1#!/usr/bin/env bash 2 3# layout1 - Tables based layout. 4# layout2 - CSS based layout 5LAYOUT=layout2 6 7ASCIIDOCVERSION=$(sed -n '1p' configure.ac | grep -o -e "[0-9]*\.[0-9]*\.[a-z0-9]*") 8# trying to embed this string with spaces into the command below causes 9# sys.argv to get funny, and I cannot figure out why 10ASCIIDOCDATE=$(sed -n '3p' configure.ac | grep -o -e "[0-9]* [A-Z][a-z]* [0-9]*") 11 12# execute this as a function so that we do not run afoul of bash's string interpolation / splitting 13# when trying to execute commands from variables 14asciidoc() { 15 python3 ../asciidoc.py -a revnumber="${ASCIIDOCVERSION}" -a revdate="${ASCIIDOCDATE}" "$@" 16} 17 18A2X="python3 ../a2x.py" 19 20# Step 0: Initialize the gh-pages folder 21if [ ! -d gh-pages ]; then 22 git clone https://github.com/asciidoc/asciidoc-py3 gh-pages 23 pushd gh-pages 24 git checkout gh-pages 25 popd 26fi 27pushd gh-pages 28find . -maxdepth 1 -type f -not \( -name '*.md' -o -name '*.md5' -o -name '*.epub' -o -name 'CNAME' -o -name '.nojekyll' \) -exec rm -rf {} \; 29rm -rf chunked 30rm -rf images 31popd 32 33 34# Step 1: Conslidate all files into the gh-pages directory 35files=( 36 docbook-xsl/asciidoc-docbook-xsl.txt 37 filters/graphviz/asciidoc-graphviz-sample.txt 38 stylesheets/asciidoc.css 39 javascripts/asciidoc.js 40 javascripts/ASCIIMathML.js 41 CHANGELOG.txt 42 INSTALL.txt 43 javascripts/LaTeXMathML.js 44 stylesheets/xhtml11-quirks.css 45) 46 47for file in ${files[@]}; do 48 name=$(basename ${file}) 49 set -x 50 cp ${file} gh-pages/${name} 51 set +x 52done 53 54set -x 55cp README.asciidoc gh-pages/README.txt 56cp website/* gh-pages 57cp doc/*.txt gh-pages 58cp -R images gh-pages 59 60cp doc/asciidoc.1.txt gh-pages/manpage.txt 61cp doc/asciidoc.txt gh-pages/userguide.txt 62set +x 63 64pushd gh-pages 65 66# Step 2: Build the files 67ASCIIDOC="asciidoc -b xhtml11 -f ${LAYOUT}.conf -a icons -a badges -a max-width=70em -a source-highlighter=highlight" 68for file in *.txt; do 69 name=${file:0:-4} 70 opts="" 71 if [ "${name}" = "userguide" ] || [ "${name}" = "faq" ]; then 72 opts="-a toc -a numbered" 73 elif [ "${name}" = "index" ]; then 74 opts="-a index-only" 75 elif [ "${name}" = "manpage" ] || [ "${name}" = "a2x.1" ] || [ "${name}" = "asciidoc.1" ]; then 76 opts="-d manpage" 77 elif [ "${name}" = "asciimathml" ]; then 78 opts="-a asciimath" 79 elif [ "${name}" = "latexmath" ]; then 80 opts="-a latexmath" 81 fi 82 if [ "${name}" = "index" ] || [ "${name}" = "INSTALL" ] || [ "${name}" = "asciidocapi" ] || [ "${name}" = "testasciidoc" ] || [ "${name}" = "publishing-ebooks-with-asciidoc" ]; then 83 opts+=" -a toc -a toclevels=1" 84 fi 85 set -x 86 ${ASCIIDOC} ${opts} ${file} 87 set +x 88done 89 90# Step 3: build out remaining specific files from doc 91ASCIIDOC="asciidoc" 92# TODO: investigate epub generation (--epubcheck fails) 93set -x 94${ASCIIDOC} -a data-uri -a icons -a toc -a max-width=55em -o article-standalone.html article.txt 95${ASCIIDOC} -b html5 -a icons -a toc2 -a theme=flask -o article-html5-toc2.html article.txt 96 97${ASCIIDOC} -d manpage -b html4 asciidoc.1.txt 98${ASCIIDOC} -b xhtml11 -d manpage -o asciidoc.1.css-embedded.html asciidoc.1.txt 99${ASCIIDOC} -d manpage -b docbook asciidoc.1.txt 100xsltproc --nonet ../docbook-xsl/manpage.xsl asciidoc.1.xml 101rm asciidoc.1.xml 102 103${ASCIIDOC} -b xhtml11 -n -a toc -a toclevels=2 -o asciidoc.css-embedded.html asciidoc.txt 104# ${A2X} -f epub -d book --epubcheck --icons asciidoc.txt 105${A2X} -f chunked -dbook --icons -D ./ asciidoc.txt 106mv asciidoc.chunked chunked 107 108# ${A2X} -f epub -d book --epubcheck --icons book.txt 109 110${ASCIIDOC} -n -b docbook article.txt 111xsltproc --nonet --stringparam admon.textlabel 0 ../docbook-xsl/fo.xsl article.xml > article.fo 112fop article.fo article.pdf 113set +x 114rm article.xml 115rm article.fo 116 117set -x 118${ASCIIDOC} -b docbook asciidoc.txt 119dblatex -p ../dblatex/asciidoc-dblatex.xsl -s ../dblatex/asciidoc-dblatex.sty -o asciidoc.pdf asciidoc.xml 120set +x 121rm asciidoc.xml 122 123popd 124