-
-
Notifications
You must be signed in to change notification settings - Fork 395
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
Line feed following printable character is detected as an error for VimL #827
Comments
I would suggest trying to replicate this in the Chroma playground, which will eliminate the many layers of indirection at play. |
You can re-produce it in the playground, you will see the error span in the html output. |
Ah sorry, I somehow missed your invocation from the command line 🤦 Thanks for doing that. |
Should be fixed. I also added a couple more keywords to vim, though there are millions of them so... |
Fantastic, thank you very much 👍 |
Glamour renders \n as visible error when rendering VimL code blocks. This is due to a bug in Chroma, now fixed, but yet to be released, combined with the code block error style in Glamour rendering errors with a red background (rather than Chroma default of using red text). Updating Glamour styles to use red text rather than a red background works around this, because there is no printable text to highlight. See alecthomas/chroma#827 for more info Although this might seem like a fugly hack to address one specific issue, it seems a pretty reasonable default to me as Glamour has no control over Chroma's parsing of code blocks, only the highlighting.
Glamour renders \n as visible error when rendering VimL code blocks. This is due to a bug in Chroma, now fixed, but yet to be released, combined with the code block error style in Glamour rendering errors with a red background (rather than Chroma default of using red text). See alecthomas/chroma#827 for more info Updating Glamour styles to use red text rather than a red background works around this, because there is no printable text to highlight. For dracula I've swapped the code block error and generic deleted styles, as otherwise both would be styled using the same red text. Although this might seem like a fugly hack to address one specific issue, it seems a pretty reasonable default to me as Glamour has no control over Chroma's parsing of code blocks, only the highlighting.
Glamour renders \n as visible error when rendering VimL code blocks. This is due to lexer bug in Chroma, now fixed, but yet to be released, combined with the code block error style in Glamour rendering errors with a red background (rather than Chroma default of using red text). See alecthomas/chroma#827 for more info Updating Glamour styles to use red text rather than a red background works around this, because there is no printable text to highlight. Note that for dracula, the style for generic deleted and error are now the same, but this seems a reasonable compromise as generic deleted is primarily for diffs, which seem less likely to result in lexer errors. Although this might seem like a fugly hack to address one specific issue, it seems a pretty reasonable default to me as Glamour has no control over Chroma's parsing of code blocks, only the highlighting, and barring a new release of Glamour with updated dependencies, cannot do anything about Chroma lexer errors other than highlight them.
I'm using glow to preview markdown within Vim and have noticed that for code blocks with the language set to vim, a line feed following a printable character is always shown as an error, e.g.
The first code block here has the language set to
vim
, the other set toruby
, line feed following a printable character is always shown as an error forvim
code blocks.Glow depends on glamour to render markdown, and Glamour depends on Chroma to add syntax highlighting to code blocks.
It looks like the root cause of this issue is that Chroma is detecting a line feed following a printable character as an error, e.g.
Glamour then highlights this as an error with a red background when rendering the code block, and that's what I end up seeing in the output from Glow. I can work around this telling glow to use custom styles and just override the rendering of errors in code blocks, but that's quite a nasty hack, so it would be really nice to see this fixed in Chroma (assuming Chroma is really the root cause here, and I may well have assumed incorrectly that Chroma is at fault).
I will try to find some time to fix this myself and open a PR, but I'm not familiar with this code at all, so It thought I'd open an issue first as this might be a simple fix for someone who knows the code.
The text was updated successfully, but these errors were encountered: