Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Systematic way to convert multiple markdown files to html

obtained from atom/markdown-preview#289

Yep, have a look at http://pandoc.org/ or markdown-it https://github.com/markdown-it

It now depends, whether you want to merge the HTMl files or not:

# Single output files
for f in *.md ; do pandoc ${f} -f markdown -t html -s -o ${f}.html  ; done
# One output file
pandoc *.md -f markdown -t -s html -o merged.html

There are other ways to do it recursively according to https://stackoverflow.com/questions/26126362/converting-all-files-in-a-folder-to-md-using-pandoc-on-mac

You can run this in the parent directory in the terminal

find ./ -iname "*.md" -type f -exec sh -c 'pandoc "${0}" -o "${0%.md}.pdf"' {} \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment