1

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.

Community
  • 1
  • 1
Nicola
  • 23
  • 5

2 Answers2

1

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>
John MacFarlane
  • 8,511
  • 39
  • 33
  • Thank you. It works. I already tried to add a blank line before the HTML block but it didn't work because it requires also a newline after
    and before
    .
    – Nicola Jan 23 '14 at 09:51
  • This doesn't work in recent versions of pandoc. This does however: https://stackoverflow.com/a/48083891/1175053 – C S May 13 '18 at 01:12
0

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}'.

  • Thank you Ryan.I think these are two different questions. If Markdown is not parsed, then the text is printed out without to be formatted. By the way, I am looking how print a text only in HTML output and not in TEX/PDF output. Hope someone can help me. – Nicola Jan 22 '14 at 08:39