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

Add more Markdown backends #179

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from
Draft

Add more Markdown backends #179

wants to merge 12 commits into from

Conversation

LukeMoll
Copy link
Member

@LukeMoll LukeMoll commented Sep 29, 2021

Adds the following (CommonMark-compliant) Markdown backends:

  • cmark
  • commonmark
  • mistletoe
  • markdown-it-py

At some point in the future, the goal will be to switch to one of these (or another CommonMark implementation). This PR does not intend to change the default backend, but to provide the tools to evaluate a replacement for a future PR to switch to.

TODO

  • Update documentation in docs/
    • The abstraction layer barely needs documenting; if someone wants to add docstrings to it they're welcome to.
  • Get syntax highlighting working
    • For the time being, "offline" highlighting (eg with Pygments) is preferred to simply tagging <pre> blocks for a JavaScript-based highlighter to process on the client-side.
    • Mistletoe
      • Working using Pygments
    • CommonMark
      • Working using Pygments
      • No table support
    • Markdown-It
      • Working using Pygments
    • cmark
      • Unlikely to support syntax highlighting extensions -- this is probably in a "done" state

@LukeMoll LukeMoll added the backend Relating to the code which runs on the server and generates the site label Sep 29, 2021
@sersorrel
Copy link
Member

testcase for the various markdown renderers: https://www.hacksoc.org/news/2021-05-25-moving-to-libera.html, specifically does #cs-york render as a heading or not (in a commonmark-compliant renderer, it should not)

@LukeMoll
Copy link
Member Author

That was in fact the article that made me aware of the problem, and I did use it while setting up the new backends 😅

@sersorrel
Copy link
Member

i definitely thought it had been brought up somewhere, yeah, but i couldn't find any references to it – i guess maybe it got slacked

Copy link
Member

@sersorrel sersorrel left a comment

Choose a reason for hiding this comment

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

whitespace moment


```
# Equivalent; markdown2 is the default backend
hacksoc_org run
hacksoc_org run --markdown markdown2
hacksoc_org run --markdown markdown2
Copy link
Member

Choose a reason for hiding this comment

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

super minor nitpick

Suggested change
hacksoc_org run --markdown markdown2
hacksoc_org run --markdown markdown2

Comment on lines +67 to +68
```
#### Markdown2 (Current default)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
```
#### Markdown2 (Current default)
```
#### Markdown2 (Current default)

Comment on lines +76 to +77
Fork of the CommonMark reference implementation, maintained by GitHub to provide [GFM](https://github.github.com/gfm/) features. Only provides syntax highlighing for the client-side, by adding a (eg.) `lang="py"` attribute to `<pre>` blocks for a JavaScript library to parse and highlight.
#### CommonMark
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Fork of the CommonMark reference implementation, maintained by GitHub to provide [GFM](https://github.github.com/gfm/) features. Only provides syntax highlighing for the client-side, by adding a (eg.) `lang="py"` attribute to `<pre>` blocks for a JavaScript library to parse and highlight.
#### CommonMark
Fork of the CommonMark reference implementation, maintained by GitHub to provide [GFM](https://github.github.com/gfm/) features. Only provides syntax highlighing for the client-side, by adding a (eg.) `lang="py"` attribute to `<pre>` blocks for a JavaScript library to parse and highlight.
#### CommonMark

Comment on lines +82 to +83
**Does not support tables**.
#### Mistletoe
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
**Does not support tables**.
#### Mistletoe
**Does not support tables**.
#### Mistletoe

Comment on lines +86 to +87
Gives an example integration of Pygments for syntax highlighing, adapted into [`mistletoe_pygments_renderer.py`](../hacksoc_org/markdown/mistletoe_pygments_renderer.py)
#### Markdown-it
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Gives an example integration of Pygments for syntax highlighing, adapted into [`mistletoe_pygments_renderer.py`](../hacksoc_org/markdown/mistletoe_pygments_renderer.py)
#### Markdown-it
Gives an example integration of Pygments for syntax highlighing, adapted into [`mistletoe_pygments_renderer.py`](../hacksoc_org/markdown/mistletoe_pygments_renderer.py)
#### Markdown-it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend Relating to the code which runs on the server and generates the site
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants