summaryrefslogtreecommitdiff
path: root/bin/any2qmd.sh
blob: 0abe6ceb2927ee64828584bac2cb9f7206bc3147 (plain)
  1. #!/bin/sh
  2. set -eu
  3. INFILE=$1
  4. OUTFILE="${2:-$(dirname "$INFILE")/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. # TODO: maybe add --fail-if-warnings
  12. $PANDOC --to commonmark+smart+yaml_metadata_block --standalone --wrap none --output "$OUTFILE"~ "$INFILE"
  13. perl -pe 's/ --- / -- /g; s/\\(?=['"'"'"])//g; s/^- / * /g;' < "$OUTFILE"~ > "$OUTFILE"
  14. rm "$OUTFILE"~