I would like to modify the way some html tags are rendered on jekyll. What I need is to add some css classes automatically (in this case the ".table" class to the table html tag).
I'm using the redcarpet markdown processor. I suppose I need to write a plugin that extends the renderer but I can't find any good example...
I came up with this but it's just a copy/paste job and it doesn't work...
require 'redcarpet'
class BootstrapTables < Redcarpet::Render::HTML
def table(header, body)
"\n<table class='table'><thead>\n#{ header }</thead><tbody>\n#{ body }</tbody></table>\n"
end
end
Someone can help?
I've tested that you can give a class to a markdown element with kramdown
{:.foo}
| First Header | Second Header |
| ------------- | ------------- |
| Content Cell | Content Cell |
| Content Cell | Content Cell |
Your table has the class foo
NB : this answer was given one month ago on SO
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With