-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
Use glamour as markdown rendering backend for issue & pr previews #311
Conversation
In my haste to add markdown rendering I somehow completely missed goldmark/glamour when picking a library to use. I would have started there had I known about it, so thanks for this! I'll test this PR out today on the various platforms we support. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One change I'd like to see is preserving the renderMarkdown
function in util instead of adding calls to glamour
throughout the code (as we're going to have even more use cases for rendering markdown).
More importantly, though, is that syntax highlighting is failing for me (both alacritty and konsole on manjaro):
Both the hy
and python
code blocks are being mostly rendered as space characters. Given that showstopper I didn't proceed and test on windows.
(The PR i'm using to test this is a pathologic one featuring a lot of markdown: vilmibm/testing#20 )
Hey @vilmibm, author of [edit] Managed to reproduce this locally, looking into it right now! |
Ok @vilmibm, we figured out what's going on here. The issue was caused by chroma not correctly rendering sources with Windows-style line endings. @penguwin will update his pull request with a work-around and the changes you requested. In the meantime I'll fix the issue upstream in |
glamour uses the CommonMark compliant Goldmark markdown parser instead of go-termd which is based on Blackfriday.
@vilmibm Ok, should be good for another review! |
@muesli thank you for the turn around! i will review this soon!! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
heya @tierninho , do you have bandwidth to test this on Windows and macOS? |
Let me know if I can help by rebasing to resolve the impending merge conflicts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vilmibm Awesome! I'll look into the checkmark rendering issue tomorrow. |
glamour uses the CommonMark 0.29 compliant goldmark markdown parser instead of go-termd which is based on blackfriday.
blackfriday is not CommonMark-complicant and cannot be extended from outside the package, since its AST uses structs instead of interfaces. Furthermore, its behavior differs from other implementations in some cases, especially regarding lists: Deep nested lists don't output correctly (russross/blackfriday#329), List block cannot have a second line (russross/blackfriday#244), etc. This behavior sometimes causes problems.
The combination of glamour/goldmark also supports all the GitHub-flavoured markdown extensions, which means rendering behaviour on the terminal should match the behaviour you expect from the GitHub website.
It also lets you configure and tweak your output-style extensively, and offers sane default styles. See: https://github.com/charmbracelet/glamour/tree/master/styles