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

Make glamour compliant with CommonMark #122

Open
jordanbtucker opened this issue Sep 17, 2021 · 4 comments
Open

Make glamour compliant with CommonMark #122

jordanbtucker opened this issue Sep 17, 2021 · 4 comments

Comments

@jordanbtucker
Copy link

jordanbtucker commented Sep 17, 2021

CommonMark is a document that attempts to specify Markdown unambiguously. If Markdown renderers adhere to this specification, then authors can be sure that all Markdown documents render in a predictable way, which also benefits the author's audience and makes Markdown documents more portable.

Although CommonMark specifies how Markdown should be translated to HTML, glamour could, and in my opinion should, ensure that its own output mimics the visual rendering of CommonMark's HTML output as closely as reasonably possible.

There of course will be exceptions. One example is headings. Since stylesheets render different heading levels with varying font sizes and weights, and since ANSI terminals don't support varying font sizes, it's better for glamour to output bold text and include the leading # characters.

However, there are still some cases where glamour does not produce the expected output for someone familiar with CommonMark. See #106 and charmbracelet/glow#212, for example.

To aide in increasing CommonMark compliance, glamour developers could make use of CommonMark's test cases. This is a JSON document describing an array of test case objects, each with a markdown field as input and an html field as output. Glamour developers could translate the HTML output to something that makes sense for ANSI terminals and include these modified test cases in its own test suite.

Thank you for considering this proposal. I look forward to your feedback.

@ceuk
Copy link

ceuk commented Dec 10, 2021

Just to provide an alternative opinion on this: I really like the headings sans # at the mo. Programs like mdcat have more markdown-looking renders but they aren't as visually pleasing IMO.

I can see why this is a good idea - but if you guys do consider if I would request it be a config option as opposed to something that can't be disabled again if desired :)

@muesli
Copy link
Contributor

muesli commented Dec 10, 2021

@ceuk The styles are editable and you can easily come up with your own style that includes or removes the # prefixes. See: https://github.com/charmbracelet/glamour/tree/master/styles

We'll also happily accept user-contributed styles!

@muesli
Copy link
Contributor

muesli commented Dec 10, 2021

@jordanbtucker The plan is indeed to make glamour fully CommonMark compliant, and we're already using a bunch of their test-cases. I agree that we still have some work to do in certain areas and - as so often - the devil is in the details 😉 We've already made some progress towards #212 and I hope the next release addresses a few of the other issues as well.

@ceuk
Copy link

ceuk commented Dec 10, 2021

Oh man you're too fast I Just realised and came back to commit exactly this :D

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

3 participants