Skip to content

Question: commonmark-attributes-extension Add attribute to <pre> tag? #631

Answered by colinodell
rob4226 asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @rob4226,

How would I target a fenced code block's <pre> tag?

The custom attributes get applied to the FencedCode block in our AST. When it's time to render that block, the FencedCodeRenderer produces the nested <pre><code>...</code></pre> HTML. The challenge here is that we have Markdown block being converted into two nested HTML elements, so we must pick one of those HTML elements to contain the attributes.

The "info string" is usually added to the <code> block, since most syntax highlighters expect it to be there, so we decided that any other attributes should also be applied to the <code> block and not the <pre> block.

This means that, without any customization on your end, the …

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by colinodell
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question General questions about the project or usage
3 participants
Converted from issue

This discussion was converted from issue #611 on June 12, 2021 13:51.