Skip to content

Commit

Permalink
2022 toolchain update
Browse files Browse the repository at this point in the history
Update to Docbook xslTNG toolchain.

This drops all sorts of now unneeded dependencies.

The pdf and epub are generated by the print output CSS
by "prince".  It seems to be the best option for now [1].

[1] docbook/xslTNG#121
  • Loading branch information
ianw committed Aug 5, 2022
1 parent 69d1a3b commit d7dbe75
Show file tree
Hide file tree
Showing 5,993 changed files with 69 additions and 2,033,246 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
109 changes: 37 additions & 72 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,8 @@ svgs := $(gen_svgs) $(foreach dir,$(imagedirs),$(wildcard $(dir)/*.svg))
html.output=html.output
html.css=css/csbu.css

docbook.xsl=docbook-xsl-ns-1.79.1

saxon.classpath="../saxon65/saxon.jar:../$(docbook.xsl)/extensions/saxon65.jar:../xslthl-2.1.3/xslthl-2.1.3.jar"
pdf.output=pdf.output
fop=fop-2.0/fop

epub.output=epub.output
epub.output=pdf.output

#rules to convert xfigs to png/eps
%.png : %.xfig
Expand All @@ -38,67 +33,40 @@ epub.output=epub.output
%.svg : %.xfig
fig2dev -L svg $< $@

# general overview
#
# use xmllint to build a .xml file (xmllint has xincludes support,
# saxon doesn't. xinclude seems more reliable for finding souce
# files for .txt or .c examples)
#
# use saxon to apply xsl and get final output

#pdf depends on having eps figures around.
.PHONY: pdf
pdf: $(svgs) $(pdf.output)/csbu.pdf
pdf: $(pdf.output)/csbu.pdf

$(pdf.output)/csbu.pdf : $(pdf.output)/csbu.fo
$(fop) $< $@
$(pdf.output)/csbu.pdf: $(svgs) $(pdf.output)/csbu.html $(pdf.output)/csbu.html
cd $(pdf.output); prince -o csbu.pdf csbu.html

$(pdf.output)/csbu.fo: input/csbu.xml csbu-pdf.xsl $(sources)
rm -rf ./pdf.output
mkdir -p ./pdf.output
#a bit hacky; copy all svg to be alongside .fo for fop to find
#as image references are like "chapterXX/foo.svg"
cd input ; cp -r --parents $(svgs:input/%=%) ../$(pdf.output)
xmllint --xinclude --noent ./input/csbu.xml > $(pdf.output)/csbu.xml
jing ./docbook-5.0/rng/docbookxi.rng $(pdf.output)/csbu.xml
cd $(pdf.output) ; java -classpath $(saxon.classpath) \
-Dxslthl.config="file://$(CURDIR)/$(docbook.xsl)/highlighting/xslthl-config.xml" \
com.icl.saxon.StyleSheet \
-o csbu.fo \
csbu.xml ../csbu-pdf.xsl \
use.extensions=1

epub: input/csbu.xml csbu-epub.xsl $(sources) $(pngs)
rm -rf $(epub.output)
mkdir -p $(epub.output) $(epub.output)/OEBPS
# copy once for the epub build process to read the images, it
# puts the output into $(epub.output)/OEBPS. Copy again so
# the images are in the OEBPS directory for packaging.
-cd input; \
for dir in $(sourcedirs:input/%=%); do \
cp -r --parents $$dir/figures/*.png ../$(epub.output); \
cp -r --parents $$dir/images/*.png ../$(epub.output); \
done
$(pdf.output)/csbu.html : input/csbu.xml csbu-pdf.xsl $(html.css) $(sources) $(pngs) $(svgs)
rm -rf $(pdf.output)
mkdir -p $(pdf.output)

#copy all .c files into appropriate places
-cd input; \
for dir in $(sourcedirs:input/%=%); do \
cp -r --parents $$dir/figures/*.png ../$(epub.output)/OEBPS; \
cp -r --parents $$dir/images/*.png ../$(epub.output)/OEBPS; \
done
xmllint --xinclude --noent ./input/csbu.xml > $(epub.output)/csbu.xml
jing ./docbook-5.0/rng/docbookxi.rng $(epub.output)/csbu.xml
cd $(epub.output) ; java -classpath $(saxon.classpath) \
-Dxslthl.config="file://$(CURDIR)/$(docbook.xsl)/highlighting/xslthl-config.xml" \
com.icl.saxon.StyleSheet \
csbu.xml ../csbu-epub.xsl \
base.dir=OEBPS \
use.extensions=1
cd $(epub.output); \
zip -X0 csbu.epub mimetype; \
zip -r -X9 csbu.epub META-INF OEBPS


#html depends on having png figures around.
html: input/csbu.xml csbu-html.xsl $(html.css) $(sources) $(pngs)
cp -r --parents $$dir/code/* ../$(pdf.output); \
cp -r --parents $$dir/figures/*.png ../$(pdf.output); \
cp -r --parents $$dir/images/*.png ../$(pdf.output); \
cp -r --parents $$dir/figures/*.svg ../$(pdf.output); \
cp -r --parents $$dir/images/*.svg ../$(pdf.output); \
done
xmllint --xinclude --noent ./input/csbu.xml > $(pdf.output)/csbu.xml
cd $(pdf.output); ../docbook-xslTNG-1.8.0/bin/docbook \
--resources:. \
/csbu.xml -xsl:../csbu-pdf.xsl -o:csbu.html

.PHONY: epub
epub: $(epub.output)/csbu.epub

$(epub.output)/csbu.epub: $(pdf.output)/csbu.html
cd $(epub.output); ebook-convert csbu.html csbu.epub

.PHONY: html
html: $(html.output)/index.html

$(html.output)/index.html: input/csbu.xml csbu-html.xsl $(sources) $(pngs) $(svgs)
rm -rf ./html.output
mkdir -p ./html.output

Expand All @@ -108,18 +76,15 @@ html: input/csbu.xml csbu-html.xsl $(html.css) $(sources) $(pngs)
cp -r --parents $$dir/code/* ../$(html.output); \
cp -r --parents $$dir/figures/*.png ../$(html.output); \
cp -r --parents $$dir/images/*.png ../$(html.output); \
cp -r --parents $$dir/figures/*.svg ../$(html.output); \
cp -r --parents $$dir/images/*.svg ../$(html.output); \
done
xmllint --xinclude --noent ./input/csbu.xml > $(html.output)/csbu.xml
jing ./docbook-5.0/rng/docbookxi.rng $(html.output)/csbu.xml
cd $(html.output); java -classpath $(saxon.classpath) \
-Dxslthl.config="file://$(CURDIR)/$(docbook.xsl)/highlighting/xslthl-config.xml" \
com.icl.saxon.StyleSheet \
./csbu.xml ../csbu-html.xsl \
base.dir=. \
use.extensions=1 \
tablecolumns.extension=1

cp $(html.css) draft.png $(html.output)
cd $(html.output); ../docbook-xslTNG-1.8.0/bin/docbook \
--resources:. \
./csbu.xml -xsl:../csbu-html.xsl

cp $(html.css) $(html.output)/css
cp google726839f49cefc875.html $(html.output)

.PHONY: clean
Expand Down
24 changes: 5 additions & 19 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,16 @@ or

make pdf (output in csbu.pdf)

Included for simplicity are the docbook dtds, xsl stylesheets and fop
distribution. You need some other things for this to work out of the
box. If you have the Debian packages
Dependencies are roughly

* java (1.8 ... 1.7 seems to have some issues with saxon; see
https://sourceforge.net/p/docbook/bugs/1373/ )
* java
* libxml2-utils
* jing
* transfig (for fig2dev)

you will probably be ok.
* pdf : prince - https://www.princexml.com/
* epub : calibre

I am always interested in contribution and feedback so please feel
free to email

Ian Wienand
[email protected]

---

Notes

2016-01-13 : fop-2.0/lib/batik-all-svn-trunk.jar from [1] is included
to work around [2]

[1] https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk/lib/batik-all-svn-trunk.jar
[2] https://issues.apache.org/jira/browse/FOP-2489
[email protected]
13 changes: 0 additions & 13 deletions csbu-epub.xsl

This file was deleted.

46 changes: 17 additions & 29 deletions csbu-html.xsl
Original file line number Diff line number Diff line change
@@ -1,40 +1,28 @@
<?xml version='1.0'?>
<?xml version="1.0" encoding="utf-8"?>

<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:d="http://docbook.org/ns/docbook"
version="1.0">
xmlns:db="http://docbook.org/ns/docbook"
xmlns:m="http://docbook.org/ns/docbook/modes"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.w3.org/1999/xhtml"
exclude-result-prefixes="db xs"
version="3.0">

<xsl:import href="docbook-xsl-ns-1.79.1/xhtml5/chunk.xsl"/>
<xsl:import href="docbook-xsl-ns-1.79.1/xhtml/highlight.xsl"/>
<!-- This href has to point to your local copy
of the stylesheets. -->

<xsl:param name="highlight.source" select="1" />
<xsl:param name="chunker.output.encoding" select="'UTF-8'"/>
<xsl:param name="make.clean.html" select="1"></xsl:param>
<xsl:param name="use.id.as.filename" select="1"></xsl:param>
<xsl:param name="chunk.first.selection" select="1"></xsl:param>
<!--<xsl:param name="html.ext">.html</xsl:param>-->
<xsl:param name="docbook.css.link" select="0"></xsl:param>
<xsl:param name="docbook.css.source"></xsl:param>
<xsl:param name="suppress.navigation" select="0"></xsl:param>
<xsl:param name="html.stylesheet">csbu.css</xsl:param>
<xsl:import href="docbook-xslTNG-1.8.0/xslt/docbook.xsl"/>

<xsl:template name="user.footer.navigation">
<script type="text/javascript">
<xsl:param name="chunk" select="'index.html'" />
<xsl:param name="chunk-output-base-uri" select="'.'" />
<xsl:param name="verbatim-syntax-highlighter" select="'highlight.js'" />
<xsl:param name="persistent-toc" select="'true'" />

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-25195980-1']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

</script>
<xsl:template match="*" mode="m:html-head-links">
<xsl:next-match/>

<link rel="stylesheet" href="css/csbu.css"/>
</xsl:template>


</xsl:stylesheet>
32 changes: 10 additions & 22 deletions csbu-pdf.xsl
Original file line number Diff line number Diff line change
@@ -1,28 +1,16 @@
<?xml version='1.0'?>
<?xml version="1.0" encoding="utf-8"?>

<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:d="http://docbook.org/ns/docbook"
version="1.0">

<xsl:import href="docbook-xsl-ns-1.79.1/fo/docbook.xsl"/>
<xsl:import href="docbook-xsl-ns-1.79.1/fo/highlight.xsl"/>

<xsl:param name="highlight.source" select="1" />

<xsl:param name="body.font.family">Helvetica</xsl:param>
<xsl:param name="body.font.size">11pt</xsl:param>
xmlns:db="http://docbook.org/ns/docbook"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.w3.org/1999/xhtml"
exclude-result-prefixes="db xs"
version="3.0">

<xsl:attribute-set name="monospace.verbatim.properties">
<xsl:attribute name="font-size">0.7em</xsl:attribute>
</xsl:attribute-set>
<!-- This href has to point to your local copy
of the stylesheets. -->

<xsl:param name="shade.verbatim" select="1" />
<xsl:attribute-set name="shade.verbatim.style">
<xsl:attribute name="background-color">#F8F8F8</xsl:attribute>
<xsl:attribute name="border-width">0.5pt</xsl:attribute>
<xsl:attribute name="border-style">solid</xsl:attribute>
<xsl:attribute name="border-color">#575757</xsl:attribute>
<xsl:attribute name="padding">2pt</xsl:attribute>
</xsl:attribute-set>
<xsl:import href="docbook-xslTNG-1.8.0/xslt/print.xsl"/>

</xsl:stylesheet>
Loading

0 comments on commit d7dbe75

Please sign in to comment.