From: Lady Date: Tue, 21 May 2024 03:19:48 +0000 (-0400) Subject: Support +xml suffix for determining X·M·L files X-Git-Tag: 0.9.0~1 X-Git-Url: https://git.ladys.computer/Shushe/commitdiff_plain/cb45fc856ed6f9e7eaf6db12a93372026decd080 Support +xml suffix for determining X·M·L files This gets around operating system extensions to `file` which might identify S·V·G files (for example) as `image/svg+xml` before attempting magic detection. If not every X·M·L‐based syntax should be handled as such by ⛩️📰 书社, redefine `XMLTYPES` to exclude the `+xml`. --- diff --git a/GNUmakefile b/GNUmakefile index 338c55d..7765095 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -193,7 +193,10 @@ EXTRATRANSFORMS := TRANSFORMS := $(sort $(patsubst ./%,%,$(wildcard $(THISDIR)/transforms/*.xslt)) $(EXTRATRANSFORMS)) # List of types which should be treated as X·M·L. -XMLTYPES := application/xml text/xml +# +# Types which start with a `+´ are suffixes and match any type which +# ends accordingly. +XMLTYPES := application/xml text/xml +xml ifdef GIT ifneq ($(wildcard $(THISDIR)/.git),) @@ -343,8 +346,10 @@ ifneq ($(wildcard $(BUILDDIR)/parser.xslt),) override plaintexttypes := $(filter-out $(XMLTYPES),$(shell $(XMLLINT) --xpath '/*/*[@name="书社:parsers"]//*[namespace-uri()="http://www.w3.org/1999/xhtml" and local-name()="dd"]/text()' $(call quote,$(BUILDDIR)/parser.xslt))) endif -# (callable) Get all of the files (source and includes) which have the given types. -override filesoftype = $(foreach type,$1,$(patsubst %|$(type),%,$(filter %|$(type),$(types)))) +# (callable) Get all of the files (source and includes) which have the provided types. +# +# If a provided type begins with a `+´, it is analysed as a suffix, and all matching types will be used. +override filesoftype = $(foreach typeorsuffix,$1,$(foreach type,$(if $(filter +%,$(typeorsuffix)),$(sort $(foreach suffixedtype,$(filter %$(typeorsuffix),$(types)),$(lastword $(subst |, ,$(suffixedtype))))),$(typeorsuffix)),$(patsubst %|$(type),%,$(filter %|$(type),$(types))))) # Build up collections of various file types. override xmlfiles := $(call filesoftype,$(XMLTYPES)) diff --git a/README.markdown b/README.markdown index 86d57bc..5342790 100644 --- a/README.markdown +++ b/README.markdown @@ -292,8 +292,8 @@ The following additional variables can be used to control the behaviour enable additional transforms without overriding the existing ones. - **`XMLTYPES`:** - A white·space‐separated list of media types to consider X·M·L - (default: `application/xml text/xml`). + A white·space‐separated list of media types or media type suffixes to + consider X·M·L (default: `application/xml text/xml +xml`). - **`THISREV`:** The current version of ⛩️📰 书社 (default: derived from the current