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

(YAML) Multiline strings don't support empty lines #4090

Open
dmelikhov opened this issue Aug 9, 2024 · 3 comments · May be fixed by #4111
Open

(YAML) Multiline strings don't support empty lines #4090

dmelikhov opened this issue Aug 9, 2024 · 3 comments · May be fixed by #4111
Labels
bug help welcome Could use help from community language

Comments

@dmelikhov
Copy link

dmelikhov commented Aug 9, 2024

Describe the issue
YAML multiline strings break on first empty line even when the rest of the block is properly indented.

Which language seems to have the issue?
YAML

Are you using highlight or highlightAuto?
highlight

Sample Code to Reproduce

foo:
  bar: |
    still: a string

    not: anymore

Additional context
I was able to workaround the issue by replacing this regex with

[\\|>]([1-9]?[+-])?[ ]*\\n+( +)[^ ][^\\n]*\\n+(\\2[^\\n]+\\n*)*

It's not perfect and still has some false positives/negatives but should cover more valid cases.

@dmelikhov dmelikhov added bug help welcome Could use help from community language labels Aug 9, 2024
@joshgoebel
Copy link
Member

joshgoebel commented Aug 9, 2024

YAML is the worst. :) What are the valid rules for multi-line strings anyways? Is there some chance we could do this better with our own parser rather than a super complex regex?

Did we just change the \n+ to \n*?

@dmelikhov
Copy link
Author

The first thing that came to my mind after seeing the regex is this. :)

I don't have enough knowledge about the library's architecture, but I think it's not possible to properly detect multiline strings using a regex, as it knows nothing about the property's indentation that contains the multiline string.

@joshgoebel In the regex I mentioned \n is replaced by \n+ and \n? is replaced by \n*. But I can't give you any guarantees that it's better than the currently used one.

@Dxuian
Copy link
Contributor

Dxuian commented Sep 1, 2024

i believe added a fix for this @joshgoebel pls 🙏🙏🙏 review #4111 (and other prs)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug help welcome Could use help from community language
Projects
None yet
3 participants