Producing markdown slides and article with the same source

自古美人都是妖i 提交于 2021-02-08 09:31:41

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!