Skip to content

Understanding the output for syntax highlighter #798

Answered by gettalong
moonglum asked this question in Q&A
Discussion options

You must be logged in to vote

Thanks! 😄

kramdown itself doesn't know what the specific syntax highlighter does. It may as well just output plain text without any HTML tags at all. This is the reason why kramdown adds the outer-most <div> tag so that a highlighted codeblock can always be determined. Another reason is that this <div> tag will get all attributes specified for the codeblock.

The inner CSS class attribute for the <pre> tag comes from the syntax highlighter option 'css_class' which gets assigned the value 'highlight' if it is not set, for backwards-compatibility. So you can get rid of that if you need to, e.g.

$ kramdown --syntax-highlighter-opts "{css_class: ''}"
~~~ruby
puts 'hi'
~~~
^D
<div class="langua…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@moonglum
Comment options

Answer selected by moonglum
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants