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

fix: inconsistent YAML multiline parsing (#475) #724

Merged

Conversation

guilgaly
Copy link
Contributor

@guilgaly guilgaly commented Jan 11, 2023

When the YAML block scalar (multiline string) syntax is used with only one line of text, the single line is not matched by the current regexp. It currently only works with at least two lines.

This fixes the regexp by adding a special case for a single line after the first indentation in the block.


This is a fix for issue #475.

I tested the regexp used in the lexer, it simply doesn't match the content of the block scalar if it contains only one line; I guess the rendering inconsistency came from that line then being matched as something else.

The regexp uses a backreference to check that following lines (after the first) all have at least as much indentation as the first line; but this doesn't work when there is only the first line. I basically just added a special case when there is only one line.

When the YAML block scalar (multiline string) syntax is used with only one line of text, the single line is not matched by the current regexp. It currently only works with at least two lines.

This fixes the regexp by adding a special case for a single line after the first indentation in the block.
@guilgaly
Copy link
Contributor Author

This is my first contribution here, please let me know if I should add anything else! 🙂

@alecthomas
Copy link
Owner

Lovely, thanks!

@alecthomas alecthomas merged commit 5ca7345 into alecthomas:master Jan 12, 2023
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

Successfully merging this pull request may close these issues.

None yet

2 participants