是否有任何markdown fork允许你引用其他文件,比如包含文件?具体来说,我想创建一个单独的markdown文件,其中包含我经常调用但不总是调用的链接(调用此B.md),然后当我通过引用链接到我正在写入的md文件(A.md)时,我希望它从另一个文件(B.md)中拉出链接,而不是从当前文件(A.md)的末尾。


当前回答

我知道这是一个老问题,但我还没有看到任何关于这个效果的答案:本质上,如果你使用markdown和pandoc将你的文件转换为pdf,在页面顶部的yaml数据中,你可以包括这样的东西:

---
header-includes:
- \usepackage{pdfpages}
output: pdf_document
---

\includepdf{/path/to/pdf/document.pdf}

# Section

Blah blah

## Section 

Blah blah

由于pandoc使用latex来转换所有文档,因此包含头的部分调用pdfpages包。然后,当你包含\includepdf{/path/to/pdf/document.pdf}时,它将插入该文档中包含的内容。此外,您还可以通过这种方式包含多个pdf文件。

作为一个有趣的奖励,这只是因为我经常使用markdown,如果您想包括markdown以外的文件,例如latex文件。我稍微修改了一下这个答案。假设你有一个markdown1.md文件:

---
title: Something meaning full
author: Talking head
---

还有两个额外的乳胶文件document1,看起来像这样:

\section{Section}

Profundity.

\subsection{Section}

Razor's edge.

另一个document2.tex,看起来像这样:

\section{Section

Glah

\subsection{Section}

Balh Balh

假设您想将document1.tex和document2.tex包含到markdown1中。Md,你只要这样做,就可以降低1。Md

---
title: Something meaning full
author: Talking head
---

\input{/path/to/document1}
\input{/path/to/document2}

用pandoc检查一下。

在终端pandoc markdown1。Md -o markdown1.pdf

你的最终文档看起来是这样的:

有意义的事

的头部特写

部分

深刻。

部分

剃刀边缘。

部分

Glah

部分

Balh Balh

其他回答

切换到asciidoc,这样你就不必使用Markdown这样的语言了,这些语言现在非常原始:)

我在Mac OS x上使用标记2,它支持以下语法来包含其他文件。

<<[chapters/chapter1.md]
<<[chapters/chapter2.md]
<<[chapters/chapter3.md]
<<[chapters/chapter4.md]

遗憾的是,您不能将其提供给pandoc,因为它不理解语法。但是,编写一个脚本来剥离语法来构造一个pandoc命令行是非常容易的。

事实上,你可以使用\input{filename}和\include{filename}这两个乳胶命令, 因为它支持几乎所有的html和latex语法。

但是要注意,包含的文件将被视为乳胶文件。但是您可以使用Pandox轻松地将您的markdown编译为latex。

我知道这是一个老问题,但我还没有看到任何关于这个效果的答案:本质上,如果你使用markdown和pandoc将你的文件转换为pdf,在页面顶部的yaml数据中,你可以包括这样的东西:

---
header-includes:
- \usepackage{pdfpages}
output: pdf_document
---

\includepdf{/path/to/pdf/document.pdf}

# Section

Blah blah

## Section 

Blah blah

由于pandoc使用latex来转换所有文档,因此包含头的部分调用pdfpages包。然后,当你包含\includepdf{/path/to/pdf/document.pdf}时,它将插入该文档中包含的内容。此外,您还可以通过这种方式包含多个pdf文件。

作为一个有趣的奖励,这只是因为我经常使用markdown,如果您想包括markdown以外的文件,例如latex文件。我稍微修改了一下这个答案。假设你有一个markdown1.md文件:

---
title: Something meaning full
author: Talking head
---

还有两个额外的乳胶文件document1,看起来像这样:

\section{Section}

Profundity.

\subsection{Section}

Razor's edge.

另一个document2.tex,看起来像这样:

\section{Section

Glah

\subsection{Section}

Balh Balh

假设您想将document1.tex和document2.tex包含到markdown1中。Md,你只要这样做,就可以降低1。Md

---
title: Something meaning full
author: Talking head
---

\input{/path/to/document1}
\input{/path/to/document2}

用pandoc检查一下。

在终端pandoc markdown1。Md -o markdown1.pdf

你的最终文档看起来是这样的:

有意义的事

的头部特写

部分

深刻。

部分

剃刀边缘。

部分

Glah

部分

Balh Balh

我使用一个包含我所有文件的正确顺序的include .txt文件 我像这样执行pandoc:

Pandoc -s $(cat includes.txt)——quiet -f markdown -t html5——css Pandoc .css -o index.html

效果好极了!