Easy Markdown to Word conversion in macOS
| macOS text file icon |
1. Install pandoc
% brew install pandoc -y
2. Create a new Quick Action in Shortcuts
Open the Shortcuts program under Applications on the Mac. Click + to create a new shortcut. In the editor that pops up, in the right pane click the ⓘ at the top to show Shortcut Details, and:
☑ Use as Quick Action
☑ Finder.
Me, I also made a keyboard shortcut for it, ⌥⇧⌘C (that’s command, option, shift, C (for “convert”)).
Setup the input to:
Receive Files input from Quick Actions
If there's no input:
Continue
| Configuring Shortcuts to add a new Quick Action |
Toggle the right pane back to the action pane and in the 🔍 search bar find “Run Shell Script”
| Finding the Run Shell Script action |
If prompted, configure to ☑ Allow Running Scripts:
| Setting permission in settings |
Set the shell to ‘zsh’ and pass input to ‘as arguments’ and the shell script itself to:
for f in "$@"
do
# Get the file path without the extension
filename="${f%.*}"
# Run pandoc to convert the .md file to a .docx file
/opt/homebrew/bin/pandoc "$f" -o "${filename}.docx"
done
Give it a name (in this example, “Convert Markdown to Word”):
Close the Shortcuts app and Bob’s your uncle:
Comments
Post a Comment