Pandoc markdown: Omit text in PDF version but incl

2019-02-18 18:52发布

问题:

I'm trying to maintain two versions of my CV, one with lots of gloss and one that's more conventional. The glossy version will be HTML. I have it working with images (e.g. when I include an image using straight-up HTML code, Pandoc non-strict ignores the image and alt text in the PDF version but includes it in the HTML version.

However, for straight-up text, it's not working. I've tried wrapping it in <p>text</p> or <div>text</div>, but the PDF version seems to be ignoring the code while leaving the text content intact.

Reproducible example:

**My CV**

Content to appear in both

<img src='https://www.google.com/images/srpr/logo4w.png' alt='image to only appear in HTML'>

<p>Text to only appear in HTML</p>

How do I flag text content so that it only appears in the HTML version?

回答1:

With recent versions of pandoc, you can disable the extension markdown_in_html_blocks:

pandoc -f markdown-markdown_in_html_blocks

Then the contents of <div>...</div> tags will be ignored in LaTeX/PDF output, but will still appear in HTML.