Browse Source

Add PDF generation back to Makefile

Sam Whited 2 years ago
parent
commit
30bb05ba94
2 changed files with 28 additions and 1 deletions
  1. 2
    0
      .gitignore
  2. 26
    1
      Makefile

+ 2
- 0
.gitignore View File

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

+ 26
- 1
Makefile View File

@@ -4,7 +4,7 @@ OUTDIR?=build
4 4
 RESOURCESDIR=$(OUTDIR)/resources
5 5
 TEMPDIR?=$(OUTDIR)/xepbuild
6 6
 XMLDEPS=xep.xsl xep.xsd xep.ent xep.dtd ref.xsl $(OUTDIR)
7
-TEXMLDEPS=xep2texml.xsl $(TEMPDIR) $(XMLDEPS) $(RESOURCESDIR)/xmpp.pdf $(RESOURCESDIR)/xmpp-text.pdf
7
+TEXMLDEPS=xep2texml.xsl $(OUTDIR)/xmpp.pdf $(OUTDIR)/xmpp-text.pdf
8 8
 XMPPIMAGESURL=https://xmpp.org/images
9 9
 XEPDIRS=. inbox
10 10
 
@@ -19,6 +19,7 @@ help:
19 19
 	@echo '                 clean  -  recursively unlink the build tree'
20 20
 	@echo '               preview  -  builds html whenever an XEP changes (requires inotify-tools)'
21 21
 	@echo '              xep-xxxx  -  build xep-xxxx.html'
22
+	@echo '          xep-xxxx.pdf  -  build xep-xxxx.pdf (requires xelatex and texml)'
22 23
 	@echo '         xep-xxxx.html  -  build xep-xxxx.html'
23 24
 	@echo ' '
24 25
 	@echo 'Output directory: "$(OUTDIR)/"'
@@ -29,12 +30,18 @@ all: html
29 30
 .PHONY: html
30 31
 html: $(patsubst %.xml, $(OUTDIR)/%.html, $(wildcard *.xml))
31 32
 
33
+.PHONY: pdf
34
+pdf: $(patsubst %.xml, $(OUTDIR)/%.pdf, $(wildcard *.xml))
35
+
32 36
 .PHONY: xep-%
33 37
 xep-%: $(OUTDIR)/xep-%.html ;
34 38
 
35 39
 .PHONY: xep-%.html
36 40
 xep-%.html: $(OUTDIR)/xep-%.html ;
37 41
 
42
+.PHONY: xep-%.pdf
43
+xep-%.pdf: $(OUTDIR)/xep-%.pdf ;
44
+
38 45
 .PHONY: dependencies
39 46
 dependencies: $(OUTDIR)/prettify.css $(OUTDIR)/prettify.js $(OUTDIR)/xmpp.css ;
40 47
 
@@ -44,9 +51,27 @@ $(OUTDIR)/%.html: %.xml $(XMLDEPS) dependencies
44 51
 	xmllint --nonet --noout --noent --loaddtd --valid "$<" || true
45 52
 	# Check for non-data URIs
46 53
 	! xmllint --nonet --noout --noent --loaddtd --xpath "//img/@src[not(starts-with(., 'data:'))]" $< 2>/dev/null && true
54
+
47 55
 	# Actually build the HTML
48 56
 	xsltproc --path $(CURDIR) xep.xsl "$<" > "$@" && echo "Finished building $@"
49 57
 
58
+$(OUTDIR)/xmpp.pdf $(OUTDIR)/xmpp-text.pdf:
59
+	cp "resources/$(notdir $@)" "$@"
60
+
61
+$(OUTDIR)/%.pdf: %.xml $(TEXMLDEPS) $(XMLDEPS) dependencies
62
+	# TODO: After existing issues are worked out this and the ratcheting CI build
63
+	#       should be removed and become an error, not just a warning.
64
+	xmllint --nonet --noout --noent --loaddtd --valid "$<" || true
65
+	# Check for non-data URIs
66
+	! xmllint --nonet --noout --noent --loaddtd --xpath "//img/@src[not(starts-with(., 'data:'))]" $< 2>/dev/null && true
67
+
68
+	xsltproc --path $(CURDIR) xep2texml.xsl "$<" > "$(@:.pdf=.tex.xml)"
69
+	texml -e utf8 "$(@:.pdf=.tex.xml)" "$(@:.pdf=.tex)"
70
+	sed -i -e 's|\([\s"]\)\([^"]http://[^ "]*\)|\1\\path{\2}|g' \
71
+		-e 's|\\hyperref\[#\([^}]*\)\]|\\hyperref\[\1\]|g' \
72
+		-e 's|\\pageref{#\([^}]*\)}|\\pageref{\1}|g' "$(@:.pdf=.tex)"
73
+	cd $(OUTDIR); xelatex -interaction=batchmode -no-shell-escape "$(notdir $(basename $@)).tex" && echo "Finished building $@"
74
+
50 75
 $(OUTDIR)/%.js: %.js
51 76
 	cp "$<" "$@"
52 77
 

Loading…
Cancel
Save