latex - How can I tell Pandoc to preserve and convert begin{...} to Markdown or HTML? - Stack Overflow

admin2025-04-18  4

I have LaTeX code which looks like this:

\begin{answer}
Lorem ipsum
\end{answer}

I'd like Pandoc to convert it to Markdown with inline HTML, like this:

<span style='color:red'>
Lorem ipsum
</span>

or something similar. Is there any way to do that? At the least, to include some indicator in the Markdown, even if just text ANSWER: .

Does this require a Lua filter? How would that work?

Note: I originally asked this question on tex.stackexchange, but was advised to move it here, since it's not about LaTeX primarily.

I have LaTeX code which looks like this:

\begin{answer}
Lorem ipsum
\end{answer}

I'd like Pandoc to convert it to Markdown with inline HTML, like this:

<span style='color:red'>
Lorem ipsum
</span>

or something similar. Is there any way to do that? At the least, to include some indicator in the Markdown, even if just text ANSWER: .

Does this require a Lua filter? How would that work?

Note: I originally asked this question on tex.stackexchange.com, but was advised to move it here, since it's not about LaTeX primarily.

Share Improve this question asked Jan 29 at 11:04 SRobertJamesSRobertJames 9,22516 gold badges70 silver badges123 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

Your input converts to

<div class="answer">
<p>Lorem ipsum</p>
</div>

in pandoc 3.5, which you can style with CSS, like:

.answer::before {
  content: 'Answer ';
}
转载请注明原文地址:http://anycun.com/QandA/1744970915a90212.html