summaryrefslogtreecommitdiff
path: root/bin/any2qmd.sh
blob: cbacf7b8d85ce12ba7c004222bc611867739a6d4 (plain)
  1. #!/bin/sh
  2. set -au
  3. INFILE=$1
  4. OUTFILE="$(dirname "$INFILE")/${2:-index.qmd}"
  5. if command -v quarto > /dev/null 2>&1; then
  6. PANDOC="quarto pandoc"
  7. else
  8. PANDOC=pandoc
  9. fi
  10. # use intermediary file (cannot use pipe with quarto wrapper)
  11. $PANDOC --to commonmark+smart --wrap none --output "$OUTFILE"~ "$INFILE"
  12. perl -pe 's/ --- / -- /g; s/\\(?=['"'"'"])//g; s/^- / * /g;' < "$OUTFILE"~ > "$OUTFILE"
  13. rm "$OUTFILE"~