From fd5113fe1053a17105651eebd41e62b8e5e173be Mon Sep 17 00:00:00 2001 From: Gerrit Imsieke Date: Sun, 13 Jun 2021 11:18:46 +0200 Subject: [PATCH] introduce -e for evolve-hub customization, https://github.com/transpect/docx2hub/issues/25 --- d2t | 15 +++++++++++++-- xmlcatalog/catalog.xml | 2 +- xpl/docx2tex.xpl | 9 +++++++-- xsl/custom-evolve-hub-driver-example.xsl | 20 ++++++++++++++++++++ 4 files changed, 41 insertions(+), 5 deletions(-) create mode 100755 xsl/custom-evolve-hub-driver-example.xsl diff --git a/d2t b/d2t index c68eb34..0d61332 100755 --- a/d2t +++ b/d2t @@ -14,7 +14,8 @@ usage() { echo " -r omit page and cross-references and labels" echo " -t choose table model (tabularx|tabular|htmltabs)" echo " -l suppress table grid lines" - echo " -x custom XSLT stylesheet for Hub processing" + echo " -x custom XSLT stylesheet for Hub processing (after evolve-hub)" + echo " -e custom XSLT stylesheet for evolve-hub (should import xsl/evolve-hub-driver.xsl)" echo " -d debug mode" echo " -h heap (main memory) that Java is allowed to use (for ex., 4096m)" 1>&2; exit 1; @@ -56,7 +57,7 @@ REFS=yes DEBUG=no # specify options -while getopts ":o:c:m:t:x:plrdh:" opt; do +while getopts ":o:c:m:t:x:e:plrdh:" opt; do case "${opt}" in o) OUT_DIR=${OPTARG} @@ -70,6 +71,9 @@ while getopts ":o:c:m:t:x:plrdh:" opt; do x) CUSTOMXSL=${OPTARG} ;; + e) + CUSTOMDRIVER=${OPTARG} + ;; t) TABLEMODEL=${OPTARG} ;; @@ -104,6 +108,11 @@ if [ -z "$1" ]; then usage fi +# custom evolve-hub driver given (as URI, may also be relative to this directory) +if ! [ -z "$CUSTOMDRIVER" ]; then + INPUTCUSTOMDRIVER="-i custom-evolve-hub-driver=$CUSTOMDRIVER" +fi + # file as 1st argument FILE="$1" if ! [[ $FILE =~ \.docx$ ]]; then @@ -193,6 +202,7 @@ if [ "$DEBUG" = "yes" ]; then echo " refs and labels: $REFS" echo " table model: $TABLEMODEL" echo " draw table grid lines: $TABLEGRID" + echo " custom evolve-hub: $INPUTCUSTOMDRIVER" echo " custom xslt: $CUSTOMXSL" echo " Java heap: $HEAP" echo "" @@ -200,6 +210,7 @@ fi # docx2tex xproc pipeline HEAP=$HEAP $CALABASH \ + $INPUTCUSTOMDRIVER \ -o result="$OUT_DIR_PSEUDOURI/$BASENAME.tex" \ -o hub="$OUT_DIR_PSEUDOURI/$BASENAME.xml" \ "$DIR/xpl/docx2tex.xpl" \ diff --git a/xmlcatalog/catalog.xml b/xmlcatalog/catalog.xml index 3d9f930..082e493 100755 --- a/xmlcatalog/catalog.xml +++ b/xmlcatalog/catalog.xml @@ -4,7 +4,7 @@ - + diff --git a/xpl/docx2tex.xpl b/xpl/docx2tex.xpl index 3d38016..edd513b 100755 --- a/xpl/docx2tex.xpl +++ b/xpl/docx2tex.xpl @@ -21,6 +21,8 @@ Provide a custom evolve-hub driver stylesheet if you like. I would strongly advise to import the standard evolve-hub-driver in ../xsl/evolve-hub-driver.xsl as it brings many improvements for the subsequent processing. + There is a sample customization, xsl/custom-evolve-hub-driver-example.xsl, that treats + every empty paragraph as a Heading1, that is, a \chapter{} in the generated LaTeX file. @@ -296,10 +298,13 @@ * --> + + + - + - + diff --git a/xsl/custom-evolve-hub-driver-example.xsl b/xsl/custom-evolve-hub-driver-example.xsl new file mode 100755 index 0000000..ea744d5 --- /dev/null +++ b/xsl/custom-evolve-hub-driver-example.xsl @@ -0,0 +1,20 @@ + + + + + + + + + + + + + \ No newline at end of file