1
0
mirror of https://github.com/moparisthebest/xeps synced 2024-11-23 01:32:22 -05:00

Add PDF generation back to Makefile

This commit is contained in:
Sam Whited 2017-01-03 15:22:30 -06:00
parent 8de3ee3a29
commit 30bb05ba94
2 changed files with 28 additions and 1 deletions

2
.gitignore vendored
View File

@ -69,3 +69,5 @@ target/
Session.vim Session.vim
.netrwhist .netrwhist
*~ *~
*.pdf

View File

@ -4,7 +4,7 @@ OUTDIR?=build
RESOURCESDIR=$(OUTDIR)/resources RESOURCESDIR=$(OUTDIR)/resources
TEMPDIR?=$(OUTDIR)/xepbuild TEMPDIR?=$(OUTDIR)/xepbuild
XMLDEPS=xep.xsl xep.xsd xep.ent xep.dtd ref.xsl $(OUTDIR) XMLDEPS=xep.xsl xep.xsd xep.ent xep.dtd ref.xsl $(OUTDIR)
TEXMLDEPS=xep2texml.xsl $(TEMPDIR) $(XMLDEPS) $(RESOURCESDIR)/xmpp.pdf $(RESOURCESDIR)/xmpp-text.pdf TEXMLDEPS=xep2texml.xsl $(OUTDIR)/xmpp.pdf $(OUTDIR)/xmpp-text.pdf
XMPPIMAGESURL=https://xmpp.org/images XMPPIMAGESURL=https://xmpp.org/images
XEPDIRS=. inbox XEPDIRS=. inbox
@ -19,6 +19,7 @@ help:
@echo ' clean - recursively unlink the build tree' @echo ' clean - recursively unlink the build tree'
@echo ' preview - builds html whenever an XEP changes (requires inotify-tools)' @echo ' preview - builds html whenever an XEP changes (requires inotify-tools)'
@echo ' xep-xxxx - build xep-xxxx.html' @echo ' xep-xxxx - build xep-xxxx.html'
@echo ' xep-xxxx.pdf - build xep-xxxx.pdf (requires xelatex and texml)'
@echo ' xep-xxxx.html - build xep-xxxx.html' @echo ' xep-xxxx.html - build xep-xxxx.html'
@echo ' ' @echo ' '
@echo 'Output directory: "$(OUTDIR)/"' @echo 'Output directory: "$(OUTDIR)/"'
@ -29,12 +30,18 @@ all: html
.PHONY: html .PHONY: html
html: $(patsubst %.xml, $(OUTDIR)/%.html, $(wildcard *.xml)) html: $(patsubst %.xml, $(OUTDIR)/%.html, $(wildcard *.xml))
.PHONY: pdf
pdf: $(patsubst %.xml, $(OUTDIR)/%.pdf, $(wildcard *.xml))
.PHONY: xep-% .PHONY: xep-%
xep-%: $(OUTDIR)/xep-%.html ; xep-%: $(OUTDIR)/xep-%.html ;
.PHONY: xep-%.html .PHONY: xep-%.html
xep-%.html: $(OUTDIR)/xep-%.html ; xep-%.html: $(OUTDIR)/xep-%.html ;
.PHONY: xep-%.pdf
xep-%.pdf: $(OUTDIR)/xep-%.pdf ;
.PHONY: dependencies .PHONY: dependencies
dependencies: $(OUTDIR)/prettify.css $(OUTDIR)/prettify.js $(OUTDIR)/xmpp.css ; dependencies: $(OUTDIR)/prettify.css $(OUTDIR)/prettify.js $(OUTDIR)/xmpp.css ;
@ -44,9 +51,27 @@ $(OUTDIR)/%.html: %.xml $(XMLDEPS) dependencies
xmllint --nonet --noout --noent --loaddtd --valid "$<" || true xmllint --nonet --noout --noent --loaddtd --valid "$<" || true
# Check for non-data URIs # Check for non-data URIs
! xmllint --nonet --noout --noent --loaddtd --xpath "//img/@src[not(starts-with(., 'data:'))]" $< 2>/dev/null && true ! xmllint --nonet --noout --noent --loaddtd --xpath "//img/@src[not(starts-with(., 'data:'))]" $< 2>/dev/null && true
# Actually build the HTML # Actually build the HTML
xsltproc --path $(CURDIR) xep.xsl "$<" > "$@" && echo "Finished building $@" xsltproc --path $(CURDIR) xep.xsl "$<" > "$@" && echo "Finished building $@"
$(OUTDIR)/xmpp.pdf $(OUTDIR)/xmpp-text.pdf:
cp "resources/$(notdir $@)" "$@"
$(OUTDIR)/%.pdf: %.xml $(TEXMLDEPS) $(XMLDEPS) dependencies
# TODO: After existing issues are worked out this and the ratcheting CI build
# should be removed and become an error, not just a warning.
xmllint --nonet --noout --noent --loaddtd --valid "$<" || true
# Check for non-data URIs
! xmllint --nonet --noout --noent --loaddtd --xpath "//img/@src[not(starts-with(., 'data:'))]" $< 2>/dev/null && true
xsltproc --path $(CURDIR) xep2texml.xsl "$<" > "$(@:.pdf=.tex.xml)"
texml -e utf8 "$(@:.pdf=.tex.xml)" "$(@:.pdf=.tex)"
sed -i -e 's|\([\s"]\)\([^"]http://[^ "]*\)|\1\\path{\2}|g' \
-e 's|\\hyperref\[#\([^}]*\)\]|\\hyperref\[\1\]|g' \
-e 's|\\pageref{#\([^}]*\)}|\\pageref{\1}|g' "$(@:.pdf=.tex)"
cd $(OUTDIR); xelatex -interaction=batchmode -no-shell-escape "$(notdir $(basename $@)).tex" && echo "Finished building $@"
$(OUTDIR)/%.js: %.js $(OUTDIR)/%.js: %.js
cp "$<" "$@" cp "$<" "$@"