metanorma-iho 1.4.9 → 1.4.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 37838753ccb42360d67701723963b3e5d5957a73c1a71abf0c1149c3bad8861d
4
- data.tar.gz: 0cfdf014198b9904fcc7d6b51c2a1e6cf3d94256b162e38c6a458cf0489e45ce
3
+ metadata.gz: d34ec7bf757d609c47fcc4d8efa109030f1cf0c6b76272ab9b76e3e3b59a7256
4
+ data.tar.gz: a9f2b2e31759e5b49b413f4d9dba52ea12423f6747592b2c4582037d9b920803
5
5
  SHA512:
6
- metadata.gz: f9cb469ec176a7908eb76e9a6bfdb010e3f17544ceec55a7d5d713e7fe055970f8248ac94a6ae766831346a56930adadea32b2962d1e7c4d0372ffab0cf8c723
7
- data.tar.gz: 6ac616303ba3b2519394a7fdb0f1ff3e3110bc70ae45d0f937be5c01d866d1e0087ba00b420a0b74e235a7d8b74453138880401c009f146276072f17aa9eeb4f
6
+ metadata.gz: 2986f821c2c9235ee2a0b950ade96b7607ff96bc55b86df89d19fabadd8eb9d7e2282df226be15beed3972bc604408a1c1d66eb328f239111c0b1ee987058a9c
7
+ data.tar.gz: bbd67b129db6381037c5e9f2961f565345ae568d421641a213966131b2952abccea489f5d1336327e83d164b50bd24d99f354cb9b4579344709586b3b430d4c4
@@ -2188,8 +2188,20 @@
2188
2188
  <xsl:if test="$docnum != '1'">_<xsl:value-of select="$docnum"/></xsl:if>
2189
2189
  </xsl:variable>
2190
2190
  <xsl:variable name="named_dest_doc" select="normalize-space($named_dest_doc_)"/>
2191
- <xsl:if test="not(key('kid', $named_dest_doc))"> <!-- if element with id '$named_dest_doc' doesn't exist in the document -->
2192
- <xsl:attribute name="named_dest"><xsl:value-of select="normalize-space($named_dest_doc)"/></xsl:attribute>
2191
+ <xsl:variable name="named_dest_unique_">
2192
+ <xsl:choose>
2193
+ <xsl:when test="normalize-space($caption_label) != '' and count(//mn:fmt-name[translate(normalize-space(.//mn:span[@class = 'fmt-caption-label']), ' ()', '') = $caption_label]) &gt; 1">
2194
+ <!-- duplicate caption numbers across clauses (e.g. two "Table 1" in front matter): qualify with the owner element id so fo ids stay unique -->
2195
+ <xsl:value-of select="concat(normalize-space($named_dest_doc), '_', ancestor::*[@id][1]/@id)"/>
2196
+ </xsl:when>
2197
+ <xsl:otherwise>
2198
+ <xsl:value-of select="normalize-space($named_dest_doc)"/>
2199
+ </xsl:otherwise>
2200
+ </xsl:choose>
2201
+ </xsl:variable>
2202
+ <xsl:variable name="named_dest_unique" select="normalize-space($named_dest_unique_)"/>
2203
+ <xsl:if test="$named_dest_unique != '' and not(key('kid', $named_dest_unique))"> <!-- if element with id '$named_dest_unique' doesn't exist in the document -->
2204
+ <xsl:attribute name="named_dest"><xsl:value-of select="$named_dest_unique"/></xsl:attribute>
2193
2205
  </xsl:if>
2194
2206
  </xsl:if>
2195
2207
  </xsl:template>
@@ -15927,13 +15939,23 @@
15927
15939
  <xsl:param name="letter-spacing" select="'0.15'"/>
15928
15940
  <xsl:if test="string-length($text) &gt; 0">
15929
15941
  <xsl:variable name="char" select="substring($text, 1, 1)"/>
15930
- <fo:inline padding-right="{$letter-spacing}mm">
15931
- <xsl:if test="$char = '®'">
15932
- <xsl:attribute name="font-size">58%</xsl:attribute>
15933
- <xsl:attribute name="baseline-shift">30%</xsl:attribute>
15934
- </xsl:if>
15935
- <xsl:value-of select="$char"/>
15936
- </fo:inline>
15942
+ <xsl:choose>
15943
+ <xsl:when test="contains($letter-spacing, 'em') or contains($letter-spacing, 'mm')">
15944
+ <!-- for negative letter spacing (in em) -->
15945
+ <fo:inline letter-spacing="{$letter-spacing}">
15946
+ <xsl:value-of select="$char"/>
15947
+ </fo:inline>
15948
+ </xsl:when>
15949
+ <xsl:otherwise>
15950
+ <fo:inline padding-right="{$letter-spacing}mm">
15951
+ <xsl:if test="$char = '®'">
15952
+ <xsl:attribute name="font-size">58%</xsl:attribute>
15953
+ <xsl:attribute name="baseline-shift">30%</xsl:attribute>
15954
+ </xsl:if>
15955
+ <xsl:value-of select="$char"/>
15956
+ </fo:inline>
15957
+ </xsl:otherwise>
15958
+ </xsl:choose>
15937
15959
  <xsl:call-template name="add-letter-spacing">
15938
15960
  <xsl:with-param name="text" select="substring($text, 2)"/>
15939
15961
  <xsl:with-param name="letter-spacing" select="$letter-spacing"/>
@@ -2188,8 +2188,20 @@
2188
2188
  <xsl:if test="$docnum != '1'">_<xsl:value-of select="$docnum"/></xsl:if>
2189
2189
  </xsl:variable>
2190
2190
  <xsl:variable name="named_dest_doc" select="normalize-space($named_dest_doc_)"/>
2191
- <xsl:if test="not(key('kid', $named_dest_doc))"> <!-- if element with id '$named_dest_doc' doesn't exist in the document -->
2192
- <xsl:attribute name="named_dest"><xsl:value-of select="normalize-space($named_dest_doc)"/></xsl:attribute>
2191
+ <xsl:variable name="named_dest_unique_">
2192
+ <xsl:choose>
2193
+ <xsl:when test="normalize-space($caption_label) != '' and count(//mn:fmt-name[translate(normalize-space(.//mn:span[@class = 'fmt-caption-label']), ' ()', '') = $caption_label]) &gt; 1">
2194
+ <!-- duplicate caption numbers across clauses (e.g. two "Table 1" in front matter): qualify with the owner element id so fo ids stay unique -->
2195
+ <xsl:value-of select="concat(normalize-space($named_dest_doc), '_', ancestor::*[@id][1]/@id)"/>
2196
+ </xsl:when>
2197
+ <xsl:otherwise>
2198
+ <xsl:value-of select="normalize-space($named_dest_doc)"/>
2199
+ </xsl:otherwise>
2200
+ </xsl:choose>
2201
+ </xsl:variable>
2202
+ <xsl:variable name="named_dest_unique" select="normalize-space($named_dest_unique_)"/>
2203
+ <xsl:if test="$named_dest_unique != '' and not(key('kid', $named_dest_unique))"> <!-- if element with id '$named_dest_unique' doesn't exist in the document -->
2204
+ <xsl:attribute name="named_dest"><xsl:value-of select="$named_dest_unique"/></xsl:attribute>
2193
2205
  </xsl:if>
2194
2206
  </xsl:if>
2195
2207
  </xsl:template>
@@ -15927,13 +15939,23 @@
15927
15939
  <xsl:param name="letter-spacing" select="'0.15'"/>
15928
15940
  <xsl:if test="string-length($text) &gt; 0">
15929
15941
  <xsl:variable name="char" select="substring($text, 1, 1)"/>
15930
- <fo:inline padding-right="{$letter-spacing}mm">
15931
- <xsl:if test="$char = '®'">
15932
- <xsl:attribute name="font-size">58%</xsl:attribute>
15933
- <xsl:attribute name="baseline-shift">30%</xsl:attribute>
15934
- </xsl:if>
15935
- <xsl:value-of select="$char"/>
15936
- </fo:inline>
15942
+ <xsl:choose>
15943
+ <xsl:when test="contains($letter-spacing, 'em') or contains($letter-spacing, 'mm')">
15944
+ <!-- for negative letter spacing (in em) -->
15945
+ <fo:inline letter-spacing="{$letter-spacing}">
15946
+ <xsl:value-of select="$char"/>
15947
+ </fo:inline>
15948
+ </xsl:when>
15949
+ <xsl:otherwise>
15950
+ <fo:inline padding-right="{$letter-spacing}mm">
15951
+ <xsl:if test="$char = '®'">
15952
+ <xsl:attribute name="font-size">58%</xsl:attribute>
15953
+ <xsl:attribute name="baseline-shift">30%</xsl:attribute>
15954
+ </xsl:if>
15955
+ <xsl:value-of select="$char"/>
15956
+ </fo:inline>
15957
+ </xsl:otherwise>
15958
+ </xsl:choose>
15937
15959
  <xsl:call-template name="add-letter-spacing">
15938
15960
  <xsl:with-param name="text" select="substring($text, 2)"/>
15939
15961
  <xsl:with-param name="letter-spacing" select="$letter-spacing"/>
@@ -38,6 +38,37 @@ module Metanorma
38
38
  metadata_commentperiod(node, ext)
39
39
  end
40
40
 
41
+ # S-158:1xx validation-check specifications carry the product
42
+ # number as a Pubid::Iho `checks_for` member ("S-158:102" is
43
+ # S-158 checks for S-102), not as part of the document number.
44
+ # The :checks-for: document attribute carries it; the identifier is
45
+ # constructed through Pubid::Iho so the face and the MRN URN
46
+ # stay grammar-canonical. Documents without :checks-for: keep the
47
+ # generic docid_template path.
48
+ def metadata_id(node, xml)
49
+ if (id = checks_for_identifier(node))
50
+ # The IHO document face is unprefixed ("S-158:102"); the
51
+ # publisher rides the docidentifier type and the URN.
52
+ urn = id.to_urn
53
+ id.publisher = nil
54
+ add_noko_elem(xml, "docidentifier", id.to_s.strip,
55
+ primary: "true", boilerplate: true,
56
+ type: metadata_id_primary_type(node))
57
+ add_noko_elem(xml, "docidentifier", urn, type: "URN")
58
+ else
59
+ super
60
+ end
61
+ end
62
+
63
+ def checks_for_identifier(node)
64
+ checks_for = node.attr("checks-for") or return nil
65
+ number = node.attr("docnumber") or return nil
66
+ Pubid::Iho::Identifier.parse("S-#{number}:#{checks_for}")
67
+ rescue Pubid::Errors::ParseError
68
+ @log.add("IHO_4", nil, params: [number, checks_for])
69
+ nil
70
+ end
71
+
41
72
  # IHO S-4 documents carry their editorial group as plain attributes:
42
73
  # :committee:/:workgroup: (with _2, _3… suffixes for additional
43
74
  # groups). Emitted into bibdata <ext><editorialgroup>, the shape
@@ -14,6 +14,10 @@ module Metanorma
14
14
  error: "update-unit `%s` does not belong to Part %s " \
15
15
  "of this document",
16
16
  severity: 2 },
17
+ "IHO_4": { category: "AsciiDoc Input",
18
+ error: "`%s:%s` is not a valid S-158:1xx checks-for " \
19
+ "identifier (expected e.g. 158:102)",
20
+ severity: 2 },
17
21
  }.freeze
18
22
  # rubocop:enable Naming/VariableNumber
19
23
 
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Iho
3
- VERSION = "1.4.9".freeze
3
+ VERSION = "1.4.11".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-iho
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.9
4
+ version: 1.4.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-11-25 00:00:00.000000000 Z
11
+ date: 2026-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pubid