adoc-to-ciro 821 B

1234567891011121314151617181920
  1. #!/usr/bin/env bash
  2. # Quick regexp hacks to do easy heuristic conversions from Asciidoctor to Ourbigbook.
  3. set -eu
  4. in="$1"
  5. out="${in%.*}.bigb"
  6. cp "$in" "$out"
  7. perl -pi -e 's/<<([^>]*)>>/\\x[\1]/g' "$out"
  8. perl -pi -e 's/xref2?:([^[]*)\[\]/\\x[\1]/g' "$out"
  9. perl -pi -e 's/xref2?:([^[]*)\[xrefstyle=full\]/\\x[\1]{full}/g' "$out"
  10. perl -pi -e 's/video2?::([^[]*)\[\]/\\Video[\1]/g' "$out"
  11. perl -pi -e 's/image2?::([^[]*)\[\]/\\Image[\1]/g' "$out"
  12. perl -pi -e 's/\(https?:\/\/web.archive.org\/([^[]*)\[archive\]\)/(\\a[https:\/\/web.archive.org\/\1][archive])/g' "$out"
  13. perl -pi -e 's/^----$/``/' "$out"
  14. perl -pi -e 's/^\.\.\.\.$/``/' "$out"
  15. perl -pi -e 's/^\*\* / * /' "$out"
  16. perl -pi -e 's/^\*\*\* / * /' "$out"
  17. perl -pi -e 's/^\*\*\*\* / * /' "$out"
  18. perl -pi -e 's/toc::\[\]/\\Toc/' "$out"
  19. # TODO italic and bold.