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

Use glamour as markdown rendering backend for issue & pr previews #311

Merged
merged 2 commits into from
Feb 18, 2020
Merged

Use glamour as markdown rendering backend for issue & pr previews #311

merged 2 commits into from
Feb 18, 2020

Conversation

penguwin
Copy link
Contributor

@penguwin penguwin commented Feb 5, 2020

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

@vilmibm
Copy link
Contributor

vilmibm commented Feb 5, 2020

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.

@vilmibm vilmibm self-assigned this Feb 5, 2020
@vilmibm vilmibm self-requested a review February 5, 2020 19:01
Copy link
Contributor

@vilmibm vilmibm left a 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):

image

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 )

@muesli
Copy link
Contributor

muesli commented Feb 5, 2020

Hey @vilmibm, author of glamour here. Curious, are you using the pinned version v0.1.0 or building with git master of glamour? I'll investigate what's going on.

[edit] Managed to reproduce this locally, looking into it right now!

@muesli
Copy link
Contributor

muesli commented Feb 5, 2020

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 as soon as possible, at which point we can then simply bump its dependency in cli.

glamour uses the CommonMark compliant Goldmark markdown parser instead of
go-termd which is based on Blackfriday.
@muesli
Copy link
Contributor

muesli commented Feb 5, 2020

@vilmibm Ok, should be good for another review!

@vilmibm
Copy link
Contributor

vilmibm commented Feb 7, 2020

@muesli thank you for the turn around! i will review this soon!!

@vilmibm
Copy link
Contributor

vilmibm commented Feb 10, 2020

looking gorgeous on linux!

image

i'll test on windows after lunch.

Copy link

@IDisposable IDisposable left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@vilmibm
Copy link
Contributor

vilmibm commented Feb 13, 2020

heya @tierninho , do you have bandwidth to test this on Windows and macOS?

@penguwin
Copy link
Contributor Author

Let me know if I can help by rebasing to resolve the impending merge conflicts

Copy link
Contributor

@vilmibm vilmibm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's looking great on windows except for the checkmark. I think that's an acceptable thing for now -- it's clear that the checkbox is checked, even if the character doesn't render. Overall it's a big improvement, colorwise, on windows.

w10md

Thanks for this!

@muesli
Copy link
Contributor

muesli commented Feb 18, 2020

@vilmibm Awesome! I'll look into the checkmark rendering issue tomorrow.

@vilmibm vilmibm merged commit d682c1c into cli:master Feb 18, 2020
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.

5 participants