我的目的是将用 Markdown 编写的许多描述收集到单个 Markdown 文件中,以形成一篇综合文章。
例如,在./f1/a.md中
This is the description for f1 project.
并在 ./b.md 中
The introduction of f1 project is shown below,
<!-- Contain of the a.md goes here -->
b.md 的预期结果应该是,
The introduction of f1 project is shown below,
This is the description for f1 project.
那么,如何实现这个功能呢?
Markdown 本身不支持文件包含,但根据您使用的 Markdown 处理器,您有几个选项:
-
一些 Markdown 处理器支持多个输入文件。例如,Pandoc可以采用多个输入文件并生成单个输出文件:
pandoc -o output.html one.md two.md three.md
-
您可以简单地将各个源文件以正确的顺序连接在一起,然后使用该连接的文件作为不太灵活的解析器的单个输入:
cat one.md two.md three.md > source.md
markdown source.md
如果您使用的是 Windows,您可能需要更换cat
with type
.
根据输入的复杂性,您可能希望自动化此过程。像这样的工具make可以帮助解决这个问题。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)