5

My Question: Is there a way in Pandoc markdown to mark inline class (or id) elements that could then be output to LaTeX and html and if so, how?

I am looking for a "one input many outputs" publication solution with needed output of LaTeX and epub, but with desired output of .docx. In LaTeX I have defined \mytag{foo} which would correspond to <span class="myclass">foo</span> in html for certain word level mark up. (In MSWord, Libreoffice and Adobe Indesign it is possible to set character styles for this purpose.)

The closest thing I can find to an answer is this minimalistic statement and example from the Pandoc documenation:

Headers can be assigned attributes using this syntax at the end of the line containing the header text:

{#identifier .class .class key=value key=value}

BrianWilson
  • 1,653
  • 2
  • 12
  • 16

2 Answers2

10

pandoc got updated recently, now you can do:

`code with class`{.class}

and

[Span with class]{.class}
karelv
  • 756
  • 9
  • 20
  • 1
    To use this feature in word as well (style), it's `{custom-style=class}` instead of `{.class}`. – Bowi Jun 20 '17 at 09:13
5

No, there's no way to mark arbitrary elements (though the syntax you mention works for headers).

You can use HTML spans and divs with attributes. These can contain Markdown content, and will produce native pandoc Span and Div elements in the internal document model (AST). These can be intercepted by filters and replaced with raw LaTeX when you're targeting LaTeX -- you have to do a bit of scripting for this, but it's fairly minimal. If you have trouble writing a filter, people on pandoc-discuss are often glad to help.

John MacFarlane
  • 8,511
  • 39
  • 33