commands.bash 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #!/usr/bin/env bash
  2. ## References:
  3. ## http://asciidoctor.org/docs/asciidoc-writers-guide/
  4. SLUG="byte_of_python"
  5. FOPUB="$HOME/code/asciidoctor/asciidoctor-fopub/fopub"
  6. function doctor() {
  7. backend=$1
  8. shift
  9. asciidoctor -n -a 'source-highlighter=pygments' -b $backend ${SLUG}.asciidoc
  10. }
  11. function make_html () {
  12. doctor html5
  13. ls -lh "$PWD/$SLUG.html"
  14. }
  15. function make_pdf () {
  16. doctor docbook
  17. $FOPUB ${SLUG}.xml
  18. # OR
  19. # a2x -f pdf --fop ${SLUG}.asciidoc
  20. ls -lh "$PWD/$SLUG.pdf"
  21. }
  22. # TODO Syntax highlighting in output
  23. # - http://docbook.sourceforge.net/release/xsl/current/doc/fo/highlight.source.html
  24. # - ~/code/asciidoctor/asciidoctor-fopub/src/dist/docbook-xsl/xslthl-config.xml
  25. # - http://www.vogella.com/tutorials/DocBook/article.html#advanced_syntaxhighlighting
  26. function make_epub () {
  27. doctor docbook
  28. dbtoepub ${SLUG}.xml
  29. # OR
  30. # a2x -f epub ${SLUG}.xml
  31. epubcheck "$PWD/$SLUG.epub"
  32. ls -lh "$PWD/$SLUG.epub"
  33. }
  34. function make_mobi () {
  35. doctor html5
  36. kindlegen -verbose ${SLUG}.html -o ${SLUG}.mobi
  37. ls -lh "$PWD/$SLUG.mobi"
  38. }
  39. # TODO https://github.com/schacon/git-scribe/blob/master/lib/git-scribe/generate.rb#L107
  40. # TODO Instead, create an official backend for asciidoctor to create a website?
  41. #
  42. function make_website () {
  43. echo "TODO"
  44. }
  45. function install_deps_osx () {
  46. # http://brew.sh
  47. brew update
  48. brew install docbook docbook-xsl fop epubcheck git
  49. brew tap homebrew/binary
  50. brew install kindlegen
  51. # brew install asciidoc
  52. # http://asciidoctor.org/docs/install-asciidoctor-macosx/
  53. sudo gem update --system
  54. sudo gem install asciidoctor -N
  55. # https://groups.google.com/forum/#!topic/asciidoc/FC-eOwU8rYg
  56. echo >> ~/.bash_profile
  57. echo 'export XML_CATALOG_FILES="/usr/local/etc/xml/catalog"' >> ~/.bash_profile
  58. # https://github.com/asciidoctor/asciidoctor-fopub/blob/master/README.adoc
  59. mkdir -p $HOME/code/asciidoctor/
  60. cd $HOME/code/asciidoctor/
  61. git clone https://github.com/asciidoctor/asciidoctor-fopub
  62. # If emacs, install package: https://github.com/sensorflo/adoc-mode/wiki
  63. }