Use a specific class depending on the bullet with Markdown / Pandoc

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

I would like to have a cool bullet using the classic * character and have a + (cool!) Logo and - (not cool) with a + and - bullet.

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

+4
source share
2 answers

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

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

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

(The lack of a tag indicates that this may not be the solution you're looking for ...)

+6
source

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

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

will provide you with HTML as follows:

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

and you can use the CSS selector as follows:

 span.styledlist ul { ... } 

Not the most beautiful Markdown or HTML, but it works.

+1
source

Source: https://habr.com/ru/post/1438670/


All Articles