Shell snippets


Markdown to HTML partials

I use this to convert Markdown files from my Obsidian vault to HTML partials for use on HD-DN.

# Convert $1 to HD-DN-ready HTML partial saved at $2
pandoc "$1" -s -f markdown+yaml_metadata_block+auto_identifiers-smart -o "$2"
tidy -imq "$2" # Pandoc end-lines are weird and break stuff, run tidy on it
sed -ni "/<body>/,/<\/body>/p" "$2" # Only grab <body>stuff</body>
sed -i "1d;\$d" "$2" # Remove start and end line