From: Lady <redacted>
Date: Thu, 11 Jan 2024 01:20:38 +0000 (-0500)
Subject: Make X·M·L types take priority over plaintext ones
X-Git-Tag: 0.2.4~1
X-Git-Url: https://git.ladys.computer/Shushe/commitdiff_plain/86c5d5eeef6def732f49b94bc497ee07d92dc72e?ds=inline

Make X·M·L types take priority over plaintext ones

If `XMLTYPES` defines something as X·M·L, it should be treated as
X·M·L, regardless of whether there is a parser which claims to support
it.

This avoids awkward footguns where a parser might transform and claim
support for (through `@书社:supported-media-types`) an X·M·L dialect,
resulting in ⛩️📰 书社 treating that type as plaintext and wrapping it
in an `<html:script>` element. X·M·L types listed in
`@书社:supported-media-types` should instead not have any effect
(⛩️📰 书社 should not require parsers to reparse X·M·L).

This commit also removes the unused `simpletypes` variable; it was
formerly used for categorization of types into plaintext or asset prior
to the implementation of automatic detection.
---

diff --git a/GNUmakefile b/GNUmakefile
index 174f340..e698262 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -211,20 +211,16 @@ endif
 
 # Get the list of supported plaintext file types from the parser.
 ifneq ($(wildcard $(BUILDDIR)/parser.xslt),)
-override plaintexttypes := $(shell $(XSLTPROC) $(call quote,$(THISDIR)/lib/parser2types.xslt) $(call quote,$(BUILDDIR)/parser.xslt))
+override plaintexttypes := $(filter-out $(XMLTYPES),$(shell $(XSLTPROC) $(call quote,$(THISDIR)/lib/parser2types.xslt) $(call quote,$(BUILDDIR)/parser.xslt)))
 endif
 
-# Simplify the file type by only taking the first component (image,
-# text, ⁊·c).
-override simpletypes := $(shell $(TR) ' ' '\n' <<< $(call quote,$(types)) | $(SED) 's`/[^/]*$$``g')
-
 # (callable) Get all of the files (source and includes) which have the
 # given types.
 override filesoftype = $(foreach type,$1,$(patsubst %?type=$(type),%,$(filter %?type=$(type),$(types))))
 
 # Build up collections of various file types.
-override plaintextfiles := $(call filesoftype,$(plaintexttypes))
-override xmlfiles := $(filter-out $(plaintextfiles),$(call filesoftype,$(XMLTYPES)))
+override xmlfiles := $(call filesoftype,$(XMLTYPES))
+override plaintextfiles := $(filter-out $(xmlfiles),$(call filesoftype,$(plaintexttypes)))
 override assetfiles := $(filter-out $(xmlfiles) $(plaintextfiles),$(sourcefiles) $(sourceincludes))
 
 # (callable) Get the types of the given files.