haiku/3rdparty/mmu_man/scripts/hugo_to_pandoc.sh
François Revol 6f80a9801f Some script for a crude convertion from Hugo to Pandoc
I wrote this to make a print copy of my lenovo blog post.

Change-Id: Id39bfda3d95532a4049b58d9008b695f340513ed
2022-05-29 23:29:46 +02:00

14 lines
572 B
Bash
Executable File

#!/bin/sh
# This script tries to convert a hugo markdown source into a markdown that pandoc can read, to convert to ODT for example.
# First filter turns inline links into footnotes with italic link text and monospace URL.
# Second filter turns img tags into regular markdown images
# Third filter converts enough of the Hugo header into pandoc's own header format.
sed -r 's/\[([^\[]*)\]\(([^()]*)\)/*\1*^[`\2`]/g' | \
sed -r 's,<img src=\"([^"]*)\".*title=\"([^"]*)\".*>,![\2](static\1),g' | \
sed -r '/^\+\+\+$/{c\
---
};/^tags = \[.*$/d;1,5s/(.*) = "(.*)"/\1: \2/'