Pandoc is a tool that can convert many different markups to one another.

Install

brew install pandoc

Usage

Basic usage:

# Convert HTML to Plain Text
pandoc file.html --wrap=none -t plain -o file.txt
 
# Convert Markdown to Open Doc
pandoc ~/notes/emerging-tech-trends-2024.md -f markdown -t odt -s -o ~/Downloads/emerging-tech-trends-2024.odt
 
# Convert Markdown to HTML
pandoc ~/notes/scratch_buffer.md -s -o ~/Downloads/scratch_buffer.html
 
# With template
pandoc ~/notes/scratch_buffer.md -s --template template.html -o ~/Downloads/scratch_buffer.html

Convert all the files in a directory:

find ./ -iname "*.html" -type f -exec sh -c 'pandoc "${0}" -t plain --wrap=none -o "${0%.html}.txt"' {} \;