question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Editing enclosing <pre> tag attributes for an IndentedCodeBlock with AttributeProviderFactory

See original GitHub issue

I’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:closed
  • Created 7 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
robinstcommented, Dec 9, 2016

Implemented and released in version 0.8.0 now. Thanks for reporting! 😃

0reactions
robinstcommented, Dec 8, 2016

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!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Editing enclosing <pre> tag attributes for an ... - GitHub
I'm new to commonmark-java, and am trying to figure out how to apply a CSS class to all tags surrounding an IndentedCodeBlock.
Read more >
<pre>: The Preformatted Text element - HTML - MDN Web Docs
The HTML element represents preformatted text which is to be presented exactly as written in the HTML file. The text is typically rendered ......
Read more >
How to preserve whitespace indentation of text enclosed in ...
This code uses the first line inside the PRE tag to determine how much it has been indented purely due to the indentation...
Read more >
Considerations for styling the < pre > tag - Media Temple
Personally, I'm split. When coding in my code editor, I prefer it when long lines that break the width of the visible area...
Read more >
HTML pre tag - W3Schools
Text in a <pre> element is displayed in a fixed-width font, and the text preserves both ... The <pre> tag also supports the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found