Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parser gets stuck in infinite loop if final line doesn't contain \n #2

Open
mathewdbutton opened this issue Dec 2, 2023 · 1 comment

Comments

@mathewdbutton
Copy link

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?

@DRBragg
Copy link
Owner

DRBragg commented Dec 4, 2023

Hey @mathewdbutton, thanks for the bug report! Def feel free to open a PR to fix this, I'd love to take a look

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants