Skip to content

Instantly share code, notes, and snippets.

@bzerangue
Created April 26, 2012 23:14
Show Gist options
  • Save bzerangue/2504041 to your computer and use it in GitHub Desktop.
Save bzerangue/2504041 to your computer and use it in GitHub Desktop.
RECURSIVELY Bash convert all your html to markdown files (with Pandoc)
find . -name "*.ht*" | while read i; do pandoc -f html -t markdown "$i" -o "${i%.*}.md"; done
@AlexJameson
Copy link

Thank you! Helped me to convert multiple folders of .md files to .docx and saved a lot of time

@matiasdiez
Copy link

This is great! Thank you.

@OldManUmby
Copy link

Is there an adjustment to make it convert HTML tables to Markdown tables?

@bzerangue
Copy link
Author

@OldManUmby - after doing a web search, it looks you can do it through their pipe_tables extension.

https://pandoc.org/chunkedhtml-demo/8.9-tables.html#extension-pipe_tables

You need to look into how to set that extension up. I am not sure how it works. I did this little one-liner 13 years ago, and I am not sure how the Pandoc software has changed since then.

find . -name "*.ht*" | while read i; do 
  pandoc -f html -t markdown+pipe_tables "$i" -o "${i%.*}.md";
done

@OldManUmby
Copy link

Yep, that's what I found, too. THX!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment