summaryrefslogtreecommitdiff
path: root/bin/any2qmd.sh
blob: 021b5114775bc8a8a9eab08424a27262fc12c170 (plain)
  1. #!/bin/sh
  2. set -eu
  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. # 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"~