Parser gets stuck in infinite loop if final line doesn't contain \n
mathewdbutton opened this issue · comments
Mathew Button commented
Hi there,
Firstly thank you for making this gem, I've been playing around with a recipe tool at home and stumbled across cooklang and your parser.
I noticed that if the recipe was missing a new line character at the end of the final line it would hang.
CooklangRb::Recipe.new("A very short recipe")
=> *hangs*
vs
CooklangRb::Recipe.new("A very short recipe\n")
#<CooklangRb::Recipe:0x0000000111c0cb70 @buffer=#<StringScanner fin>, @metadata={}, @source="A very short recipe\n", @steps=[[{"type"=>"text", "value"=>"A very short recipe"}]]>
I've got a branch that I believe fixes the issue (although no particularly elegantly). Would you consider a PR with this fix?
Drew Bragg commented
Hey @mathewdbutton, thanks for the bug report! Def feel free to open a PR to fix this, I'd love to take a look