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
merged 1 commit into from Dec 30, 2022
Merged

Conversation

Mister-Hope
Copy link
Member

No description provided.

@Mister-Hope
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) +
          '</code></pre>\n';
};

@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
@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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants