1 if [ "$DOCBOOK_XSL" == "" ];then
2 echo Please
set DOCBOOK_XSL to the directory with the stylesheets
3 echo script now quiting
6 if [ "$FOPCONF" == "" ];then
9 if [ "$XSLFO_PDF" != "" ]; then
17 echo Converts a restructured text document to Docbook
, then to PDF \
(if appropriate\
)
18 echo "docutils_to_docbook.sh [options] <RST file>"
19 echo --format: format resulting files
20 echo --noclean: no not remove files created
21 echo --pdf: create a PDF document
22 echo --valid: validate the FO document
23 echo --strict: quit when a template does not match \
(or other error\
)
24 echo --asciiml: convert math
in the math element to mathml
25 echo --fo: convert to FO
26 echo --html: convert to HTML
27 echo "-s | --stylesheet <stylesheet> : the stylesheet to use"
28 echo "-o | --out: file to output to"
45 -) STDIN
='true'; shift; break;; # ====> standard in
46 -h) Usage
;exit 0;; # ==> Help message.
47 --help) Usage
;exit 0;;
48 --verbose) VERBOSE
='true';;
49 --format) FORMAT
='true';;
50 --test) CLEAN
='false';FORMAT
='true';VALID
='true';TEST
='true';STRICT
='true';PDF
='true';;
51 --testq) CLEAN
='false';VALID
='true';FORMAT
='true';;
52 --noclean) CLEAN
='false';;
54 --valid) VALID
='true';;
55 --strict) STRICT
='true';;
56 --asciiml) ASCIIML
='true';;
61 --stylesheet) shift;STYLESHEET
=$1;;
62 -s) shift;STYLESHEET
=$1;;
63 -*) echo "Illegal command $1"; Usage
; exit 1;; # ===> illegal help
64 *) break;; # first argument
69 if [ "$STYLESHEET" == "" ]; then
70 MAIN_XSL
=${DOCBOOK_XSL}/docutils_to_docbook.xsl
75 EXT
=`echo "$1"|awk -F . '{print $NF}'`
76 BASENAME
=`basename $1 .${EXT}`
78 if [ "$DIR" == "$1" ]; then
84 if [ ! -w "$DIRNAME" ]; then
85 echo "has write permission"
88 if [ "${OUT}" != "" ];then
91 EXT
=`echo "${OUT}"|awk -F . '{print $NF}'`
92 if [ ${OUT} == ${EXT} ]; then
95 OUT_BASE
=`basename ${OUT} .${EXT}`
99 if [ "${OUT}" != "" ]; then
100 RAW_XML
=${OUT_BASE}.xml
102 RAW_XML
=${DIRNAME}/${BASENAME}.xml
105 if [ "${OUT}" != "" ]; then
106 DOC_FILE
=${OUT_BASE}_docbook.xml
108 DOC_FILE
=${DIRNAME}/${BASENAME}_docbook.xml
111 if [ "$ASCIIML" == 'true' ]; then
112 rst2xml.py
--strip-comments --trim-footnote-reference-space --no-doctype $1\
113 | rstxml2xml.py
> $RAW_XML
115 rst2xml.py
--strip-comments --trim-footnote-reference-space --no-doctype $1 > $RAW_XML
118 if [ "$FORMAT" == "true" ]; then
119 xmlformat.pl
-i $RAW_XML
122 if [ "$STRICT" == "" ]; then
123 xsltproc
--output $DOC_FILE "$MAIN_XSL" $RAW_XML
125 xsltproc
--stringparam strict true
--output $DOC_FILE "$MAIN_XSL" $RAW_XML
129 if [ "$FORMAT" == "true" ]; then
130 xmlformat.pl
-i $DOC_FILE
133 if [ "$VALID" == 'true' ]; then
134 java
-jar $JING_DIR/bin
/jing.jar
-i ${VALIDATE_HOME}/relax
/docbook.rng
$DOC_FILE
137 FO_FILE
=${DIRNAME}/${BASENAME}.fo
139 if [ "$PDF" == 'true' ]; then
140 PDF_FILE
=${DIRNAME}/${BASENAME}.pdf
141 if [ "$FOPCONF" != '' ]; then
142 fop
-c $FOPCONF -fo $FO_FILE -pdf ${PDF_FILE}
144 fop
-fo $FO_FILE -pdf ${PDF_FILE}
148 if [ "$OUT" == "" ] && [ "$PDF" == 'false' ] && [ "$FO" == "true" ];then
152 if [ "$OUT" == "" ] && [ "$PDF" == 'false' ] && [ "$HTML" == "true" ];then
153 xsltproc http
://50.56.245.89/xsl-ns
/xhtml
/docbook.xsl
$DOC_FILE
156 if [ "$CLEAN" == "true" ]; then
158 if [ "$TEST" == 'true' ]; then