From: Lady <redacted>
Date: Sat, 22 Jun 2024 15:59:53 +0000 (-0400)
Subject: Allow overriding of finalization program
X-Git-Tag: 0.9.4^0
X-Git-Url: https://git.ladys.computer/Shushe/commitdiff_plain/b38943b97abaeb6f595b4f561b1dd30a6ba89f8e?ds=inline

Allow overriding of finalization program
---

diff --git a/GNUmakefile b/GNUmakefile
index 5c52e70..0a76e49 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -200,6 +200,9 @@ TRANSFORMS := $(sort $(patsubst ./%,%,$(wildcard $(THISDIR)/transforms/*.xslt))
 # ends accordingly.
 XMLTYPES := application/xml text/xml +xml
 
+# A program to run on basic X·M·L files after they are transformed.
+FINALIZE := $(XMLLINT) --nonet --nsclean
+
 ifdef GIT
 ifneq ($(wildcard $(THISDIR)/.git),)
 # A description of the current git revision of ⛩️📰 书社.
@@ -297,7 +300,7 @@ override xpath = $(XMLLINT) --noent --nonet --xpath $(call quote,$1) $(call quot
 override extracttext = $(PRINTF) '%s' '<transform xmlns="http://www.w3.org/1999/XSL/Transform" version="1.0"><output method="text" encoding="UTF-8"/></transform>' | $(XSLTPROC) --nonet --novalid - $(call quote,$1)
 
 # (callable) Process the provided transformation result and output the result to the provided location, given the provided relative path.
-override processresultto = if $(call xpath,/*[local-name()="raw-text" and namespace-uri()="urn:fdc:ladys.computer:20231231:Shu1She4"],$1); then $(call extracttext,$1) >|$(call quote,$2); elif $(call xpath,/*[local-name()="base64-binary" and namespace-uri()="urn:fdc:ladys.computer:20231231:Shu1She4"],$1); then { $(PRINTF) '%s\n' 'begin-base64 644 -'; $(call extracttext,$1) | $(TR) -d '\t\n\f\r '; $(PRINTF) '\n%s\n' '===='; } | $(UUDECODE) -o /dev/stdout >|$(call quote,$2); elif $(call xpath,/*[local-name()="archive" and namespace-uri()="urn:fdc:ladys.computer:20231231:Shu1She4"],$1); then $(MAKE) -f $(call quote,$(abspath $(THISDIR)/GNUmakefile)) NAME=$(call quote,$3) SRC=$(call quote,$1) BUILDDIR=$(call quote,$(BUILDDIR)/archive/$3) DESTDIR=$(call quote,$(patsubst %/,%,$(dir $2))) MODE='urn:fdc:ladys.computer:20231231:Shu1She4:mode:archive' $(call quote,$2); else $(XMLLINT) --nsclean $(call quote,$1) >|$(call quote,$2); fi
+override processresultto = if $(call xpath,/*[local-name()="raw-text" and namespace-uri()="urn:fdc:ladys.computer:20231231:Shu1She4"],$1); then $(call extracttext,$1) >|$(call quote,$2); elif $(call xpath,/*[local-name()="base64-binary" and namespace-uri()="urn:fdc:ladys.computer:20231231:Shu1She4"],$1); then { $(PRINTF) '%s\n' 'begin-base64 644 -'; $(call extracttext,$1) | $(TR) -d '\t\n\f\r '; $(PRINTF) '\n%s\n' '===='; } | $(UUDECODE) -o /dev/stdout >|$(call quote,$2); elif $(call xpath,/*[local-name()="archive" and namespace-uri()="urn:fdc:ladys.computer:20231231:Shu1She4"],$1); then $(MAKE) -f $(call quote,$(abspath $(THISDIR)/GNUmakefile)) NAME=$(call quote,$3) SRC=$(call quote,$1) BUILDDIR=$(call quote,$(BUILDDIR)/archive/$3) DESTDIR=$(call quote,$(patsubst %/,%,$(dir $2))) MODE='urn:fdc:ladys.computer:20231231:Shu1She4:mode:archive' $(call quote,$2); else $(FINALIZE) $(call quote,$1) >|$(call quote,$2); fi
 
 # ━ § BEGIN DEFAULT MAKE·FILE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
diff --git a/README.markdown b/README.markdown
index 2cefb62..6b865ae 100644
--- a/README.markdown
+++ b/README.markdown
@@ -317,6 +317,11 @@ The following additional variables can be used to control the behaviour
   A white·space‐separated list of media types or media type suffixes to
     consider X·M·L (default: `application/xml text/xml +xml`).
 
+- **`FINALIZE`:**
+  A program to run on (unspecial) X·M·L files after they are
+    transformed (default: `xmllint --nonet --nsclean`).
+  This variable can be used for postprocessing.
+
 - **`THISREV`:**
   The current version of ⛩️📰 书社 (default: derived from the current
     git tag/branch/commit).