Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use a specific class depending on bullet with Markdown/Pandoc

I use Markdown to write my training documents, and I convert them to HTML using Pandoc.

I'd like to have a class bullet using the classic * character, and having the logo + (cool!) and - (not cool) using bullets +and -.

Currently I have no differences in the output HTML. How could I add a class depending on the bullet?

like image 867
Nicolas Zozol Avatar asked Feb 19 '23 22:02

Nicolas Zozol


2 Answers

To get HTML class attributes out of Pandoc, you have to set these attributes explicitly in the input files. This is supported only for code blocks, and does not work automatically.

To get classes for lists, you need to modify Pandoc to output them.

In src/Text/Pandoc/Writers/HTML.hs, attributes for code blocks are generated in attrsToHtml, called from blockToHtml or inlineToHtml. You would have to extend unordList to generate an attribute and to call attrsToHtml on it.

(The absence of the haskell tag indicates that this might not be the solution you are looking for ...)

like image 73
CL. Avatar answered Mar 15 '23 20:03

CL.


If you mean list bullets you can wrap the list in a div with a class and use a corresponding CSS selector:

<div class="styledlist">
+   foo
+   bar
+   baz
</div>

will give you HTML like this:

<div class="styledlist">
<ul>
<li>foo</li>
<li>bar</li>
<li>baz</li>
</ul>
</div>

and you can use a CSS selector like this:

span.styledlist ul { ... }

Not the prettiest Markdown or HTML but it works.

like image 24
bpj Avatar answered Mar 15 '23 20:03

bpj