Editing enclosing <pre> tag attributes for an IndentedCodeBlock with AttributeProviderFactory
See original GitHub issueI’m new to commonmark-java
, and am trying to figure out how to apply a CSS class to all <pre>
tags surrounding an IndentedCodeBlock
. I was successfully able to apply attributes to Header
and BlockQuote
nodes, but if I match a Node with IndentedCodeBlock
and add a class to the attribute map, then it applies it to the <code>
tag in the HTML it renders.
I think what’s happening here is that <pre>
isn’t a Node, just an artefact of the way the HtmlRenderer
renders the IndentedCodeBlock
(and FencedCodeBlock
) Nodes, and so I’m never able to override the attributes for the <pre>
tag because it never goes through the AttributeProviderContext
as a Node.
If I’m understanding this correctly, the only way to do this would be to override the rendering itself for FencedCodeBlocks
and IndentedCodeBlocks
.
Do you think it makes sense to allow for overriding the attributes of tags where more than 1 set of tags is generated per node? Perhaps the AttributesProvider
could provide attributes for the outer tags first with an override for providing attributes inside of the nested structure?
Issue Analytics
- State:
- Created 7 years ago
- Comments:5
Top GitHub Comments
Implemented and released in version 0.8.0 now. Thanks for reporting! 😃
Yep, I meant calling it multiple times, with an additional string argument.
The
Map<Map<...
seems a bit too complicated and error-prone (what happens when implementation removes a whole tag, or adds new ones, etc).I plan to look into this tomorrow!