Remove Banzai::Renderer::CommonMark::HTML
Summary
This issue was created from this discussion https://gitlab.com/gitlab-org/gitlab/-/issues/263114#note_428271807.
We currently implement a custom commonmarker
rendering class Banzai::Renderer::CommonMark::HTML
which has the sole purpose of producing fenced code blocks in a format that renders nicely on GitLab.com (see this code comment).
Problem
@toupeira noticed https://gitlab.com/gitlab-org/gitlab/-/issues/263114#note_428271807 an issue https://github.com/gjtorikian/commonmarker/issues/112 that mentioned that doing so makes a renderer that is an "all or nothing" override of the C class with Ruby.
From https://github.com/gjtorikian/commonmarker/issues/112#issue-545161219, the style of rendering benchmarked as 10x slower (commonmarker_our_custom_renderer
) is how we currently render markdown.
Example code block styles
Our Banzai::Filter::MarkdownEngines::CommonMark
class currently outputs code blocks like this:
<pre><code lang="LANG">some code\n</code></pre>
GitHub-style looks like this:
<pre lang="LANG"><code>some code\n</code></pre>
And default Markdown style looks like this:
<pre><code class="language-LANG">puts 1\n</code></pre>
Improvements
If we can delete Banzai::Renderer::CommonMark::HTML
we might get ~10x speed up improvement in rendering markdown.
We could either:
- Move the customising of the fenced code block that
Banzai::Renderer::CommonMark::HTML
produces into another part of the Banzai pipeline. - Modify however GitLab renders fenced code blocks so that it works with either GitHub-style code fences or CommonMarker's default rendering of fenced code blocks.
Risks
We want to make sure that cached markup continues to work.
Involved components
TBD.