如何在另一个markdown文件中读取markdown文件?

3
我的目的是将许多以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. 

所以,我该如何实现这个功能?
1个回答

2

Markdown本身不支持文件包含,但根据你使用的Markdown处理器,你有几个选项:

  • 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
    

    If you are on Windows you will probably need to replace cat with type.

    Depending on the complexity of your input, you may want to automate this process. A tool like make could help with this.


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接