Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pandoc add class to table in markdown

For a heading, for a code-block, for a span element we can with pandoc add {.class} to add a class.

# Heading 1 {.my_class_for_heading1}

Here is some `code`{.my_class_for_code} and 
for a [span]{.my_class_for_span} it is working as well
and for img and url it is available as well
for [pandoc](http://www.pandoc.org/){.my_class_for_url}

I'm working with bootstrap, and it would be nice to specify "table" and/or "table-hover" as class such that the html view gets the table decorated with bootstrap CSS.

Anyone?

like image 481
karelv Avatar asked Jan 26 '17 15:01

karelv


1 Answers

In pandoc's internal document AST, tables have attributes since pandoc 2.10, but the markdown reader hasn't been updated for that yet. (Same for other formats.)

However, you can:

  • wrap a table in a raw HTML div with a class (this won't work for bootstrap CSS which expects the class to be on the table),
  • write a pandoc filter, or
  • probably in this case easier: post-process the output HTML to add a class.
like image 193
mb21 Avatar answered Oct 12 '22 12:10

mb21