From cd93d2d8b5062493650673ecdd13139d6f0e5171 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sun, 20 Sep 2026 23:43:35 -0400 Subject: xml: markup language attributes take a bcp 47 tag Spine names a language as the directory under media/text/ is named, which for a region is the posix form with an underscore, pt_BR. A lang, xml:lang or dc:language value is a BCP 47 (RFC 3066) tag and wants a hyphen, pt-BR. Spine put its own code there unchanged, so a document in a region language produced an invalid attribute in every one of its xhtml files: 138 epubcheck errors for a document of ten segments and a navigation file. src.language_tag is the same language as a tag. The attributes and the dc metadata now read it. Output paths keep src.language, since a path is named after the directory, not after the tag. (assisted by Claude-Code) --- org/default_paths.org | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'org/default_paths.org') diff --git a/org/default_paths.org b/org/default_paths.org index a6cf19a..15f196f 100644 --- a/org/default_paths.org +++ b/org/default_paths.org @@ -310,6 +310,21 @@ template PathMatters() { string language() { return lng(); } + /+ ↓ the same language, as a language tag rather than as spine's + own code. Spine names a language the way a directory under + media/text/ is named, which for a region is the posix form + with an underscore, pt_BR. A lang, xml:lang or dc:language + value is a BCP 47 (RFC 3066) tag and wants a hyphen, pt-BR; + an underscore there is invalid and every xhtml file in the + document carrying it is an epubcheck error. Every other code + spine knows (from the document sample set) is two letters, + where the two forms are equal, which is why only a region + code shows this up. + +/ + string language_tag() { + import std.array : replace; + return lng().replace("_", "-"); + } string file_with_absolute_path() { return _env["pwd"].chainPath(path_and_fn).array; } -- cgit v1.2.3