0

This may be a trivial problem, but I could not find a solution. I need to translate a markdown file into LaTeX using kramdown. However, in the .md file I have blocks of lines which has been already preprocessed, so that they contain LaTeX commands.

markdown text 
markdown text 
markdown text 
markdown text

\latexcommand
\latexcommand

markdown text
markdown text

Is it possible to tell kramdown to pass such lines verbatim (possibly by "marking" them in some way) when converting to LaTeX?

Massimo2013
  • 533
  • 4
  • 17
  • Have you looked at Kramdown's [Math Blocks](https://kramdown.gettalong.org/syntax.html#math-blocks)? If so, how do they fail to meet your needs? – Waylan Oct 05 '17 at 17:09
  • I understand that math blocks put a math environment around my LaTeX commands, which I don't want. Am I wrong? – Massimo2013 Oct 06 '17 at 13:59

1 Answers1

1

kramdown has several extensions, one of them, nomarkdown, being a method for protecting content from the parser and passing the content directly to a converter.

Using your example:

markdown text·
markdown text·
markdown text·
markdown text

{::nomarkdown type="latex"}
\latexcommand
\latexcommand
{:/}

markdown text
markdown text

This will result in the following LaTeX output:

markdown text
markdown text
markdown text
markdown text

\latexcommand
\latexcommand

markdown text
markdown text

And this HTML output:

<p>markdown text
markdown text
markdown text
markdown text</p>


<p>markdown text
markdown text</p>
gettalong
  • 735
  • 3
  • 10