Since a few people have reached out and thanked me for my previous post Batch Converting Images to webp with macOS Automator, I thought I would continue to share more of my own custom Automator Quick Actions. Today’s post will cover the ability to convert any text-based document into pure HTML.
I know - there are over 6 billion conversion apps that do this very same thing. But our way of doing it is cooler. Our conversion tool:
And it can do all of this for free on your existing macOS system. No apps required. So, enough chit-chat, let’s get started!
Unfortunately, setting things up isn’t as simple as clicking a single Install
button and calling it a day. But don’t start to panic! I assure you everything we’ll be doing is actually quite easy to breeze through - trust me.
Our main requirements will consistent of the following:
Homebrew is a simple package manager for macOS. The beauty of having Homebrew is the flexibility in the future for installing other custom packages. Overall it’s just a nice piece of software to have on your machine.
If you have already installed Homebrew in the past, ignore this step and continue down the page. If not, simply open your Terminal and run:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Let that finish and you’re done! Also feel free to read more about Homebrew on the official website. Knowledge is power!
The package that is going to be doing all the heavy-lifting for us is pandoc. Because we have Homebrew on our machine now, installing this package is as simple as opening our Terminal again and running:
brew install pandoc
Wait for everything to finish and you’re done!
Next you’ll want to open the macOS Automator app and create a new “Quick Action” when given the prompt to do so.
Now do the following (reference the image further below to make sure your parameters match):
Once all that is done, simply paste the following in the open text field within the “Run Shell Script” item:
for f in "$@"
do
/opt/homebrew/bin/pandoc -o "${f%.*}.html" "$f"
done
If you’ve done everything correctly it should look something like this:
Save this new Quick Action (Name is something like “Convert to HTML” to keep things simple). That’s it! Amazing, right?
Now it is finally time to see our Quick Action is action! Navigate to any document file in a Finder window and follow along.
Quick Actions
.Convert File to HTML
and click it. (Figure 2)If everything was set up properly (and depending on the size of the file) you should see your converted HTML file show up right next to your existing document. Time to celebrate!
Don’t forget - you can also batch convert multiple files and multiple file types at once. The possibilities are endless!
Although this article has mainly focused on converting documents to HTML, pandoc
is so powerful you could do any number of conversions. Re-using these steps above, you have the ability to make as many different conversion quick actions as your heart desires!
Have fun converting!
I'm extremely grateful for the support from the "Hall of Fame" supporters:
adast.dk
alessandrocuzzocrea.com
alexeystar.com
arc-x.org
artemislena.eu
b0ba.dev
cleberg.net
danielsada.tech
dieses-veganismus.de
gtrr.artemislena.eu
iosis-labs.com
jakobmagnusson.se
jamieonkeys.dev
kristianscott.co.uk
lukealexdavis.co.uk
miniskirt.me
nicksherman.com
simone.org
t0.vc
tedmagaoay.com
willem.com
wonger.dev
xslendi.xyz
zoraster.org
If you too would like to support this project and help fund more articles like this one:
Become a supporter today →