Question

I am writing a Markdown report with both PDF and HTML output using Pandoc. I'd like some text will appear in HTML but not in PDF. The solution proposed here isn't working for me.

What I tried so far:

My text for both HTML and PDF <div>My HTML code for HTML only</div>

and I make PDF with

~/.cabal/bin/pandoc -s -N --toc --template=default.latex -f markdown-markdown_in_html_blocks -o reproducibleResearch.pdf reproducibleResearch.md

~/.cabal/bin/pandoc contains the last version of Pandoc (~/.cabal/bin/pandoc) while Ubuntu still has 1.9.

Was it helpful?

Solution

Original markdown HTML blocks (the kind pandoc parses when you turn of the markdown_in_html_blocks extension, as you are doing) must start at the beginning of the line. From the markdown syntax description:

The only restrictions are that block-level HTML elements — e.g. <div>, <table>, <pre>, <p>, etc. — must be separated from surrounding content by blank lines, and the start and end tags of the block should not be indented with tabs or spaces. Markdown is smart enough not to add extra (unwanted) <p> tags around HTML block-level tags.

So this is what you need:

My text.

<div>
This will be ignored in non-HTML output
</div>

OTHER TIPS

There was another question on stackoverflow that was asking about markdown_in_html_blocks extension. According to that thread markdown isn't parsed in latex.

However, there is a link to pandoc's google groups page that recommend using something like the following '\begin{landscape}' and another for '\end{landscape}'.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top