3

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 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.