metanorma-iso 2.2.4 → 2.3.0

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: 9a0563d9fa5bd34ed390701df2a0fc01e009d510059ddbfc859e6fa72505297b
4
- data.tar.gz: 0be48505ccf77b173cce715b7934f13eb169fdb5bdff34c136db5ea5992c1b28
3
+ metadata.gz: 100cc8d4acfdb9e4d94e485f58f09928173b43c096ce7c1fdce04633ee0082a7
4
+ data.tar.gz: 9c8870908553dd7103dc094e5b0f9ceebb9f43f31d417d4c8d01e5d3884c3e6e
5
5
  SHA512:
6
- metadata.gz: 047442e860fd1d6e8f067882db28c6724cd8d3b8b405a3227fef5213fe3aaa8602775418d439a93d5a29a3fc3a0ea7c628eb57ceae02ebe234b52494a75b35b3
7
- data.tar.gz: 867aa6a944da537296b117daa82e5622972b5609e03a90fde3aa32741de953f71b1ab063fd1a8ab70a466cf9abe03fffdd633b81c7ddedbd67760da5ba34f0b3
6
+ metadata.gz: 98580eb700d970913763622d7b5325c58a825a98bbe350b9cac0bdcb1f1d5891eac42d9e473deadbe289f90eb1f189c11684b53e1db48e79f94bc210d0c61171
7
+ data.tar.gz: 5c52e15664a2b8edb7590f85c73bc7b13d248c70f039970a7426f654be3f0ba8165bcfbed6ab71d46be075c34db8b9213a2508ae8a48f633ccf32eed409f2c5f
data/.gitignore CHANGED
@@ -12,7 +12,6 @@ spec/examples/rice_files/
12
12
 
13
13
  .rubocop-https--*
14
14
 
15
- /Gemfile.devel
16
15
  /Gemfile.lock
17
16
  /spec/assets/iso.doc
18
17
  /spec/assets/iso.html
@@ -88,9 +88,9 @@ module IsoDoc
88
88
 
89
89
  def formula_where(dlist, out)
90
90
  return if dlist.nil?
91
- return super unless dlist&.xpath(ns("./dt"))&.size == 1 &&
92
- dlist&.at(ns("./dd"))&.elements&.size == 1 &&
93
- dlist&.at(ns("./dd/p"))
91
+ return super unless dlist.xpath(ns("./dt"))&.size == 1 &&
92
+ dlist.at(ns("./dd"))&.elements&.size == 1 &&
93
+ dlist.at(ns("./dd/p"))
94
94
 
95
95
  out.span **{ class: "zzMoveToFollowing" } do |s|
96
96
  s << "#{@i18n.where} "
@@ -222,7 +222,7 @@ p.AnnexTableTitle, li.AnnexTableTitle, div.AnnexTableTitle {
222
222
  line-height: 12.0pt;
223
223
  page-break-before: always;
224
224
  mso-pagination: widow-orphan;
225
- page-break-after: avoid;
225
+ /*page-break-after:avoid;*/
226
226
  /* mso-list:l4 level1 lfo15; */
227
227
  tab-stops: list 0cm left 20.15pt;
228
228
  font-size: {{normalfontsize}};
@@ -248,7 +248,7 @@ p.AnnexTableTitleCxSpFirst, li.AnnexTableTitleCxSpFirst, div.AnnexTableTitleCxSp
248
248
  line-height: 12.0pt;
249
249
  page-break-before: always;
250
250
  mso-pagination: widow-orphan;
251
- page-break-after: avoid;
251
+ /*page-break-after:avoid;*/
252
252
  /* mso-list:l4 level1 lfo15; */
253
253
  tab-stops: list 0cm left 20.15pt;
254
254
  font-size: {{normalfontsize}};
@@ -274,7 +274,7 @@ p.AnnexTableTitleCxSpMiddle, li.AnnexTableTitleCxSpMiddle, div.AnnexTableTitleCx
274
274
  line-height: 12.0pt;
275
275
  page-break-before: always;
276
276
  mso-pagination: widow-orphan;
277
- page-break-after: avoid;
277
+ /*page-break-after:avoid;*/
278
278
  /* mso-list:l4 level1 lfo15; */
279
279
  tab-stops: list 0cm left 20.15pt;
280
280
  font-size: {{normalfontsize}};
@@ -303,7 +303,7 @@ p.AnnexTableTitleCxSpLast, li.AnnexTableTitleCxSpLast, div.AnnexTableTitleCxSpLa
303
303
  line-height: 12.0pt;
304
304
  page-break-before: always;
305
305
  mso-pagination: widow-orphan;
306
- page-break-after: avoid;
306
+ /*page-break-after:avoid;*/
307
307
  /* mso-list:l4 level1 lfo15; */
308
308
  tab-stops: list 0cm left 20.15pt;
309
309
  font-size: {{normalfontsize}};
@@ -211,7 +211,7 @@ p.AnnexTableTitle, li.AnnexTableTitle, div.AnnexTableTitle
211
211
  line-height:12.0pt;
212
212
  page-break-before:always;
213
213
  mso-pagination:widow-orphan;
214
- page-break-after:avoid;
214
+ /*page-break-after:avoid;*/
215
215
  /* mso-list:l4 level1 lfo15; */
216
216
  tab-stops:list 0cm left 20.15pt;
217
217
  font-size:$normalfontsize;
@@ -236,7 +236,7 @@ p.AnnexTableTitleCxSpFirst, li.AnnexTableTitleCxSpFirst, div.AnnexTableTitleCxSp
236
236
  line-height:12.0pt;
237
237
  page-break-before:always;
238
238
  mso-pagination:widow-orphan;
239
- page-break-after:avoid;
239
+ /*page-break-after:avoid;*/
240
240
  /* mso-list:l4 level1 lfo15; */
241
241
  tab-stops:list 0cm left 20.15pt;
242
242
  font-size:$normalfontsize;
@@ -261,7 +261,7 @@ p.AnnexTableTitleCxSpMiddle, li.AnnexTableTitleCxSpMiddle, div.AnnexTableTitleCx
261
261
  line-height:12.0pt;
262
262
  page-break-before:always;
263
263
  mso-pagination:widow-orphan;
264
- page-break-after:avoid;
264
+ /*page-break-after:avoid;*/
265
265
  /* mso-list:l4 level1 lfo15; */
266
266
  tab-stops:list 0cm left 20.15pt;
267
267
  font-size:$normalfontsize;
@@ -289,7 +289,7 @@ p.AnnexTableTitleCxSpLast, li.AnnexTableTitleCxSpLast, div.AnnexTableTitleCxSpLa
289
289
  line-height:12.0pt;
290
290
  page-break-before:always;
291
291
  mso-pagination:widow-orphan;
292
- page-break-after:avoid;
292
+ /*page-break-after:avoid;*/
293
293
  /* mso-list:l4 level1 lfo15; */
294
294
  tab-stops:list 0cm left 20.15pt;
295
295
  font-size:$normalfontsize;
@@ -219,7 +219,7 @@ p.AnnexTableTitle, li.AnnexTableTitle, div.AnnexTableTitle {
219
219
  line-height: 12.0pt;
220
220
  page-break-before: always;
221
221
  mso-pagination: widow-orphan;
222
- page-break-after: avoid;
222
+ /*page-break-after:avoid;*/
223
223
  /* mso-list:l4 level1 lfo15; */
224
224
  tab-stops: list 0cm left 20.15pt;
225
225
  font-size: {{normalfontsize}};
@@ -245,7 +245,7 @@ p.AnnexTableTitleCxSpFirst, li.AnnexTableTitleCxSpFirst, div.AnnexTableTitleCxSp
245
245
  line-height: 12.0pt;
246
246
  page-break-before: always;
247
247
  mso-pagination: widow-orphan;
248
- page-break-after: avoid;
248
+ /*page-break-after:avoid;*/
249
249
  /* mso-list:l4 level1 lfo15; */
250
250
  tab-stops: list 0cm left 20.15pt;
251
251
  font-size: {{normalfontsize}};
@@ -271,7 +271,7 @@ p.AnnexTableTitleCxSpMiddle, li.AnnexTableTitleCxSpMiddle, div.AnnexTableTitleCx
271
271
  line-height: 12.0pt;
272
272
  page-break-before: always;
273
273
  mso-pagination: widow-orphan;
274
- page-break-after: avoid;
274
+ /*page-break-after:avoid;*/
275
275
  /* mso-list:l4 level1 lfo15; */
276
276
  tab-stops: list 0cm left 20.15pt;
277
277
  font-size: {{normalfontsize}};
@@ -300,7 +300,7 @@ p.AnnexTableTitleCxSpLast, li.AnnexTableTitleCxSpLast, div.AnnexTableTitleCxSpLa
300
300
  line-height: 12.0pt;
301
301
  page-break-before: always;
302
302
  mso-pagination: widow-orphan;
303
- page-break-after: avoid;
303
+ /*page-break-after:avoid;*/
304
304
  /* mso-list:l4 level1 lfo15; */
305
305
  tab-stops: list 0cm left 20.15pt;
306
306
  font-size: {{normalfontsize}};
@@ -209,7 +209,7 @@ p.AnnexTableTitle, li.AnnexTableTitle, div.AnnexTableTitle
209
209
  line-height:12.0pt;
210
210
  page-break-before:always;
211
211
  mso-pagination:widow-orphan;
212
- page-break-after:avoid;
212
+ /*page-break-after:avoid;*/
213
213
  /* mso-list:l4 level1 lfo15; */
214
214
  tab-stops:list 0cm left 20.15pt;
215
215
  font-size:$normalfontsize;
@@ -234,7 +234,7 @@ p.AnnexTableTitleCxSpFirst, li.AnnexTableTitleCxSpFirst, div.AnnexTableTitleCxSp
234
234
  line-height:12.0pt;
235
235
  page-break-before:always;
236
236
  mso-pagination:widow-orphan;
237
- page-break-after:avoid;
237
+ /*page-break-after:avoid;*/
238
238
  /* mso-list:l4 level1 lfo15; */
239
239
  tab-stops:list 0cm left 20.15pt;
240
240
  font-size:$normalfontsize;
@@ -259,7 +259,7 @@ p.AnnexTableTitleCxSpMiddle, li.AnnexTableTitleCxSpMiddle, div.AnnexTableTitleCx
259
259
  line-height:12.0pt;
260
260
  page-break-before:always;
261
261
  mso-pagination:widow-orphan;
262
- page-break-after:avoid;
262
+ /*page-break-after:avoid;*/
263
263
  /* mso-list:l4 level1 lfo15; */
264
264
  tab-stops:list 0cm left 20.15pt;
265
265
  font-size:$normalfontsize;
@@ -287,7 +287,7 @@ p.AnnexTableTitleCxSpLast, li.AnnexTableTitleCxSpLast, div.AnnexTableTitleCxSpLa
287
287
  line-height:12.0pt;
288
288
  page-break-before:always;
289
289
  mso-pagination:widow-orphan;
290
- page-break-after:avoid;
290
+ /*page-break-after:avoid;*/
291
291
  /* mso-list:l4 level1 lfo15; */
292
292
  tab-stops:list 0cm left 20.15pt;
293
293
  font-size:$normalfontsize;
@@ -58,7 +58,7 @@ module IsoDoc
58
58
  end
59
59
 
60
60
  def html_toc_entry(level, header)
61
- content = header.at("./following-sibling::p"\
61
+ content = header.at("./following-sibling::p" \
62
62
  "[@class = 'variant-title-toc']") || header
63
63
  if level == "h1" &&
64
64
  header.parent.at(".//h2#{toc_exclude_class}")
@@ -127,7 +127,7 @@ module IsoDoc
127
127
  terms.each_with_object(val) do |t, v|
128
128
  term, term2, term3 = extract_indexterms_init(t)
129
129
  term_hash_init(v, term, term2, term3, label)
130
- v[term][term2][term3][label] << t&.at(ns("./target"))&.children&.to_xml
130
+ v[term][term2][term3][label] << to_xml(t.at(ns("./target"))&.children)
131
131
  t.remove
132
132
  end
133
133
  end
@@ -154,7 +154,7 @@ module IsoDoc
154
154
 
155
155
  def extract_indexterms_init(term)
156
156
  %w(primary secondary tertiary).each_with_object([]) do |x, m|
157
- m << term&.at(ns("./#{x}"))&.children&.to_xml
157
+ m << to_xml(term.at(ns("./#{x}"))&.children)
158
158
  end
159
159
  end
160
160
 
@@ -5011,6 +5011,10 @@
5011
5011
  <xsl:variable name="footnote_inline">
5012
5012
  <fo:inline xsl:use-attribute-sets="fn-num-style">
5013
5013
 
5014
+ <xsl:if test="following-sibling::*[1][local-name() = 'fn']">
5015
+ <xsl:attribute name="padding-right">0.5mm</xsl:attribute>
5016
+ </xsl:if>
5017
+
5014
5018
  <fo:basic-link internal-destination="{$ref_id}" fox:alt-text="footnote {$current_fn_number}">
5015
5019
  <xsl:value-of select="$current_fn_number_text"/>
5016
5020
  </fo:basic-link>
@@ -6251,6 +6255,23 @@
6251
6255
  <xsl:apply-templates/>
6252
6256
  </xsl:template>
6253
6257
 
6258
+ <!-- Don't break standard's numbers -->
6259
+ <!-- Example : <span class="stdpublisher">ISO</span> <span class="stddocNumber">10303</span>-<span class="stddocPartNumber">1</span>:<span class="stdyear">1994</span> -->
6260
+ <xsl:template match="*[local-name() = 'span'][@class = 'stdpublisher' or @class = 'stddocNumber' or @class = 'stddocPartNumber' or @class = 'stdyear']" priority="2">
6261
+ <xsl:choose>
6262
+ <xsl:when test="ancestor::*[local-name() = 'table']"><xsl:apply-templates/></xsl:when>
6263
+ <xsl:when test="following-sibling::*[2][local-name() = 'span'][@class = 'stdpublisher' or @class = 'stddocNumber' or @class = 'stddocPartNumber' or @class = 'stdyear']">
6264
+ <fo:inline keep-with-next.within-line="always"><xsl:apply-templates/></fo:inline>
6265
+ </xsl:when>
6266
+ <xsl:otherwise>
6267
+ <xsl:apply-templates/>
6268
+ </xsl:otherwise>
6269
+ </xsl:choose>
6270
+ </xsl:template>
6271
+ <xsl:template match="text()[not(ancestor::*[local-name() = 'table']) and preceding-sibling::*[1][local-name() = 'span'][@class = 'stdpublisher' or @class = 'stddocNumber' or @class = 'stddocPartNumber' or @class = 'stdyear'] and following-sibling::*[1][local-name() = 'span'][@class = 'stdpublisher' or @class = 'stddocNumber' or @class = 'stddocPartNumber' or @class = 'stdyear']]" priority="2">
6272
+ <fo:inline keep-with-next.within-line="always"><xsl:value-of select="."/></fo:inline>
6273
+ </xsl:template>
6274
+
6254
6275
  <!-- ========================= -->
6255
6276
  <!-- END Rich text formatting -->
6256
6277
  <!-- ========================= -->
@@ -6646,7 +6667,7 @@
6646
6667
  <xsl:choose>
6647
6668
  <xsl:when test="@colspan">
6648
6669
  <xsl:variable name="td">
6649
- <xsl:element name="td">
6670
+ <xsl:element name="{local-name()}">
6650
6671
  <xsl:attribute name="divide"><xsl:value-of select="@colspan"/></xsl:attribute>
6651
6672
  <xsl:if test="local-name()='th'">
6652
6673
  <xsl:attribute name="font-weight">bold</xsl:attribute>
@@ -6661,7 +6682,7 @@
6661
6682
  </xsl:call-template>
6662
6683
  </xsl:when>
6663
6684
  <xsl:otherwise>
6664
- <xsl:element name="td">
6685
+ <xsl:element name="{local-name()}">
6665
6686
  <xsl:apply-templates select="@*" mode="simple-table-colspan"/>
6666
6687
  <xsl:if test="local-name()='th'">
6667
6688
  <xsl:attribute name="font-weight">bold</xsl:attribute>
@@ -6728,7 +6749,7 @@
6728
6749
  <xsl:variable name="currentRow" select="."/>
6729
6750
 
6730
6751
  <xsl:variable name="normalizedTDs">
6731
- <xsl:for-each select="xalan:nodeset($previousRow)//td">
6752
+ <xsl:for-each select="xalan:nodeset($previousRow)//*[self::td or self::th]">
6732
6753
  <xsl:choose>
6733
6754
  <xsl:when test="@rowspan &gt; 1">
6734
6755
  <xsl:copy>
@@ -6740,7 +6761,7 @@
6740
6761
  </xsl:copy>
6741
6762
  </xsl:when>
6742
6763
  <xsl:otherwise>
6743
- <xsl:copy-of select="$currentRow/td[1 + count(current()/preceding-sibling::td[not(@rowspan) or (@rowspan = 1)])]"/>
6764
+ <xsl:copy-of select="$currentRow/*[self::td or self::th][1 + count(current()/preceding-sibling::*[self::td or self::th][not(@rowspan) or (@rowspan = 1)])]"/>
6744
6765
  </xsl:otherwise>
6745
6766
  </xsl:choose>
6746
6767
  </xsl:for-each>
@@ -7421,12 +7442,6 @@
7421
7442
 
7422
7443
  <fo:block-container margin-left="0mm">
7423
7444
 
7424
- <!-- <xsl:if test="$namespace = 'iho'">
7425
- <xsl:if test="ancestor::iho:td">
7426
- <xsl:attribute name="font-size">12pt</xsl:attribute>
7427
- </xsl:if>
7428
- </xsl:if> -->
7429
-
7430
7445
  <fo:block>
7431
7446
 
7432
7447
  <fo:inline xsl:use-attribute-sets="note-name-style">
@@ -7936,6 +7951,31 @@
7936
7951
  <xsl:apply-templates mode="svg_update"/>
7937
7952
  </xsl:copy>
7938
7953
  </xsl:template>
7954
+
7955
+ <!-- regex for 'display: inline-block;' -->
7956
+ <xsl:variable name="regex_svg_style_notsupported">display(\s|\h)*:(\s|\h)*inline-block(\s|\h)*;</xsl:variable>
7957
+ <xsl:template match="*[local-name() = 'svg']//*[local-name() = 'style']/text()" mode="svg_update">
7958
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.), $regex_svg_style_notsupported, '')"/>
7959
+ </xsl:template>
7960
+
7961
+ <!-- replace
7962
+ stroke="rgba(r, g, b, alpha)" to
7963
+ stroke="rgb(r,g,b)" stroke-opacity="alpha", and
7964
+ fill="rgba(r, g, b, alpha)" to
7965
+ fill="rgb(r,g,b)" fill-opacity="alpha" -->
7966
+ <xsl:template match="@*[local-name() = 'stroke' or local-name() = 'fill'][starts-with(normalize-space(.), 'rgba')]" mode="svg_update">
7967
+ <xsl:variable name="components_">
7968
+ <xsl:call-template name="split">
7969
+ <xsl:with-param name="pText" select="substring-before(substring-after(., '('), ')')"/>
7970
+ <xsl:with-param name="sep" select="','"/>
7971
+ </xsl:call-template>
7972
+ </xsl:variable>
7973
+ <xsl:variable name="components" select="xalan:nodeset($components_)"/>
7974
+ <xsl:variable name="att_name" select="local-name()"/>
7975
+ <xsl:attribute name="{$att_name}"><xsl:value-of select="concat('rgb(', $components/item[1], ',', $components/item[2], ',', $components/item[3], ')')"/></xsl:attribute>
7976
+ <xsl:attribute name="{$att_name}-opacity"><xsl:value-of select="$components/item[4]"/></xsl:attribute>
7977
+ </xsl:template>
7978
+
7939
7979
  <!-- ============== -->
7940
7980
  <!-- END: svg_update -->
7941
7981
  <!-- ============== -->
@@ -10886,7 +10926,9 @@
10886
10926
  <!-- Update xml -->
10887
10927
  <!-- ===================================== -->
10888
10928
  <!-- =========================================================================== -->
10889
- <!-- STEP1: Re-order elements in 'preface', 'sections' based on @displayorder -->
10929
+ <!-- STEP1: -->
10930
+ <!-- - Re-order elements in 'preface', 'sections' based on @displayorder -->
10931
+ <!-- - Ignore 'span' without style -->
10890
10932
  <!-- =========================================================================== -->
10891
10933
  <xsl:template match="@*|node()" mode="update_xml_step1">
10892
10934
  <xsl:copy>
@@ -10969,7 +11011,8 @@
10969
11011
  </xsl:copy>
10970
11012
  </xsl:template>
10971
11013
 
10972
- <xsl:template match="*[local-name() = 'span'][@style]" mode="update_xml_step1" priority="2">
11014
+ <!-- Example with 'class': <span class="stdpublisher">ISO</span> <span class="stddocNumber">10303</span>-<span class="stddocPartNumber">1</span>:<span class="stdyear">1994</span> -->
11015
+ <xsl:template match="*[local-name() = 'span'][@style or @class = 'stdpublisher' or @class = 'stddocNumber' or @class = 'stddocPartNumber' or @class = 'stdyear']" mode="update_xml_step1" priority="2">
10973
11016
  <xsl:copy>
10974
11017
  <xsl:copy-of select="@*"/>
10975
11018
  <xsl:apply-templates mode="update_xml_step1"/>
@@ -5011,6 +5011,10 @@
5011
5011
  <xsl:variable name="footnote_inline">
5012
5012
  <fo:inline xsl:use-attribute-sets="fn-num-style">
5013
5013
 
5014
+ <xsl:if test="following-sibling::*[1][local-name() = 'fn']">
5015
+ <xsl:attribute name="padding-right">0.5mm</xsl:attribute>
5016
+ </xsl:if>
5017
+
5014
5018
  <fo:basic-link internal-destination="{$ref_id}" fox:alt-text="footnote {$current_fn_number}">
5015
5019
  <xsl:value-of select="$current_fn_number_text"/>
5016
5020
  </fo:basic-link>
@@ -6251,6 +6255,23 @@
6251
6255
  <xsl:apply-templates/>
6252
6256
  </xsl:template>
6253
6257
 
6258
+ <!-- Don't break standard's numbers -->
6259
+ <!-- Example : <span class="stdpublisher">ISO</span> <span class="stddocNumber">10303</span>-<span class="stddocPartNumber">1</span>:<span class="stdyear">1994</span> -->
6260
+ <xsl:template match="*[local-name() = 'span'][@class = 'stdpublisher' or @class = 'stddocNumber' or @class = 'stddocPartNumber' or @class = 'stdyear']" priority="2">
6261
+ <xsl:choose>
6262
+ <xsl:when test="ancestor::*[local-name() = 'table']"><xsl:apply-templates/></xsl:when>
6263
+ <xsl:when test="following-sibling::*[2][local-name() = 'span'][@class = 'stdpublisher' or @class = 'stddocNumber' or @class = 'stddocPartNumber' or @class = 'stdyear']">
6264
+ <fo:inline keep-with-next.within-line="always"><xsl:apply-templates/></fo:inline>
6265
+ </xsl:when>
6266
+ <xsl:otherwise>
6267
+ <xsl:apply-templates/>
6268
+ </xsl:otherwise>
6269
+ </xsl:choose>
6270
+ </xsl:template>
6271
+ <xsl:template match="text()[not(ancestor::*[local-name() = 'table']) and preceding-sibling::*[1][local-name() = 'span'][@class = 'stdpublisher' or @class = 'stddocNumber' or @class = 'stddocPartNumber' or @class = 'stdyear'] and following-sibling::*[1][local-name() = 'span'][@class = 'stdpublisher' or @class = 'stddocNumber' or @class = 'stddocPartNumber' or @class = 'stdyear']]" priority="2">
6272
+ <fo:inline keep-with-next.within-line="always"><xsl:value-of select="."/></fo:inline>
6273
+ </xsl:template>
6274
+
6254
6275
  <!-- ========================= -->
6255
6276
  <!-- END Rich text formatting -->
6256
6277
  <!-- ========================= -->
@@ -6646,7 +6667,7 @@
6646
6667
  <xsl:choose>
6647
6668
  <xsl:when test="@colspan">
6648
6669
  <xsl:variable name="td">
6649
- <xsl:element name="td">
6670
+ <xsl:element name="{local-name()}">
6650
6671
  <xsl:attribute name="divide"><xsl:value-of select="@colspan"/></xsl:attribute>
6651
6672
  <xsl:if test="local-name()='th'">
6652
6673
  <xsl:attribute name="font-weight">bold</xsl:attribute>
@@ -6661,7 +6682,7 @@
6661
6682
  </xsl:call-template>
6662
6683
  </xsl:when>
6663
6684
  <xsl:otherwise>
6664
- <xsl:element name="td">
6685
+ <xsl:element name="{local-name()}">
6665
6686
  <xsl:apply-templates select="@*" mode="simple-table-colspan"/>
6666
6687
  <xsl:if test="local-name()='th'">
6667
6688
  <xsl:attribute name="font-weight">bold</xsl:attribute>
@@ -6728,7 +6749,7 @@
6728
6749
  <xsl:variable name="currentRow" select="."/>
6729
6750
 
6730
6751
  <xsl:variable name="normalizedTDs">
6731
- <xsl:for-each select="xalan:nodeset($previousRow)//td">
6752
+ <xsl:for-each select="xalan:nodeset($previousRow)//*[self::td or self::th]">
6732
6753
  <xsl:choose>
6733
6754
  <xsl:when test="@rowspan &gt; 1">
6734
6755
  <xsl:copy>
@@ -6740,7 +6761,7 @@
6740
6761
  </xsl:copy>
6741
6762
  </xsl:when>
6742
6763
  <xsl:otherwise>
6743
- <xsl:copy-of select="$currentRow/td[1 + count(current()/preceding-sibling::td[not(@rowspan) or (@rowspan = 1)])]"/>
6764
+ <xsl:copy-of select="$currentRow/*[self::td or self::th][1 + count(current()/preceding-sibling::*[self::td or self::th][not(@rowspan) or (@rowspan = 1)])]"/>
6744
6765
  </xsl:otherwise>
6745
6766
  </xsl:choose>
6746
6767
  </xsl:for-each>
@@ -7421,12 +7442,6 @@
7421
7442
 
7422
7443
  <fo:block-container margin-left="0mm">
7423
7444
 
7424
- <!-- <xsl:if test="$namespace = 'iho'">
7425
- <xsl:if test="ancestor::iho:td">
7426
- <xsl:attribute name="font-size">12pt</xsl:attribute>
7427
- </xsl:if>
7428
- </xsl:if> -->
7429
-
7430
7445
  <fo:block>
7431
7446
 
7432
7447
  <fo:inline xsl:use-attribute-sets="note-name-style">
@@ -7936,6 +7951,31 @@
7936
7951
  <xsl:apply-templates mode="svg_update"/>
7937
7952
  </xsl:copy>
7938
7953
  </xsl:template>
7954
+
7955
+ <!-- regex for 'display: inline-block;' -->
7956
+ <xsl:variable name="regex_svg_style_notsupported">display(\s|\h)*:(\s|\h)*inline-block(\s|\h)*;</xsl:variable>
7957
+ <xsl:template match="*[local-name() = 'svg']//*[local-name() = 'style']/text()" mode="svg_update">
7958
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.), $regex_svg_style_notsupported, '')"/>
7959
+ </xsl:template>
7960
+
7961
+ <!-- replace
7962
+ stroke="rgba(r, g, b, alpha)" to
7963
+ stroke="rgb(r,g,b)" stroke-opacity="alpha", and
7964
+ fill="rgba(r, g, b, alpha)" to
7965
+ fill="rgb(r,g,b)" fill-opacity="alpha" -->
7966
+ <xsl:template match="@*[local-name() = 'stroke' or local-name() = 'fill'][starts-with(normalize-space(.), 'rgba')]" mode="svg_update">
7967
+ <xsl:variable name="components_">
7968
+ <xsl:call-template name="split">
7969
+ <xsl:with-param name="pText" select="substring-before(substring-after(., '('), ')')"/>
7970
+ <xsl:with-param name="sep" select="','"/>
7971
+ </xsl:call-template>
7972
+ </xsl:variable>
7973
+ <xsl:variable name="components" select="xalan:nodeset($components_)"/>
7974
+ <xsl:variable name="att_name" select="local-name()"/>
7975
+ <xsl:attribute name="{$att_name}"><xsl:value-of select="concat('rgb(', $components/item[1], ',', $components/item[2], ',', $components/item[3], ')')"/></xsl:attribute>
7976
+ <xsl:attribute name="{$att_name}-opacity"><xsl:value-of select="$components/item[4]"/></xsl:attribute>
7977
+ </xsl:template>
7978
+
7939
7979
  <!-- ============== -->
7940
7980
  <!-- END: svg_update -->
7941
7981
  <!-- ============== -->
@@ -10886,7 +10926,9 @@
10886
10926
  <!-- Update xml -->
10887
10927
  <!-- ===================================== -->
10888
10928
  <!-- =========================================================================== -->
10889
- <!-- STEP1: Re-order elements in 'preface', 'sections' based on @displayorder -->
10929
+ <!-- STEP1: -->
10930
+ <!-- - Re-order elements in 'preface', 'sections' based on @displayorder -->
10931
+ <!-- - Ignore 'span' without style -->
10890
10932
  <!-- =========================================================================== -->
10891
10933
  <xsl:template match="@*|node()" mode="update_xml_step1">
10892
10934
  <xsl:copy>
@@ -10969,7 +11011,8 @@
10969
11011
  </xsl:copy>
10970
11012
  </xsl:template>
10971
11013
 
10972
- <xsl:template match="*[local-name() = 'span'][@style]" mode="update_xml_step1" priority="2">
11014
+ <!-- Example with 'class': <span class="stdpublisher">ISO</span> <span class="stddocNumber">10303</span>-<span class="stddocPartNumber">1</span>:<span class="stdyear">1994</span> -->
11015
+ <xsl:template match="*[local-name() = 'span'][@style or @class = 'stdpublisher' or @class = 'stddocNumber' or @class = 'stddocPartNumber' or @class = 'stdyear']" mode="update_xml_step1" priority="2">
10973
11016
  <xsl:copy>
10974
11017
  <xsl:copy-of select="@*"/>
10975
11018
  <xsl:apply-templates mode="update_xml_step1"/>
@@ -13,14 +13,19 @@ module IsoDoc
13
13
  @suffix = "isosts.xml"
14
14
  end
15
15
 
16
- def convert(input_fname, file = nil, debug = false, output_fname = nil)
17
- file = File.read(input_fname, encoding: "utf-8") if file.nil?
18
- _, fname, dir = convert_init(file, input_fname, debug)
16
+ def get_input_fname(input_fname)
19
17
  /\.xml$/.match(input_fname) or
20
18
  input_fname = Tempfile.open([fname, ".xml"], encoding: "utf-8") do |f|
21
19
  f.write file
22
20
  f.path
23
21
  end
22
+ input_fname
23
+ end
24
+
25
+ def convert(input_fname, file = nil, debug = false, output_fname = nil)
26
+ file = File.read(input_fname, encoding: "utf-8") if file.nil?
27
+ _, fname, dir = convert_init(file, input_fname, debug)
28
+ input_fname = get_input_fname(input_fname)
24
29
  FileUtils.rm_rf dir
25
30
  MnConvert.convert(input_fname,
26
31
  {
@@ -101,7 +101,7 @@ module IsoDoc
101
101
  end
102
102
 
103
103
  def concept_term1(node, seen)
104
- term = node&.at(ns("./refterm"))&.to_xml
104
+ term = to_xml(node.at(ns("./refterm")))
105
105
  if term && seen[term]
106
106
  concept_render(node, ital: "false", ref: "false",
107
107
  linkref: "true", linkmention: "false")
@@ -114,8 +114,8 @@ module IsoDoc
114
114
 
115
115
  def concept1_ref_content(ref)
116
116
  repl = if ref.name == "termref"
117
- @i18n.term_defined_in.sub(/%/, ref.to_xml)
118
- else "(#{ref.to_xml})"
117
+ @i18n.term_defined_in.sub(/%/, to_xml(ref))
118
+ else "(#{to_xml(ref)})"
119
119
  end
120
120
  ref.replace(repl)
121
121
  end
@@ -152,7 +152,7 @@ module IsoDoc
152
152
  (v = elem.at(ns("./definition/verbal-definition"))) &&
153
153
  v.elements.first.name == "p") or return
154
154
  v.elements.first.children.first.previous =
155
- "&#x3c;#{d.remove.children.to_xml}&#x3e; "
155
+ "&#x3c;#{to_xml(d.remove.children)}&#x3e; "
156
156
  end
157
157
 
158
158
  def insertall_after_here(node, insert, name)
@@ -186,7 +186,7 @@ module IsoDoc
186
186
  p = n.next_element
187
187
  return unless p.name == "p"
188
188
 
189
- p.children.first.previous = admonition_name(n.remove.children.to_xml)
189
+ p.children.first.previous = admonition_name(to_xml(n.remove.children))
190
190
  end
191
191
 
192
192
  def admonition_name(xml)
@@ -33,9 +33,10 @@ module IsoDoc
33
33
  ret = resolve_eref_connectives(eref_locality_stacks(refs, target,
34
34
  node))
35
35
  node["droploc"] = droploc
36
- eref_localities1(target,
37
- prefix_clause(target, refs.first.at(ns("./locality"))),
38
- l10n(ret[1..-1].join), nil, node, @lang)
36
+ eref_localities1({ target: target, number: "pl",
37
+ type: prefix_clause(target, refs.first.at(ns("./locality"))),
38
+ from: l10n(ret[1..-1].join),
39
+ node: node, lang: @lang })
39
40
  end
40
41
 
41
42
  def prefix_clause(target, loc)
@@ -79,29 +80,30 @@ module IsoDoc
79
80
  ret.join
80
81
  end
81
82
 
82
- def eref_localities1_zh(target, type, from, upto, node)
83
- ret = " 第#{from}" if from
84
- ret += "&#x2013;#{upto}" if upto
85
- node["droploc"] != "true" && !subclause?(target, type, from) and
86
- ret += eref_locality_populate(type, node)
87
- ret += ")" if type == "list"
88
- locality_span_wrap(ret, type)
83
+ def eref_localities1_zh(opt)
84
+ ret = " 第#{opt[:from]}" if opt[:from]
85
+ ret += "&#x2013;#{opt[:upto]}" if opt[:upto]
86
+ opt[:node]["droploc"] != "true" &&
87
+ !subclause?(opt[:target], opt[:type], opt[:from]) and
88
+ ret += eref_locality_populate(opt[:type], opt[:node], "sg")
89
+ ret += ")" if opt[:type] == "list"
90
+ locality_span_wrap(ret, opt[:type])
89
91
  end
90
92
 
91
- def eref_localities1(target, type, from, upto, node, lang = "en")
92
- return nil if type == "anchor"
93
+ def eref_localities1(opt)
94
+ return nil if opt[:type] == "anchor"
93
95
 
94
- type = type.downcase
95
- lang == "zh" and
96
- return l10n(eref_localities1_zh(target, type, from, upto, node))
96
+ opt[:type] = opt[:type].downcase
97
+ opt[:lang] == "zh" and return l10n(eref_localities1_zh(opt))
97
98
  ret = ""
98
- node["droploc"] != "true" && !subclause?(target, type, from) and
99
- ret = eref_locality_populate(type, node)
100
- ret += " #{from}" if from
101
- ret += "&#x2013;#{upto}" if upto
102
- ret += ")" if type == "list"
99
+ opt[:node]["droploc"] != "true" &&
100
+ !subclause?(opt[:target], opt[:type], opt[:from]) and
101
+ ret = eref_locality_populate(opt[:type], opt[:node], opt[:number])
102
+ ret += " #{opt[:from]}" if opt[:from]
103
+ ret += "&#x2013;#{opt[:upto]}" if opt[:upto]
104
+ ret += ")" if opt[:type] == "list"
103
105
  ret = l10n(ret)
104
- locality_span_wrap(ret, type)
106
+ locality_span_wrap(ret, opt[:type])
105
107
  end
106
108
 
107
109
  def prefix_container(container, linkend, node, target)
@@ -101,7 +101,7 @@ module IsoDoc
101
101
 
102
102
  def footnote_reference_format(link)
103
103
  link.children =
104
- "<span class='MsoFootnoteReference'>#{link.children.to_xml}</span>)"
104
+ "<span class='MsoFootnoteReference'>#{to_xml(link.children)}</span>)"
105
105
  end
106
106
 
107
107
  def bibliography_attrs
@@ -205,7 +205,7 @@ module IsoDoc
205
205
  docxml.xpath("//p[@id = 'boilerplate-address']")&.each do |p|
206
206
  p["class"] = "zzCopyright"
207
207
  p["style"] = "text-indent:20.15pt;"
208
- p.replace(p.to_xml.gsub(%r{<br/>}, "</p>\n<p class='zzCopyright' " \
208
+ p.replace(to_xml(p).gsub(%r{<br/>}, "</p>\n<p class='zzCopyright' " \
209
209
  "style='text-indent:20.15pt;'>"))
210
210
  end
211
211
  docxml.xpath("//p[@class = 'zzCopyrightHdr']")&.each do |p|
@@ -217,7 +217,7 @@ module IsoDoc
217
217
  def copyright_dis(docxml)
218
218
  docxml.xpath("//p[@id = 'boilerplate-address']")&.each do |p|
219
219
  p["class"] = "zzCopyright"
220
- p.replace(p.to_xml.gsub(%r{<br/>}, "</p>\n<p class='zzCopyright'>"))
220
+ p.replace(to_xml(p).gsub(%r{<br/>}, "</p>\n<p class='zzCopyright'>"))
221
221
  end
222
222
  docxml.xpath("//p[@class = 'zzCopyrightHdr']")&.each do |p|
223
223
  p.remove
@@ -235,7 +235,7 @@ module IsoDoc
235
235
  if t.at("./p |./div")
236
236
  t.xpath("./p | ./div").each { |p| p["class"] = s }
237
237
  else
238
- t.children = "<div class='#{s}'>#{t.children.to_xml}</div>"
238
+ t.children = "<div class='#{s}'>#{to_xml(t.children)}</div>"
239
239
  end
240
240
  end
241
241
  end
@@ -43,7 +43,7 @@ module IsoDoc
43
43
  n = Counter.new
44
44
  n = section_names(doc.at(ns("//clause[@type = 'scope']")), n, 1)
45
45
  n = section_names(doc.at(ns(@klass.norm_ref_xpath)), n, 1)
46
- doc.xpath(ns("//sections/clause[not(@type = 'scope')] | "\
46
+ doc.xpath(ns("//sections/clause[not(@type = 'scope')] | " \
47
47
  "//sections/terms | //sections/definitions")).each do |c|
48
48
  n = section_names(c, n, 1)
49
49
  end
@@ -169,25 +169,28 @@ module IsoDoc
169
169
 
170
170
  def modspec_table_xrefs(clause)
171
171
  clause.xpath(ns(".//table[@class = 'modspec']")).noblank.each do |t|
172
- (@anchors[t["id"]] && !@anchors[t["id"]][:modspec]) or next
173
172
  n = @anchors[t["id"]][:xref]
174
- @anchors[t["id"]][:modspec] = true
175
- @anchors[t["id"]][:xref] =
176
- l10n("#{n}, #{@anchors_previous[t['id']][:xref_bare]}")
173
+ xref_to_modspec(t["id"], n) or next
177
174
  modspec_table_components_xrefs(t, n)
178
175
  end
179
176
  end
180
177
 
181
178
  def modspec_table_components_xrefs(table, table_label)
182
179
  table.xpath(ns(".//tr[@id]")).each do |tr|
183
- (@anchors[tr["id"]] && !@anchors[tr["id"]][:modspec]) or next
184
- @anchors[tr["id"]][:modspec] = true
185
- @anchors[tr["id"]][:xref] =
186
- l10n("#{table_label}, #{@anchors_previous[tr['id']][:xref]}")
180
+ xref_to_modspec(tr["id"], table_label) or next
187
181
  @anchors[tr["id"]].delete(:container)
188
182
  end
189
183
  end
190
184
 
185
+ def xref_to_modspec(id, table_label)
186
+ (@anchors[id] && !@anchors[id][:has_modspec]) or return
187
+ @anchors[id][:has_modspec] = true
188
+ x = @anchors_previous[id][:xref_bare] || @anchors_previous[id][:xref]
189
+ @anchors[id][:xref] = l10n("#{table_label}, #{x}")
190
+ @anchors[id][:modspec] = @anchors_previous[id][:modspec]
191
+ true
192
+ end
193
+
191
194
  def hierarchical_table_names(clause, _num)
192
195
  super
193
196
  modspec_table_xrefs(clause) if @anchors_previous
@@ -683,6 +683,9 @@
683
683
  </define>
684
684
  <define name="underline">
685
685
  <element name="underline">
686
+ <optional>
687
+ <attribute name="style"/>
688
+ </optional>
686
689
  <zeroOrMore>
687
690
  <ref name="PureTextElement"/>
688
691
  </zeroOrMore>
@@ -47,7 +47,7 @@
47
47
  </element>
48
48
  </define>
49
49
  <define name="DocumentType">
50
- <value>document</value>
50
+ <text/>
51
51
  </define>
52
52
  <define name="docsubtype">
53
53
  <element name="subdoctype">
@@ -2653,6 +2653,7 @@
2653
2653
  <value>full</value>
2654
2654
  <value>short</value>
2655
2655
  <value>id</value>
2656
+ <value>modspec</value>
2656
2657
  </choice>
2657
2658
  </define>
2658
2659
  <define name="erefTypeWithConnective">
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module ISO
3
- VERSION = "2.2.4".freeze
3
+ VERSION = "2.3.0".freeze
4
4
  end
5
5
  end
@@ -3,15 +3,6 @@ module Metanorma
3
3
  class Modspec
4
4
  # Don't want to inherit from Metanorma::Requirements::Modspec
5
5
  class Iso < ::Metanorma::Requirements::Modspec
6
- def recommendation_label_xref(elem, label, xrefs, _type)
7
- id = @reqtlabels[label]
8
- number = xrefs.anchor(id, :xref_reqt2reqt, false)
9
- number.nil? and return type
10
- elem.ancestors("requirement, recommendation, permission").empty? and
11
- return number
12
- "<xref target='#{id}'>#{number}</xref>"
13
- end
14
-
15
6
  def recommendation_label(elem, type, xrefs)
16
7
  lbl = super
17
8
  title = elem.at(ns("./title"))
@@ -55,55 +46,13 @@ module Metanorma
55
46
 
56
47
  def postprocess_anchor_struct(block, anchor)
57
48
  super
58
- anchor[:xref_reqt2reqt] = anchor[:xref_bare]
49
+ anchor[:modspec] = anchor[:xref_bare]
59
50
  if l = block.at(ns("./title"))
60
- anchor[:xref_reqt2reqt] =
61
- l10n("#{anchor[:xref_reqt2reqt]}: #{l.children.to_xml.strip}")
51
+ anchor[:modspec] =
52
+ l10n("#{anchor[:modspec]}: #{l.children.to_xml.strip}")
62
53
  end
63
54
  anchor
64
55
  end
65
-
66
- def reqt_ids(docxml)
67
- docxml.xpath(ns("//requirement | //recommendation | //permission"))
68
- .each_with_object({}) do |r, m|
69
- id = r.at(ns("./identifier")) or next
70
- m[id.text] =
71
- { id: r["id"],
72
- lbl: @xrefs.anchor(r["id"], :xref_reqt2reqt, false) }
73
- end
74
- end
75
-
76
- def reqt_links_test1(reqt, acc)
77
- return unless %w(conformanceclass
78
- verification).include?(reqt["type"])
79
-
80
- subj = reqt_extract_target(reqt)
81
- id = reqt.at(ns("./identifier")) or return
82
- lbl = @xrefs.anchor(@reqt_ids[id.text.strip][:id], :xref_reqt2reqt,
83
- false)
84
- return unless subj
85
-
86
- acc[subj.text] = { lbl: lbl, id: reqt["id"] }
87
- end
88
-
89
- def reqt_links_class(docxml)
90
- docxml.xpath(ns("//requirement | //recommendation | //permission"))
91
- .each_with_object({}) do |r, m|
92
- next unless %w(class
93
- conformanceclass).include?(r["type"])
94
-
95
- id = r.at(ns("./identifier")) or next
96
- r.xpath(ns("./requirement | ./recommendation | ./permission"))
97
- .each do |r1|
98
- id1 = r1.at(ns("./identifier")) or next
99
- lbl = @xrefs.anchor(@reqt_ids[id.text.strip][:id],
100
- :xref_reqt2reqt, false)
101
- next unless lbl
102
-
103
- m[id1.text] = { lbl: lbl, id: r["id"] }
104
- end
105
- end
106
- end
107
56
  end
108
57
  end
109
58
  end
@@ -32,7 +32,7 @@ Gem::Specification.new do |spec|
32
32
  spec.test_files = `git ls-files -- {spec}/*`.split("\n")
33
33
  spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
34
34
 
35
- spec.add_dependency "metanorma-standoc", "~> 2.2.4"
35
+ spec.add_dependency "metanorma-standoc", "~> 2.3.0"
36
36
  spec.add_dependency "mnconvert", "~> 1.14"
37
37
  spec.add_dependency "pubid-iso"
38
38
  spec.add_dependency "ruby-jing"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-iso
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.4
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-21 00:00:00.000000000 Z
11
+ date: 2022-12-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: metanorma-standoc
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 2.2.4
19
+ version: 2.3.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 2.2.4
26
+ version: 2.3.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: mnconvert
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -415,7 +415,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
415
415
  - !ruby/object:Gem::Version
416
416
  version: '0'
417
417
  requirements: []
418
- rubygems_version: 3.3.7
418
+ rubygems_version: 3.3.26
419
419
  signing_key:
420
420
  specification_version: 4
421
421
  summary: metanorma-iso lets you write ISO standards in AsciiDoc.