Skip to content

Instantly share code, notes, and snippets.

@halostatue
Forked from brasilikum/mjml-2-mjml-and-txt.sh
Created August 6, 2020 13:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save halostatue/e73a92ebf73449916e4755ce295b470a to your computer and use it in GitHub Desktop.
Save halostatue/e73a92ebf73449916e4755ce295b470a to your computer and use it in GitHub Desktop.
turn mjml into html and txt.
# Check if mjml is installed
if ! [ -x "$(command -v mjml)" ]; then
echo 'Error: mjml is not installed. Install with "npm install -g mjml"' >&2
exit 1
fi
# Check if html-to-text is installed
if ! [ -x "$(command -v html-to-text)" ]; then
echo 'Error: html-to-text is not installed. Install with "npm install -g html-to-text"' >&2
exit 1
fi
# Run command for all files passed as arguments to the script
for FILENAME in "$@"
do
echo Input: $FILENAME
FILENAME=${FILENAME%.*}
mjml -o $FILENAME.html $FILENAME.mjml
cat $FILENAME.html | html-to-text > $FILENAME.txt
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment