How to read a markdown file in another markdown file?

邮差的信 提交于 2021-02-10 23:46:59

问题


My purpose is to collect many descriptions written in markdown to a single markdown file for an integrated article.

For instance, in ./f1/a.md

This is the description for f1 project. 

and in ./b.md

The introduction of f1 project is shown below, 
<!-- Contain of the a.md goes here -->

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?


回答1:


Markdown itself doesn't support file inclusions, but depending on the Markdown processor you are using you've got a couple of options:

  • 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.



来源:https://stackoverflow.com/questions/28294926/how-to-read-a-markdown-file-in-another-markdown-file

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