summaryrefslogtreecommitdiff
path: root/bin/any2qmd.sh
blob: f7759f54b109f5985b2b148653a92d76b17285b9 (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+yaml_metadata_block --standalone --wrap none --output "$OUTFILE"~ "$INFILE"
  12. perl -pe 's/ --- / -- /g; s/\\(?=['"'"'"])//g; s/^- / * /g;' < "$OUTFILE"~ > "$OUTFILE"
  13. rm "$OUTFILE"~