Skip to content
GitLab
Next
    • Why GitLab
    • Pricing
    • Contact Sales
    • Explore
  • Why GitLab
  • Pricing
  • Contact Sales
  • Explore
  • Sign in
  • Get free trial
  • GitLab.org GitLab.org
  • GitLabGitLab
  • Issues
  • #267091

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:

  1. Move the customising of the fenced code block that Banzai::Renderer::CommonMark::HTML produces into another part of the Banzai pipeline.
  2. 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.

Edited Nov 02, 2020 by Luke Duncalfe
Assignee
Assign to
Time tracking