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

fix(markdown): respect token attrs in code block #1220

merged 1 commit into from Dec 30, 2022


Copy link

No description provided.

Copy link
Member Author

Mister-Hope commented Dec 29, 2022

Some 3rd party markdown-it plugin about code blocks is effected with this bug.

We shall not just ignore token attrs as it might contain data- information and other attrs like id and class.

The following are markdown-it default renderer and we should no break it:

default_rules.code_block = function (tokens, idx, options, env, slf) {
  var token = tokens[idx];

  return  '<pre' + slf.renderAttrs(token) + '><code>' +
          escapeHtml(tokens[idx].content) +

@Mister-Hope Mister-Hope changed the title fix(markdown): render token attrs in code block fix(markdown): respect token attrs in code block Dec 29, 2022
@meteorlxy meteorlxy merged commit b4e313b into main Dec 30, 2022
29 checks passed
@meteorlxy meteorlxy deleted the markdown/code-attr branch December 30, 2022 02:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.

None yet

2 participants