metanorma-iso 2.4.8 → 2.5.1

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: 7aaa364a3a007ab13cb425bee0b000154d5d49d394db13f37945b18eb77a7d97
4
- data.tar.gz: 54974181bd0d2c29fc00299aaa0da54bc5749c741d4a63503003af1d46038c95
3
+ metadata.gz: 1ab1010b198fb64456b71a06834ab3c1207417c16c765f6c5905cd18ff5a0dc8
4
+ data.tar.gz: c92bdd8228ce983eed939cb2b38b60b7ec631d37b64ea390e26e870700f7065b
5
5
  SHA512:
6
- metadata.gz: 85dcbabb3fd13f5020003f4e5c59d8fad34287002f3e9fc03d4cc6c0fe37d0938bcf0ce1e3a3e6a0fc5a1937c756646662cd7d48eea65e3208e1650927ab3133
7
- data.tar.gz: 77268460b6cfbeda72397ec169dc82bfdfdd724214d138fe7f6621570cf01b881097baaebc36e0eadac9568e2b842e2fa068c5994f98fb228c9ef1146dfc3430
6
+ metadata.gz: de58d8b4fa0e039e153cd5a9d9637adaedf45e674cb59c113e2feb4eaa1444ca7d98badd5ac080687ec66ee19305e8b8677ea855c24b1df91ddae0c12464180a
7
+ data.tar.gz: 48d297855239fec0dd80dbb6db404bf4b8c2a79ba49051d275f56f3dff579bda479f30ba71ba1931170088c7e3c0014878b92af7d91177151f625cdf359e7ef9
@@ -6,7 +6,7 @@ module IsoDoc
6
6
  module Iso
7
7
  module BaseConvert
8
8
  def convert1(docxml, filename, dir)
9
- if amd(docxml)
9
+ if amd?(docxml)
10
10
  @oldsuppressheadingnumbers = @suppressheadingnumbers
11
11
  @suppressheadingnumbers = true
12
12
  end
@@ -130,22 +130,13 @@ module IsoDoc
130
130
  end
131
131
  end
132
132
 
133
- def middle(isoxml, out)
134
- middle_title(isoxml, out)
135
- middle_admonitions(isoxml, out)
136
- i = scope isoxml, out, 0
137
- i = norm_ref isoxml, out, i
138
- clause_etc isoxml, out, i
139
- annex isoxml, out
140
- bibliography isoxml, out
141
- end
142
-
143
- def clause_etc(isoxml, out, num)
144
- isoxml.xpath(ns("//sections/clause[not(@type = 'scope')] | " \
145
- "//sections/terms | //sections/definitions"))
146
- .each do |f|
147
- clause_etc1(f, out, num)
148
- end
133
+ def top_element_render(elem, out)
134
+ if %w(clause terms definitions).include?(elem.name) &&
135
+ elem.parent.name == "sections" &&
136
+ elem["type"] != "scope"
137
+ clause_etc1(elem, out, 0)
138
+ else super
139
+ end
149
140
  end
150
141
 
151
142
  def clause_etc1(clause, out, num)
@@ -161,12 +152,6 @@ module IsoDoc
161
152
  end
162
153
  end
163
154
 
164
- def indexsect(isoxml, out)
165
- isoxml.xpath(ns("//indexsect")).each do |i|
166
- clause_parse(i, out)
167
- end
168
- end
169
-
170
155
  def ol_attrs(node)
171
156
  super.merge(start: node["start"]).compact
172
157
  end
@@ -81,18 +81,6 @@ module IsoDoc
81
81
  docxml
82
82
  end
83
83
 
84
- def middle(isoxml, out)
85
- middle_title(isoxml, out)
86
- middle_admonitions(isoxml, out)
87
- scope isoxml, out, 0
88
- norm_ref isoxml, out, 0
89
- clause_etc isoxml, out, 0
90
- annex isoxml, out
91
- bibliography isoxml, out
92
- indexsect isoxml, out
93
- end
94
-
95
-
96
84
  def html_toc1(ulist)
97
85
  u2 = nil
98
86
  ulist.xpath("./li").each do |l|
@@ -20,7 +20,7 @@ module IsoDoc
20
20
  i18nyaml: i18nyaml || @i18nyaml)
21
21
  end
22
22
 
23
- def amd(docxml)
23
+ def amd?(docxml)
24
24
  doctype = docxml.at(ns("//bibdata/ext/doctype"))&.text
25
25
  %w(amendment technical-corrigendum).include? doctype
26
26
  end
@@ -44,16 +44,15 @@ module IsoDoc
44
44
  end
45
45
 
46
46
  def std_docid_semantic1(id)
47
- ids = id.split(/ /)
48
- %w(ISO IEC ITU IETF NIST OGC IEEE BIPM BSI IANA UN W3C IEV)
49
- .include?(ids[0].sub(/\/.*$/, "")) or
50
- return id
47
+ ids = id.split(/(\p{Zs})/)
48
+ agency?(ids[0].sub(/\/.*$/, "")) or return id
51
49
  ids.map! do |i|
52
50
  if %w(GUIDE TR TS DIR).include?(i)
53
51
  "<span class='stddocNumber'>#{i}</span>"
52
+ elsif /\p{Zs}/.match?(i) then i
54
53
  else std_docid_semantic_full(i)
55
54
  end
56
- end.join(" ")
55
+ end.join
57
56
  end
58
57
 
59
58
  def std_docid_semantic_full(ident)
@@ -1353,38 +1353,35 @@
1353
1353
  <xsl:call-template name="insertHeaderFooter"/>
1354
1354
  <fo:flow flow-name="xsl-region-body">
1355
1355
 
1356
- <fo:block-container>
1357
- <!-- Information and documentation — Codes for transcription systems -->
1358
- <!-- <fo:block font-size="16pt" font-weight="bold" margin-bottom="18pt">
1359
- <xsl:value-of select="$title-en"/>
1360
- </fo:block>
1361
- -->
1356
+ <!-- Information and documentation — Codes for transcription systems -->
1357
+ <!-- <fo:block-container>
1358
+
1362
1359
  <fo:block font-size="18pt" font-weight="bold" margin-top="40pt" margin-bottom="20pt" line-height="1.1" role="H1">
1363
-
1360
+
1364
1361
  <fo:block role="SKIP">
1365
-
1362
+
1366
1363
  <xsl:apply-templates select="/iso:iso-standard/iso:bibdata/iso:title[@language = $lang and @type = 'title-intro']"/>
1367
-
1364
+
1368
1365
  <xsl:apply-templates select="/iso:iso-standard/iso:bibdata/iso:title[@language = $lang and @type = 'title-main']"/>
1369
-
1366
+
1370
1367
  <xsl:apply-templates select="/iso:iso-standard/iso:bibdata/iso:title[@language = $lang and @type = 'title-part']">
1371
1368
  <xsl:with-param name="isMainLang">true</xsl:with-param>
1372
1369
  <xsl:with-param name="isMainBody">true</xsl:with-param>
1373
1370
  </xsl:apply-templates>
1374
-
1371
+
1375
1372
  </fo:block>
1376
1373
  <fo:block role="SKIP">
1377
1374
  <xsl:apply-templates select="/iso:iso-standard/iso:bibdata/iso:title[@language = $lang and @type = 'title-part']/node()"/>
1378
1375
  </fo:block>
1379
-
1376
+
1380
1377
  <xsl:apply-templates select="/iso:iso-standard/iso:bibdata/iso:title[@language = $lang and @type = 'title-amd']">
1381
1378
  <xsl:with-param name="isMainLang">true</xsl:with-param>
1382
1379
  <xsl:with-param name="isMainBody">true</xsl:with-param>
1383
1380
  </xsl:apply-templates>
1384
-
1381
+
1385
1382
  </fo:block>
1386
-
1387
- </fo:block-container>
1383
+
1384
+ </fo:block-container> -->
1388
1385
  <!-- Clause(s) -->
1389
1386
  <fo:block>
1390
1387
 
@@ -1757,6 +1754,31 @@
1757
1754
  </xsl:if>
1758
1755
  </xsl:template>
1759
1756
 
1757
+ <xsl:template match="iso:sections/iso:p[@class = 'zzSTDTitle1']" priority="4">
1758
+ <fo:block font-size="18pt" font-weight="bold" margin-top="40pt" margin-bottom="20pt" line-height="1.1" role="H1">
1759
+ <xsl:if test="following-sibling::*[1][self::iso:p][starts-with(@class, 'zzSTDTitle')]">
1760
+ <xsl:attribute name="margin-bottom">0pt</xsl:attribute>
1761
+ </xsl:if>
1762
+ <xsl:apply-templates/>
1763
+ </fo:block>
1764
+ </xsl:template>
1765
+
1766
+ <xsl:template match="iso:sections/iso:p[@class = 'zzSTDTitle1']/iso:span[@class = 'nonboldtitle']" priority="3">
1767
+ <!-- Example: <span class="nonboldtitle">Part 1:</span> -->
1768
+ <fo:block font-weight="normal" margin-top="12pt" line-height="1.1" role="SKIP">
1769
+ <xsl:apply-templates/>
1770
+ </fo:block>
1771
+ </xsl:template>
1772
+
1773
+ <xsl:template match="iso:sections/iso:p[@class = 'zzSTDTitle2']" priority="4">
1774
+ <!-- Example: <p class="zzSTDTitle2" displayorder="3">AMENDMENT 1: Mass fraction of extraneous matter, milled rice (nonglutinous), sample dividers and recommendations relating to storage and transport conditions</p> -->
1775
+ <xsl:if test="$doctype = 'amendment'">
1776
+ <fo:block font-size="18pt" margin-top="12pt" margin-bottom="20pt" margin-right="0mm" font-weight="normal" line-height="1.1" role="H1">
1777
+ <xsl:apply-templates/>
1778
+ </fo:block>
1779
+ </xsl:if>
1780
+ </xsl:template>
1781
+
1760
1782
  <!-- ==================== -->
1761
1783
  <!-- END display titles -->
1762
1784
  <!-- ==================== -->
@@ -2652,11 +2674,26 @@
2652
2674
  <xsl:value-of select="$font_extended"/><xsl:text>, </xsl:text>
2653
2675
  </xsl:if>
2654
2676
 
2655
- <xsl:value-of select="."/>
2677
+ <xsl:variable name="font_family" select="."/>
2656
2678
 
2657
- <xsl:if test="$additional_fonts != ''">
2658
- <xsl:text>, </xsl:text><xsl:value-of select="$additional_fonts"/>
2659
- </xsl:if>
2679
+ <xsl:choose>
2680
+ <xsl:when test="$additional_fonts = ''">
2681
+ <xsl:value-of select="$font_family"/>
2682
+ </xsl:when>
2683
+ <xsl:otherwise> <!-- $additional_fonts != '' -->
2684
+ <xsl:choose>
2685
+ <xsl:when test="contains($font_family, ',')">
2686
+ <xsl:value-of select="substring-before($font_family, ',')"/>
2687
+ <xsl:text>, </xsl:text><xsl:value-of select="$additional_fonts"/>
2688
+ <xsl:text>, </xsl:text><xsl:value-of select="substring-after($font_family, ',')"/>
2689
+ </xsl:when>
2690
+ <xsl:otherwise>
2691
+ <xsl:value-of select="$font_family"/>
2692
+ <xsl:text>, </xsl:text><xsl:value-of select="$additional_fonts"/>
2693
+ </xsl:otherwise>
2694
+ </xsl:choose>
2695
+ </xsl:otherwise>
2696
+ </xsl:choose>
2660
2697
  </xsl:attribute>
2661
2698
  </xsl:when>
2662
2699
  <xsl:otherwise>
@@ -5330,21 +5367,21 @@
5330
5367
 
5331
5368
  <xsl:template match="*[local-name()='table']/*[local-name()='note' or local-name() = 'example']" priority="2">
5332
5369
 
5333
- <fo:block xsl:use-attribute-sets="table-note-style">
5370
+ <fo:block xsl:use-attribute-sets="table-note-style">
5334
5371
 
5335
- <xsl:call-template name="refine_table-note-style"/>
5372
+ <xsl:call-template name="refine_table-note-style"/>
5336
5373
 
5337
- <!-- Table's note/example name (NOTE, for example) -->
5338
- <fo:inline xsl:use-attribute-sets="table-note-name-style">
5374
+ <!-- Table's note/example name (NOTE, for example) -->
5375
+ <fo:inline xsl:use-attribute-sets="table-note-name-style">
5339
5376
 
5340
- <xsl:call-template name="refine_table-note-name-style"/>
5377
+ <xsl:call-template name="refine_table-note-name-style"/>
5341
5378
 
5342
- <xsl:apply-templates select="*[local-name() = 'name']"/>
5379
+ <xsl:apply-templates select="*[local-name() = 'name']"/>
5343
5380
 
5344
- </fo:inline>
5381
+ </fo:inline>
5345
5382
 
5346
- <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
5347
- </fo:block>
5383
+ <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
5384
+ </fo:block>
5348
5385
 
5349
5386
  </xsl:template> <!-- table/note -->
5350
5387
 
@@ -6429,6 +6466,9 @@
6429
6466
  <!-- END Definition List -->
6430
6467
  <!-- ===================== -->
6431
6468
 
6469
+ <!-- default: ignore title in sections/p -->
6470
+ <xsl:template match="*[local-name() = 'sections']/*[local-name() = 'p'][starts-with(@class, 'zzSTDTitle')]" priority="3"/>
6471
+
6432
6472
  <!-- ========================= -->
6433
6473
  <!-- Rich text formatting -->
6434
6474
  <!-- ========================= -->
@@ -6512,7 +6552,7 @@
6512
6552
  <xsl:variable name="regex_url_start">^(http://|https://|www\.)?(.*)</xsl:variable>
6513
6553
  <xsl:template match="*[local-name()='tt']/text()" priority="2">
6514
6554
  <xsl:choose>
6515
- <xsl:when test="java:replaceAll(java:java.lang.String.new(.), '$2', '') != ''">
6555
+ <xsl:when test="java:replaceAll(java:java.lang.String.new(.), $regex_url_start, '$2') != ''">
6516
6556
  <!-- url -->
6517
6557
  <xsl:call-template name="add-zero-spaces-link-java"/>
6518
6558
  </xsl:when>
@@ -7045,10 +7085,13 @@
7045
7085
  </xsl:choose>
7046
7086
  </xsl:variable>
7047
7087
 
7088
+ <!-- replace sequence #x200B to one &#x200B -->
7089
+ <xsl:variable name="text10" select="java:replaceAll(java:java.lang.String.new($text9), '\u200b{2,}', '​')"/>
7090
+
7048
7091
  <!-- replace sequence #x200B and space TO space -->
7049
- <xsl:variable name="text10" select="java:replaceAll(java:java.lang.String.new($text9), '\u200b ', ' ')"/>
7092
+ <xsl:variable name="text11" select="java:replaceAll(java:java.lang.String.new($text10), '\u200b ', ' ')"/>
7050
7093
 
7051
- <xsl:value-of select="$text10"/>
7094
+ <xsl:value-of select="$text11"/>
7052
7095
  </xsl:template>
7053
7096
 
7054
7097
  <xsl:template name="add-zero-spaces-link-java">
@@ -7058,8 +7101,12 @@
7058
7101
  <xsl:variable name="url_continue" select="java:replaceAll(java:java.lang.String.new($text), $regex_url_start, '$2')"/>
7059
7102
  <!-- add zero-width space (#x200B) after characters: dash, dot, colon, equal, underscore, em dash, thin space, comma, slash, @ -->
7060
7103
  <xsl:variable name="url" select="java:replaceAll(java:java.lang.String.new($url_continue),'(-|\.|:|=|_|—| |,|/|@)','$1​')"/>
7104
+
7105
+ <!-- replace sequence #x200B to one &#x200B -->
7106
+ <xsl:variable name="url2" select="java:replaceAll(java:java.lang.String.new($url), '\u200b{2,}', '​')"/>
7107
+
7061
7108
  <!-- remove zero-width space at the end -->
7062
- <xsl:value-of select="java:replaceAll(java:java.lang.String.new($url), '​$', '')"/>
7109
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new($url2), '​$', '')"/>
7063
7110
  </xsl:template>
7064
7111
 
7065
7112
  <!-- add zero space after dash character (for table's entries) -->
@@ -8556,8 +8603,12 @@
8556
8603
  <xsl:variable name="isAdded" select="../@added"/>
8557
8604
  <xsl:variable name="isDeleted" select="../@deleted"/>
8558
8605
  <xsl:choose>
8559
- <xsl:when test="ancestor::*[local-name() = 'title']">
8606
+ <xsl:when test="ancestor::*[local-name() = 'title'] or not(parent::*[local-name() = 'figure']) or parent::*[local-name() = 'p']">
8560
8607
  <fo:inline padding-left="1mm" padding-right="1mm">
8608
+ <xsl:if test="not(parent::*[local-name() = 'figure']) or parent::*[local-name() = 'p']">
8609
+ <xsl:attribute name="padding-left">0mm</xsl:attribute>
8610
+ <xsl:attribute name="padding-right">0mm</xsl:attribute>
8611
+ </xsl:if>
8561
8612
  <xsl:variable name="src">
8562
8613
  <xsl:call-template name="image_src"/>
8563
8614
  </xsl:variable>
@@ -8590,25 +8641,45 @@
8590
8641
  <fo:external-graphic src="{$src}" fox:alt-text="Image {@alt}" xsl:use-attribute-sets="image-graphic-style">
8591
8642
  <xsl:if test="not(@mimetype = 'image/svg+xml') and ../*[local-name() = 'name'] and not(ancestor::*[local-name() = 'table'])">
8592
8643
 
8593
- <xsl:variable name="img_src">
8594
- <xsl:choose>
8595
- <xsl:when test="not(starts-with(@src, 'data:'))"><xsl:value-of select="concat($basepath, @src)"/></xsl:when>
8596
- <xsl:otherwise><xsl:value-of select="@src"/></xsl:otherwise>
8597
- </xsl:choose>
8598
- </xsl:variable>
8644
+ <xsl:if test="@width != '' and @width != 'auto' and @width != 'text-width' and @width != 'full-page-width' and @width != 'narrow'">
8645
+ <xsl:attribute name="width">
8646
+ <xsl:value-of select="@width"/>
8647
+ </xsl:attribute>
8648
+ </xsl:if>
8599
8649
 
8600
- <xsl:variable name="image_width_effective">
8650
+ <xsl:if test="@height != '' and @height != 'auto'">
8651
+ <xsl:attribute name="height">
8652
+ <xsl:value-of select="@height"/>
8653
+ </xsl:attribute>
8654
+ </xsl:if>
8601
8655
 
8602
- <xsl:value-of select="$width_effective"/>
8656
+ <xsl:choose>
8657
+ <xsl:when test="@width != '' and @width != 'auto' and @height != '' and @height != 'auto'">
8658
+ <xsl:attribute name="scaling">non-uniform</xsl:attribute>
8659
+ </xsl:when>
8660
+ <xsl:otherwise>
8603
8661
 
8604
- </xsl:variable>
8662
+ <xsl:variable name="img_src">
8663
+ <xsl:choose>
8664
+ <xsl:when test="not(starts-with(@src, 'data:'))"><xsl:value-of select="concat($basepath, @src)"/></xsl:when>
8665
+ <xsl:otherwise><xsl:value-of select="@src"/></xsl:otherwise>
8666
+ </xsl:choose>
8667
+ </xsl:variable>
8605
8668
 
8606
- <xsl:variable name="scale" select="java:org.metanorma.fop.Util.getImageScale($img_src, $image_width_effective, $height_effective)"/>
8607
- <xsl:if test="number($scale) &lt; 100">
8669
+ <xsl:variable name="image_width_effective">
8608
8670
 
8609
- <xsl:attribute name="content-width"><xsl:value-of select="$scale"/>%</xsl:attribute>
8671
+ <xsl:value-of select="$width_effective"/>
8610
8672
 
8611
- </xsl:if>
8673
+ </xsl:variable>
8674
+
8675
+ <xsl:variable name="scale" select="java:org.metanorma.fop.Util.getImageScale($img_src, $image_width_effective, $height_effective)"/>
8676
+ <xsl:if test="number($scale) &lt; 100">
8677
+
8678
+ <xsl:attribute name="content-width"><xsl:value-of select="$scale"/>%</xsl:attribute>
8679
+
8680
+ </xsl:if>
8681
+ </xsl:otherwise>
8682
+ </xsl:choose>
8612
8683
 
8613
8684
  </xsl:if>
8614
8685
 
@@ -12266,7 +12337,7 @@
12266
12337
  <xsl:template match="*[local-name() = 'span']" mode="update_xml_step1">
12267
12338
  <xsl:apply-templates mode="update_xml_step1"/>
12268
12339
  </xsl:template>
12269
- <xsl:template match="*[local-name() = 'sourcecode']//*[local-name() = 'span'][@class]" mode="update_xml_step1" priority="2">
12340
+ <xsl:template match="*[local-name() = 'sections']/*[local-name() = 'p'][starts-with(@class, 'zzSTDTitle')]/*[local-name() = 'span'][@class] | *[local-name() = 'sourcecode']//*[local-name() = 'span'][@class]" mode="update_xml_step1" priority="2">
12270
12341
  <xsl:copy>
12271
12342
  <xsl:copy-of select="@*"/>
12272
12343
  <xsl:apply-templates mode="update_xml_step1"/>