问题
I'm trying markdown/knitr/pandoc for producing documentation and slides as an alternative to LaTeX/Beamer.
One funcionality I miss is the possibility to use the same source for both types of output (slides and articles), while being able to mark content which is specific to either format. Unmarked content will appear in both presentation and article modes.
I understand I can produce both types of output with the same source with Pandoc-markdown by specifying several *output*s in the YAML header.
However, I can't figure out how to prevent paragraphs to appear in the slides, or bullet lists to appear in the article.
Is this possible?
回答1:
This is not natively supported by Pandoc, however you can use a preprocessor. Basically he uses GPP and then writes stuff like:
<#ifdef SLIDES>
slide text
<#endif>
<#ifdef ARTICLE>
article text
<#endif>
If you know some Python or only a bit of Haskell, you can avoid installing GPP and write a simple script instead that changes the Markdown AST, see Pandoc scripting. Then you'd probably do something like:
<div class="slides">
slide text
</div>
<div class="article">
article text
</div>
来源:https://stackoverflow.com/questions/25864859/producing-markdown-slides-and-article-with-the-same-source