Skip to content

Complete removal of `lang` attribute on markdown code blocks

What does this MR do and why?

This completes the removal of our use the lang= attribute for our code syntax highlighting. It's not semantically correct.

We now rely solely on the data-canonical-lang attribute.

However, this does not remove the use of lang= in the final rendering of the syntax highlighted code. This is generated by the ruby syntax highlight library, and would require changing libraries, which is beyond the scope of this. That may happen as part of Add support for `syntax-highlighting` option (gitlab-org/ruby/gems/gitlab-glfm-markdown#14)

You can verify the changes by

  • going to an issue and creating a ruby code block

    ```ruby
    this = that
    ```
  • Inspect the block with browser inspector, you should see html similar to this:

    <pre class="code highlight js-syntax-highlight language-ruby white" data-canonical-lang="ruby" data-sourcepos="1:1-3:3" id="code-116">
      <code>
        <span lang="ruby" class="line" id="LC1"><span class="n">this</span> <span class="o">=</span> <span class="n">that</span></span>
      </code>
    </pre>
  • note that neither the <pre> or <code> block uses the lang= attribute

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #385036 (closed)

Edited by Brett Walker

Merge request reports