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

Windows-style line endings break rendering #329

Closed
muesli opened this issue Feb 6, 2020 · 6 comments
Closed

Windows-style line endings break rendering #329

muesli opened this issue Feb 6, 2020 · 6 comments

Comments

@muesli
Copy link

muesli commented Feb 6, 2020

Windows-style line endings \r\n break chroma's syntax highlighting. I've seen it break in different ways, but most commonly it will then render everything as spaces instead of text.

Providing a copyable text is difficult, as the GitHub interface would cleanup the line endings. GitHub also doesn't let me attach such a file to this issue.

Replacing \r\n and \r with \n before passing the source to chroma works around the problem.

@chmike
Copy link

chmike commented Feb 16, 2020

I confirm the problem.

Text obtain from a textarea html form has its lines terminated by \r\n. A filtering is required to replace \r\n with \n.

satotake added a commit to satotake/chroma that referenced this issue Feb 23, 2020
@alecthomas
Copy link
Owner

Can someone try #336? Given there's no data to verify that this fixes the issue, I'd prefer someone to verify it before merging.

@muesli
Copy link
Author

muesli commented Mar 2, 2020

@alecthomas This is pretty much the workaround I use locally, at the moment. I'm actually wondering if it needs to be a separate option or if this isn't a sanitizer we always want to run?

@satotake
Copy link
Contributor

satotake commented Mar 3, 2020

I am wondering, too. @muesli

Theoretically, there can be lexers which do not handle \n as EOL and accept only \r or \r\n.
I had suspected some windows-driven files might be so.
Fortunately, it was not the case of the lexers which chorma is using.
At least, they are so rare.

alecthomas pushed a commit that referenced this issue Mar 4, 2020
* Add new TokeniseOption EnsureLF

ref #329

* Use efficient process suggested by @chmike
@alecthomas
Copy link
Owner

Fix merged please verify.

@muesli
Copy link
Author

muesli commented Mar 4, 2020

@alecthomas Verified as fixed. Thanks everyone!

mrsdizzie pushed a commit to mrsdizzie/chroma that referenced this issue Jul 15, 2020
* Add new TokeniseOption EnsureLF

ref alecthomas#329

* Use efficient process suggested by @chmike
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

4 participants