Created
August 24, 2023 20:09
-
-
Save jaypsan/ba2978a9a235ce8e8cd0c9a1ded326f9 to your computer and use it in GitHub Desktop.
bash script for md-to-pdf Node JS CLI tool. Iterate through all folders within the script directory and, for each, concatenate all .md files and convert to PDF to ./_dist
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for d in ./*/; do | |
# Trim last "/" from "$d | |
folderName=${d%*/} | |
# remove text until last "/" | |
folderName=${folderName##*/} | |
# checks if folder name starts with underline (_) | |
# yes: stop loop here | |
# no: continue | |
if [[ $folderName == _* ]]; then continue; fi | |
# Create _dist directory if it does not exist | |
mkdir -p ./_dist | |
# Run md-to-pdf CLI commant to convert all files within the folder | |
# to a single pdf file with the same name in the ./_dist directory. | |
cat $d/*.md | md-to-pdf > ./_dist/$folderName.pdf --config-file ./pdf_options.js | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment