Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jekyll, modify the way some html tags are rendered

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?

like image 208
cyrusza Avatar asked Dec 11 '22 04:12

cyrusza


1 Answers

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

like image 116
David Jacquel Avatar answered Jan 07 '23 19:01

David Jacquel