如何在另一个Markdown文件中读取Markdown文件? [英] How to read a markdown file in another markdown file?
问题描述
我的目的是将许多用markdown编写的描述收集到一个集成文章的单个markdown文件中.
My purpose is to collect many descriptions written in markdown to a single markdown file for an integrated article.
例如,在./f1/a.md
For instance, in ./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 expected result of the b.md should be,
The introduction of f1 project is shown below,
This is the description for f1 project.
那么,我该如何实现此功能?
So, how can I achieve this function?
推荐答案
Markdown本身不支持文件包含,但是根据您使用的Markdown处理器,您有两种选择:
Markdown itself doesn't support file inclusions, but depending on the Markdown processor you are using you've got a couple of options:
-
某些Markdown处理器支持多个输入文件.例如, Pandoc 可以获取多个输入文件并生成一个输出文件:
Some Markdown processors support multiple input files. For example, Pandoc can take multiple input files and generate a single output file:
pandoc -o output.html one.md two.md three.md
您可以按照正确的顺序简单地将各个源文件连接在一起,然后将该连接的文件用作输入,以简化分析器:
You could simply concatenate your individual source files together in the correct order, then use that concatenated file as a single input for a less flexible parser:
cat one.md two.md three.md > source.md
markdown source.md
如果您使用的是Windows,则可能需要将 cat
替换为 type
.
If you are on Windows you will probably need to replace cat
with type
.
根据您输入的复杂性,您可能希望自动执行此过程.像 make
这样的工具可以帮助解决这个问题.
Depending on the complexity of your input, you may want to automate this process. A tool like make
could help with this.
这篇关于如何在另一个Markdown文件中读取Markdown文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!