You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
1.7KB

  1. #!/bin/bash
  2. #
  3. # This script converts markdown into html, to be used with vimwiki's
  4. # "customwiki2html" option. Experiment with the two proposed methods by
  5. # commenting / uncommenting the relevant lines below.
  6. #
  7. # NEW! An alternative converter was developed by Jason6Anderson, and can
  8. # be located at https://github.com/vimwiki-backup/vimwiki/issues/384
  9. #
  10. #
  11. # To use this script, you must have the Discount converter installed.
  12. #
  13. # http://www.pell.portland.or.us/~orc/Code/discount/
  14. #
  15. # To verify your installation, check that the commands markdown and mkd2text,
  16. # are on your path.
  17. #
  18. # Also verify that this file is executable.
  19. #
  20. # Then, in your .vimrc file, set:
  21. #
  22. # g:vimwiki_customwiki2html=$HOME.'/.vim/autoload/vimwiki/customwiki2html.sh'
  23. #
  24. # On your next restart, Vimwiki will run this script instead of using the
  25. # internal wiki2html converter.
  26. #
  27. MARKDOWN=markdown
  28. MKD2HTML=mkd2html
  29. FORCE="$1"
  30. SYNTAX="$2"
  31. EXTENSION="$3"
  32. OUTPUTDIR="$4"
  33. INPUT="$5"
  34. CSSFILE="$6"
  35. TPLPATH="$7"
  36. TPLDEF="$8"
  37. TPLEXT="$9"
  38. FORCEFLAG=
  39. [ $FORCE -eq 0 ] || { FORCEFLAG="-f"; };
  40. [ $SYNTAX = "markdown" ] || { echo "Error: Unsupported syntax"; exit -2; };
  41. OUTPUT="$OUTPUTDIR"/$(basename "$INPUT" .$EXTENSION).html
  42. TPL="$TPLPATH$TPLDEF$TPLEXT"
  43. # Method 1:
  44. # markdown [-d] [-T] [-V] [-b url-base] [-C prefix] [-F bitmap] [-f flags] [-o file] [-s text] [-t text] [textfile]
  45. OUT=`cat "$INPUT" | perl -pe 's/(\[.*?\]\(.*?)\)/\1.html)/g' | $MARKDOWN`
  46. cat $TPL | perl -pe "s|%content%|$OUT|" > "$OUTPUT"
  47. # Method 2:
  48. # mkd2html [-css file] [-header string] [-footer string] [file]
  49. # $MKD2HTML -css "$CSSFILE" "$INPUT"
  50. # OUTPUTTMP=$(dirname "$INPUT")/$(basename "$INPUT" ."$EXTENSION").html
  51. # mv -f "$OUTPUTTMP" "$OUTPUT"