3 ms·
You don’t need to play tricks with comment characters. From the Pandoc manual (https://pandoc.org/MANUAL.html https://pandoc.org/MANUAL.html) [HN is messing wit
by leephillips 5y ago
You don’t need to play tricks with comment characters. From the Pandoc manual (https://pandoc.org/MANUAL.html https://pandoc.org/MANUAL.html) [HN is messing with the backtics, but you get the idea]:
Extension: raw_attribute
Inline spans and fenced code blocks with a special kind of attribute will be parsed as raw content with the designated format. For example, the following produces a raw roff ms block:
`````````{=ms}
.MYMACRO
blah blah
`````````
And the following produces a raw html inline element:
This is `<a>html</a>`{=html}
- dredmorbius 5y agoI'm trying to find my earlier example. This Reddit post describes the challenge / goal: https://old.reddit.com/r/pandoc/comments/7lnc38/is_it_possible_to_have_parallel_markdown_html_and/ https://old.reddit.com/r/pandoc/comments/7lnc38/is_it_possib... And ... found it. As you suggest, it turns out to be the raw_attribute extension which enables this. Note that this requires maintaining parallel content for each output format. https://stackoverflow.com/questions/48205029/pandoc-have-either-latex-or-markdown-html-render-but-not-both https://stackoverflow.com/questions/48205029/pandoc-have-eit... https://stackoverflow.com/questions/48083724/pandoc-markdown-ignore-text-in-pdf-but-include-in-html-updated https://stackoverflow.com/questions/48083724/pandoc-markdown...
- eslaught 5y agoYes, it requires parallel content. But I still think this is a better situation than a LaTeX source. While Pandoc can read LaTeX, it's limited to a fairly narrow subset. Anything you do outside of that will generate the raw formatting blocks the gp showed (and won't in general appear in any other format output). And you won't be left with any way to represent what should go in those places in HTML, ePub, etc. To put it in a more programmer centric way, Pandoc allows you to have the moral equivalent of ifdefs instead of maintaining separate source files for each output format. That's a huge advantage when you want to keep the content in sync.
- leephillips 5y agoThat’s exactly it. I usually use these raw_attribute blocks for things like tables, when I want more control than I get when leaving it to Pandoc’s translation from Markdown tables to HTML or LaTeX.
- dredmorbius 5y agoHrm.... Though there are other tools for mapping LaTeX to specific formats. I'll keep this in mind, and I'm aware that all document formatting specification conversions are lossy, ambiguous, or both. LaTeX seems to me to be the least lossy and most consistent over time, as well as sufficiently lightweight in authoring. There's an idea I've been using for myself, of a minimum sufficient level of typographic specification. For many works that is truly de minimus. I've typeset book-length works using nothing but Markdown, almost always sufficiently (there are a couple of limitations, with underlining and text justification (right or centre) being the principle ones. There's no specific hierarchy of formatting levels, though there's a rough classification, from whitespace and emphasis to formuale and interactive diagrammes, as well as document-level constructs such as tables of contents / figures / tables, etc., foot / side / end notes, bibliographic references, and indices. LaTeX supports all of these rather well. Markdown can achieve some of these. HTML itself natively has no inherent concept of many of these, though the typographic and some semantic primitives (e.g., hyperlinks) from which they can be created do exist. So if I'm looking for a consistent sufficient standard, I'd lean strongly toward LaTeX, and find ways to deal with the edge cases in conversion as they crop up.