metanorma-un 0.10.13 → 0.11.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 04e000256ab134b80a72f9a876d5b8b6864529306a476ceffd7c164dc4ba366e
4
- data.tar.gz: b8191bfffd99a65df9d3b56ddc4bc2db5f3820530ae56637a1b7f32a58b5840e
3
+ metadata.gz: 4bb7f5e0507e6121b00bb9c0a77de939bef65ffd3d0430abefb46a9755989f1e
4
+ data.tar.gz: 1fbf3cc1f9e13c7b349f6dc5964f005247f17a6df0cf016e6af1d35c29929df2
5
5
  SHA512:
6
- metadata.gz: b61fa9f4b6176a45223ad7b31ee0909be4dc08f6ad957eb6a7a1ebaeccc0768eb0b25bea1cd0594da11784f859d1c5f7d6ab425f8b05fd93dfd10b3f4ad20973
7
- data.tar.gz: 48ab9f757cca73b72fb187fa8b9f23148b3aef42a492785e4042caf67d6ad96a804890e3b2f1f585fd2d4f4afd1f67caedf87b446ccd53ff6f2f979f6d14a1dd
6
+ metadata.gz: 466ee743e3a9cfac771aa8f25419b9032e12f0de5a7141da4ed5f138b769ec1840f6fb0110c8dc5b80b3acbcc9ad489b4f00a4d363b4d4742e5b71f691511b43
7
+ data.tar.gz: 5a1175c0a0049a6e3c24bd3044297bd11506f9ebe3fb60b06e8a76e36449081cde0ea33219a30ec5a1a6373b4080e99db3b2492e137e63f4716ec244561626e7
@@ -7,6 +7,15 @@ module IsoDoc
7
7
  "//clause[parent::sections]"
8
8
  end
9
9
 
10
+ def norm_ref_xpath
11
+ "//null"
12
+ end
13
+
14
+ def bibliography_xpath
15
+ "//bibliography/clause[.//references] | " \
16
+ "//bibliography/references"
17
+ end
18
+
10
19
  def admonition_parse(node, out)
11
20
  name = node.at(ns("./name"))
12
21
  out.div **admonition_attrs(node) do |t|
@@ -18,7 +27,7 @@ module IsoDoc
18
27
  end
19
28
 
20
29
  def inline_header_title(out, _node, title)
21
- out.span **{ class: "zzMoveToFollowing" } do |s|
30
+ out.span class: "zzMoveToFollowing" do |s|
22
31
  title&.children&.each { |c2| parse(c2, s) }
23
32
  clausedelimspace(_node, out) if /\S/.match?(title&.text)
24
33
  end
@@ -32,6 +41,10 @@ module IsoDoc
32
41
  false
33
42
  end
34
43
 
44
+ def norm_ref(node, out)
45
+ bibliography(node, out)
46
+ end
47
+
35
48
  def convert_i18n_init1(docxml)
36
49
  super
37
50
  docxml.xpath(ns("//bibdata/language")).size > 1 and @lang = "en"
@@ -65,23 +65,6 @@ module IsoDoc
65
65
  end
66
66
  end
67
67
 
68
- def make_body3(body, docxml)
69
- body.div class: "main-section" do |div3|
70
- boilerplate docxml, div3
71
- front docxml, div3
72
- middle docxml, div3
73
- footnotes div3
74
- comments div3
75
- end
76
- end
77
-
78
- def middle(isoxml, out)
79
- middle_admonitions(isoxml, out)
80
- clause isoxml, out
81
- annex isoxml, out
82
- bibliography isoxml, out
83
- end
84
-
85
68
  def introduction(clause, out)
86
69
  page_break(out)
87
70
  out.div class: "Section3", id: clause["id"] do |div|
@@ -9,6 +9,8 @@ module IsoDoc
9
9
  @toc = options[:toc]
10
10
  end
11
11
 
12
+ def middle_title(docxml); end
13
+
12
14
  def note1(elem)
13
15
  return if elem.parent.name == "bibitem"
14
16
  return if elem["type"] == "title-footnote"
@@ -44,6 +46,8 @@ module IsoDoc
44
46
  super
45
47
  end
46
48
 
49
+ def move_norm_ref_to_sections(docxml); end
50
+
47
51
  include Init
48
52
  end
49
53
  end
@@ -1046,11 +1046,26 @@
1046
1046
  <xsl:value-of select="$font_extended"/><xsl:text>, </xsl:text>
1047
1047
  </xsl:if>
1048
1048
 
1049
- <xsl:value-of select="."/>
1049
+ <xsl:variable name="font_family" select="."/>
1050
1050
 
1051
- <xsl:if test="$additional_fonts != ''">
1052
- <xsl:text>, </xsl:text><xsl:value-of select="$additional_fonts"/>
1053
- </xsl:if>
1051
+ <xsl:choose>
1052
+ <xsl:when test="$additional_fonts = ''">
1053
+ <xsl:value-of select="$font_family"/>
1054
+ </xsl:when>
1055
+ <xsl:otherwise> <!-- $additional_fonts != '' -->
1056
+ <xsl:choose>
1057
+ <xsl:when test="contains($font_family, ',')">
1058
+ <xsl:value-of select="substring-before($font_family, ',')"/>
1059
+ <xsl:text>, </xsl:text><xsl:value-of select="$additional_fonts"/>
1060
+ <xsl:text>, </xsl:text><xsl:value-of select="substring-after($font_family, ',')"/>
1061
+ </xsl:when>
1062
+ <xsl:otherwise>
1063
+ <xsl:value-of select="$font_family"/>
1064
+ <xsl:text>, </xsl:text><xsl:value-of select="$additional_fonts"/>
1065
+ </xsl:otherwise>
1066
+ </xsl:choose>
1067
+ </xsl:otherwise>
1068
+ </xsl:choose>
1054
1069
  </xsl:attribute>
1055
1070
  </xsl:when>
1056
1071
  <xsl:otherwise>
@@ -3549,21 +3564,21 @@
3549
3564
 
3550
3565
  <xsl:template match="*[local-name()='table']/*[local-name()='note' or local-name() = 'example']" priority="2">
3551
3566
 
3552
- <fo:block xsl:use-attribute-sets="table-note-style">
3567
+ <fo:block xsl:use-attribute-sets="table-note-style">
3553
3568
 
3554
- <xsl:call-template name="refine_table-note-style"/>
3569
+ <xsl:call-template name="refine_table-note-style"/>
3555
3570
 
3556
- <!-- Table's note/example name (NOTE, for example) -->
3557
- <fo:inline xsl:use-attribute-sets="table-note-name-style">
3571
+ <!-- Table's note/example name (NOTE, for example) -->
3572
+ <fo:inline xsl:use-attribute-sets="table-note-name-style">
3558
3573
 
3559
- <xsl:call-template name="refine_table-note-name-style"/>
3574
+ <xsl:call-template name="refine_table-note-name-style"/>
3560
3575
 
3561
- <xsl:apply-templates select="*[local-name() = 'name']"/>
3576
+ <xsl:apply-templates select="*[local-name() = 'name']"/>
3562
3577
 
3563
- </fo:inline>
3578
+ </fo:inline>
3564
3579
 
3565
- <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
3566
- </fo:block>
3580
+ <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
3581
+ </fo:block>
3567
3582
 
3568
3583
  </xsl:template> <!-- table/note -->
3569
3584
 
@@ -4628,6 +4643,9 @@
4628
4643
  <!-- END Definition List -->
4629
4644
  <!-- ===================== -->
4630
4645
 
4646
+ <!-- default: ignore title in sections/p -->
4647
+ <xsl:template match="*[local-name() = 'sections']/*[local-name() = 'p'][starts-with(@class, 'zzSTDTitle')]" priority="3"/>
4648
+
4631
4649
  <!-- ========================= -->
4632
4650
  <!-- Rich text formatting -->
4633
4651
  <!-- ========================= -->
@@ -6685,8 +6703,12 @@
6685
6703
  <xsl:variable name="isAdded" select="../@added"/>
6686
6704
  <xsl:variable name="isDeleted" select="../@deleted"/>
6687
6705
  <xsl:choose>
6688
- <xsl:when test="ancestor::*[local-name() = 'title']">
6706
+ <xsl:when test="ancestor::*[local-name() = 'title'] or not(parent::*[local-name() = 'figure']) or parent::*[local-name() = 'p']">
6689
6707
  <fo:inline padding-left="1mm" padding-right="1mm">
6708
+ <xsl:if test="not(parent::*[local-name() = 'figure']) or parent::*[local-name() = 'p']">
6709
+ <xsl:attribute name="padding-left">0mm</xsl:attribute>
6710
+ <xsl:attribute name="padding-right">0mm</xsl:attribute>
6711
+ </xsl:if>
6690
6712
  <xsl:variable name="src">
6691
6713
  <xsl:call-template name="image_src"/>
6692
6714
  </xsl:variable>
@@ -6719,25 +6741,45 @@
6719
6741
  <fo:external-graphic src="{$src}" fox:alt-text="Image {@alt}" xsl:use-attribute-sets="image-graphic-style">
6720
6742
  <xsl:if test="not(@mimetype = 'image/svg+xml') and ../*[local-name() = 'name'] and not(ancestor::*[local-name() = 'table'])">
6721
6743
 
6722
- <xsl:variable name="img_src">
6723
- <xsl:choose>
6724
- <xsl:when test="not(starts-with(@src, 'data:'))"><xsl:value-of select="concat($basepath, @src)"/></xsl:when>
6725
- <xsl:otherwise><xsl:value-of select="@src"/></xsl:otherwise>
6726
- </xsl:choose>
6727
- </xsl:variable>
6744
+ <xsl:if test="@width != '' and @width != 'auto' and @width != 'text-width' and @width != 'full-page-width' and @width != 'narrow'">
6745
+ <xsl:attribute name="width">
6746
+ <xsl:value-of select="@width"/>
6747
+ </xsl:attribute>
6748
+ </xsl:if>
6728
6749
 
6729
- <xsl:variable name="image_width_effective">
6750
+ <xsl:if test="@height != '' and @height != 'auto'">
6751
+ <xsl:attribute name="height">
6752
+ <xsl:value-of select="@height"/>
6753
+ </xsl:attribute>
6754
+ </xsl:if>
6730
6755
 
6731
- <xsl:value-of select="$width_effective"/>
6756
+ <xsl:choose>
6757
+ <xsl:when test="@width != '' and @width != 'auto' and @height != '' and @height != 'auto'">
6758
+ <xsl:attribute name="scaling">non-uniform</xsl:attribute>
6759
+ </xsl:when>
6760
+ <xsl:otherwise>
6732
6761
 
6733
- </xsl:variable>
6762
+ <xsl:variable name="img_src">
6763
+ <xsl:choose>
6764
+ <xsl:when test="not(starts-with(@src, 'data:'))"><xsl:value-of select="concat($basepath, @src)"/></xsl:when>
6765
+ <xsl:otherwise><xsl:value-of select="@src"/></xsl:otherwise>
6766
+ </xsl:choose>
6767
+ </xsl:variable>
6734
6768
 
6735
- <xsl:variable name="scale" select="java:org.metanorma.fop.Util.getImageScale($img_src, $image_width_effective, $height_effective)"/>
6736
- <xsl:if test="number($scale) &lt; 100">
6769
+ <xsl:variable name="image_width_effective">
6737
6770
 
6738
- <xsl:attribute name="content-width"><xsl:value-of select="$scale * 0.985"/>%</xsl:attribute><!-- 0.985 due border around image -->
6771
+ <xsl:value-of select="$width_effective"/>
6739
6772
 
6740
- </xsl:if>
6773
+ </xsl:variable>
6774
+
6775
+ <xsl:variable name="scale" select="java:org.metanorma.fop.Util.getImageScale($img_src, $image_width_effective, $height_effective)"/>
6776
+ <xsl:if test="number($scale) &lt; 100">
6777
+
6778
+ <xsl:attribute name="content-width"><xsl:value-of select="$scale * 0.985"/>%</xsl:attribute><!-- 0.985 due border around image -->
6779
+
6780
+ </xsl:if>
6781
+ </xsl:otherwise>
6782
+ </xsl:choose>
6741
6783
 
6742
6784
  </xsl:if>
6743
6785
 
@@ -10380,7 +10422,7 @@
10380
10422
  <xsl:template match="*[local-name() = 'span']" mode="update_xml_step1">
10381
10423
  <xsl:apply-templates mode="update_xml_step1"/>
10382
10424
  </xsl:template>
10383
- <xsl:template match="*[local-name() = 'sourcecode']//*[local-name() = 'span'][@class]" mode="update_xml_step1" priority="2">
10425
+ <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">
10384
10426
  <xsl:copy>
10385
10427
  <xsl:copy-of select="@*"/>
10386
10428
  <xsl:apply-templates mode="update_xml_step1"/>
@@ -1046,11 +1046,26 @@
1046
1046
  <xsl:value-of select="$font_extended"/><xsl:text>, </xsl:text>
1047
1047
  </xsl:if>
1048
1048
 
1049
- <xsl:value-of select="."/>
1049
+ <xsl:variable name="font_family" select="."/>
1050
1050
 
1051
- <xsl:if test="$additional_fonts != ''">
1052
- <xsl:text>, </xsl:text><xsl:value-of select="$additional_fonts"/>
1053
- </xsl:if>
1051
+ <xsl:choose>
1052
+ <xsl:when test="$additional_fonts = ''">
1053
+ <xsl:value-of select="$font_family"/>
1054
+ </xsl:when>
1055
+ <xsl:otherwise> <!-- $additional_fonts != '' -->
1056
+ <xsl:choose>
1057
+ <xsl:when test="contains($font_family, ',')">
1058
+ <xsl:value-of select="substring-before($font_family, ',')"/>
1059
+ <xsl:text>, </xsl:text><xsl:value-of select="$additional_fonts"/>
1060
+ <xsl:text>, </xsl:text><xsl:value-of select="substring-after($font_family, ',')"/>
1061
+ </xsl:when>
1062
+ <xsl:otherwise>
1063
+ <xsl:value-of select="$font_family"/>
1064
+ <xsl:text>, </xsl:text><xsl:value-of select="$additional_fonts"/>
1065
+ </xsl:otherwise>
1066
+ </xsl:choose>
1067
+ </xsl:otherwise>
1068
+ </xsl:choose>
1054
1069
  </xsl:attribute>
1055
1070
  </xsl:when>
1056
1071
  <xsl:otherwise>
@@ -3549,21 +3564,21 @@
3549
3564
 
3550
3565
  <xsl:template match="*[local-name()='table']/*[local-name()='note' or local-name() = 'example']" priority="2">
3551
3566
 
3552
- <fo:block xsl:use-attribute-sets="table-note-style">
3567
+ <fo:block xsl:use-attribute-sets="table-note-style">
3553
3568
 
3554
- <xsl:call-template name="refine_table-note-style"/>
3569
+ <xsl:call-template name="refine_table-note-style"/>
3555
3570
 
3556
- <!-- Table's note/example name (NOTE, for example) -->
3557
- <fo:inline xsl:use-attribute-sets="table-note-name-style">
3571
+ <!-- Table's note/example name (NOTE, for example) -->
3572
+ <fo:inline xsl:use-attribute-sets="table-note-name-style">
3558
3573
 
3559
- <xsl:call-template name="refine_table-note-name-style"/>
3574
+ <xsl:call-template name="refine_table-note-name-style"/>
3560
3575
 
3561
- <xsl:apply-templates select="*[local-name() = 'name']"/>
3576
+ <xsl:apply-templates select="*[local-name() = 'name']"/>
3562
3577
 
3563
- </fo:inline>
3578
+ </fo:inline>
3564
3579
 
3565
- <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
3566
- </fo:block>
3580
+ <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
3581
+ </fo:block>
3567
3582
 
3568
3583
  </xsl:template> <!-- table/note -->
3569
3584
 
@@ -4628,6 +4643,9 @@
4628
4643
  <!-- END Definition List -->
4629
4644
  <!-- ===================== -->
4630
4645
 
4646
+ <!-- default: ignore title in sections/p -->
4647
+ <xsl:template match="*[local-name() = 'sections']/*[local-name() = 'p'][starts-with(@class, 'zzSTDTitle')]" priority="3"/>
4648
+
4631
4649
  <!-- ========================= -->
4632
4650
  <!-- Rich text formatting -->
4633
4651
  <!-- ========================= -->
@@ -6685,8 +6703,12 @@
6685
6703
  <xsl:variable name="isAdded" select="../@added"/>
6686
6704
  <xsl:variable name="isDeleted" select="../@deleted"/>
6687
6705
  <xsl:choose>
6688
- <xsl:when test="ancestor::*[local-name() = 'title']">
6706
+ <xsl:when test="ancestor::*[local-name() = 'title'] or not(parent::*[local-name() = 'figure']) or parent::*[local-name() = 'p']">
6689
6707
  <fo:inline padding-left="1mm" padding-right="1mm">
6708
+ <xsl:if test="not(parent::*[local-name() = 'figure']) or parent::*[local-name() = 'p']">
6709
+ <xsl:attribute name="padding-left">0mm</xsl:attribute>
6710
+ <xsl:attribute name="padding-right">0mm</xsl:attribute>
6711
+ </xsl:if>
6690
6712
  <xsl:variable name="src">
6691
6713
  <xsl:call-template name="image_src"/>
6692
6714
  </xsl:variable>
@@ -6719,25 +6741,45 @@
6719
6741
  <fo:external-graphic src="{$src}" fox:alt-text="Image {@alt}" xsl:use-attribute-sets="image-graphic-style">
6720
6742
  <xsl:if test="not(@mimetype = 'image/svg+xml') and ../*[local-name() = 'name'] and not(ancestor::*[local-name() = 'table'])">
6721
6743
 
6722
- <xsl:variable name="img_src">
6723
- <xsl:choose>
6724
- <xsl:when test="not(starts-with(@src, 'data:'))"><xsl:value-of select="concat($basepath, @src)"/></xsl:when>
6725
- <xsl:otherwise><xsl:value-of select="@src"/></xsl:otherwise>
6726
- </xsl:choose>
6727
- </xsl:variable>
6744
+ <xsl:if test="@width != '' and @width != 'auto' and @width != 'text-width' and @width != 'full-page-width' and @width != 'narrow'">
6745
+ <xsl:attribute name="width">
6746
+ <xsl:value-of select="@width"/>
6747
+ </xsl:attribute>
6748
+ </xsl:if>
6728
6749
 
6729
- <xsl:variable name="image_width_effective">
6750
+ <xsl:if test="@height != '' and @height != 'auto'">
6751
+ <xsl:attribute name="height">
6752
+ <xsl:value-of select="@height"/>
6753
+ </xsl:attribute>
6754
+ </xsl:if>
6730
6755
 
6731
- <xsl:value-of select="$width_effective"/>
6756
+ <xsl:choose>
6757
+ <xsl:when test="@width != '' and @width != 'auto' and @height != '' and @height != 'auto'">
6758
+ <xsl:attribute name="scaling">non-uniform</xsl:attribute>
6759
+ </xsl:when>
6760
+ <xsl:otherwise>
6732
6761
 
6733
- </xsl:variable>
6762
+ <xsl:variable name="img_src">
6763
+ <xsl:choose>
6764
+ <xsl:when test="not(starts-with(@src, 'data:'))"><xsl:value-of select="concat($basepath, @src)"/></xsl:when>
6765
+ <xsl:otherwise><xsl:value-of select="@src"/></xsl:otherwise>
6766
+ </xsl:choose>
6767
+ </xsl:variable>
6734
6768
 
6735
- <xsl:variable name="scale" select="java:org.metanorma.fop.Util.getImageScale($img_src, $image_width_effective, $height_effective)"/>
6736
- <xsl:if test="number($scale) &lt; 100">
6769
+ <xsl:variable name="image_width_effective">
6737
6770
 
6738
- <xsl:attribute name="content-width"><xsl:value-of select="$scale * 0.985"/>%</xsl:attribute><!-- 0.985 due border around image -->
6771
+ <xsl:value-of select="$width_effective"/>
6739
6772
 
6740
- </xsl:if>
6773
+ </xsl:variable>
6774
+
6775
+ <xsl:variable name="scale" select="java:org.metanorma.fop.Util.getImageScale($img_src, $image_width_effective, $height_effective)"/>
6776
+ <xsl:if test="number($scale) &lt; 100">
6777
+
6778
+ <xsl:attribute name="content-width"><xsl:value-of select="$scale * 0.985"/>%</xsl:attribute><!-- 0.985 due border around image -->
6779
+
6780
+ </xsl:if>
6781
+ </xsl:otherwise>
6782
+ </xsl:choose>
6741
6783
 
6742
6784
  </xsl:if>
6743
6785
 
@@ -10380,7 +10422,7 @@
10380
10422
  <xsl:template match="*[local-name() = 'span']" mode="update_xml_step1">
10381
10423
  <xsl:apply-templates mode="update_xml_step1"/>
10382
10424
  </xsl:template>
10383
- <xsl:template match="*[local-name() = 'sourcecode']//*[local-name() = 'span'][@class]" mode="update_xml_step1" priority="2">
10425
+ <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">
10384
10426
  <xsl:copy>
10385
10427
  <xsl:copy-of select="@*"/>
10386
10428
  <xsl:apply-templates mode="update_xml_step1"/>
@@ -1152,11 +1152,26 @@
1152
1152
  <xsl:value-of select="$font_extended"/><xsl:text>, </xsl:text>
1153
1153
  </xsl:if>
1154
1154
 
1155
- <xsl:value-of select="."/>
1155
+ <xsl:variable name="font_family" select="."/>
1156
1156
 
1157
- <xsl:if test="$additional_fonts != ''">
1158
- <xsl:text>, </xsl:text><xsl:value-of select="$additional_fonts"/>
1159
- </xsl:if>
1157
+ <xsl:choose>
1158
+ <xsl:when test="$additional_fonts = ''">
1159
+ <xsl:value-of select="$font_family"/>
1160
+ </xsl:when>
1161
+ <xsl:otherwise> <!-- $additional_fonts != '' -->
1162
+ <xsl:choose>
1163
+ <xsl:when test="contains($font_family, ',')">
1164
+ <xsl:value-of select="substring-before($font_family, ',')"/>
1165
+ <xsl:text>, </xsl:text><xsl:value-of select="$additional_fonts"/>
1166
+ <xsl:text>, </xsl:text><xsl:value-of select="substring-after($font_family, ',')"/>
1167
+ </xsl:when>
1168
+ <xsl:otherwise>
1169
+ <xsl:value-of select="$font_family"/>
1170
+ <xsl:text>, </xsl:text><xsl:value-of select="$additional_fonts"/>
1171
+ </xsl:otherwise>
1172
+ </xsl:choose>
1173
+ </xsl:otherwise>
1174
+ </xsl:choose>
1160
1175
  </xsl:attribute>
1161
1176
  </xsl:when>
1162
1177
  <xsl:otherwise>
@@ -3676,21 +3691,21 @@
3676
3691
 
3677
3692
  <xsl:template match="*[local-name()='table']/*[local-name()='note' or local-name() = 'example']" priority="2">
3678
3693
 
3679
- <fo:block xsl:use-attribute-sets="table-note-style">
3694
+ <fo:block xsl:use-attribute-sets="table-note-style">
3680
3695
 
3681
- <xsl:call-template name="refine_table-note-style"/>
3696
+ <xsl:call-template name="refine_table-note-style"/>
3682
3697
 
3683
- <!-- Table's note/example name (NOTE, for example) -->
3684
- <fo:inline xsl:use-attribute-sets="table-note-name-style">
3698
+ <!-- Table's note/example name (NOTE, for example) -->
3699
+ <fo:inline xsl:use-attribute-sets="table-note-name-style">
3685
3700
 
3686
- <xsl:call-template name="refine_table-note-name-style"/>
3701
+ <xsl:call-template name="refine_table-note-name-style"/>
3687
3702
 
3688
- <xsl:apply-templates select="*[local-name() = 'name']"/>
3703
+ <xsl:apply-templates select="*[local-name() = 'name']"/>
3689
3704
 
3690
- </fo:inline>
3705
+ </fo:inline>
3691
3706
 
3692
- <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
3693
- </fo:block>
3707
+ <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
3708
+ </fo:block>
3694
3709
 
3695
3710
  </xsl:template> <!-- table/note -->
3696
3711
 
@@ -4755,6 +4770,9 @@
4755
4770
  <!-- END Definition List -->
4756
4771
  <!-- ===================== -->
4757
4772
 
4773
+ <!-- default: ignore title in sections/p -->
4774
+ <xsl:template match="*[local-name() = 'sections']/*[local-name() = 'p'][starts-with(@class, 'zzSTDTitle')]" priority="3"/>
4775
+
4758
4776
  <!-- ========================= -->
4759
4777
  <!-- Rich text formatting -->
4760
4778
  <!-- ========================= -->
@@ -6812,8 +6830,12 @@
6812
6830
  <xsl:variable name="isAdded" select="../@added"/>
6813
6831
  <xsl:variable name="isDeleted" select="../@deleted"/>
6814
6832
  <xsl:choose>
6815
- <xsl:when test="ancestor::*[local-name() = 'title']">
6833
+ <xsl:when test="ancestor::*[local-name() = 'title'] or not(parent::*[local-name() = 'figure']) or parent::*[local-name() = 'p']">
6816
6834
  <fo:inline padding-left="1mm" padding-right="1mm">
6835
+ <xsl:if test="not(parent::*[local-name() = 'figure']) or parent::*[local-name() = 'p']">
6836
+ <xsl:attribute name="padding-left">0mm</xsl:attribute>
6837
+ <xsl:attribute name="padding-right">0mm</xsl:attribute>
6838
+ </xsl:if>
6817
6839
  <xsl:variable name="src">
6818
6840
  <xsl:call-template name="image_src"/>
6819
6841
  </xsl:variable>
@@ -6846,25 +6868,45 @@
6846
6868
  <fo:external-graphic src="{$src}" fox:alt-text="Image {@alt}" xsl:use-attribute-sets="image-graphic-style">
6847
6869
  <xsl:if test="not(@mimetype = 'image/svg+xml') and ../*[local-name() = 'name'] and not(ancestor::*[local-name() = 'table'])">
6848
6870
 
6849
- <xsl:variable name="img_src">
6850
- <xsl:choose>
6851
- <xsl:when test="not(starts-with(@src, 'data:'))"><xsl:value-of select="concat($basepath, @src)"/></xsl:when>
6852
- <xsl:otherwise><xsl:value-of select="@src"/></xsl:otherwise>
6853
- </xsl:choose>
6854
- </xsl:variable>
6871
+ <xsl:if test="@width != '' and @width != 'auto' and @width != 'text-width' and @width != 'full-page-width' and @width != 'narrow'">
6872
+ <xsl:attribute name="width">
6873
+ <xsl:value-of select="@width"/>
6874
+ </xsl:attribute>
6875
+ </xsl:if>
6855
6876
 
6856
- <xsl:variable name="image_width_effective">
6877
+ <xsl:if test="@height != '' and @height != 'auto'">
6878
+ <xsl:attribute name="height">
6879
+ <xsl:value-of select="@height"/>
6880
+ </xsl:attribute>
6881
+ </xsl:if>
6857
6882
 
6858
- <xsl:value-of select="$width_effective"/>
6883
+ <xsl:choose>
6884
+ <xsl:when test="@width != '' and @width != 'auto' and @height != '' and @height != 'auto'">
6885
+ <xsl:attribute name="scaling">non-uniform</xsl:attribute>
6886
+ </xsl:when>
6887
+ <xsl:otherwise>
6859
6888
 
6860
- </xsl:variable>
6889
+ <xsl:variable name="img_src">
6890
+ <xsl:choose>
6891
+ <xsl:when test="not(starts-with(@src, 'data:'))"><xsl:value-of select="concat($basepath, @src)"/></xsl:when>
6892
+ <xsl:otherwise><xsl:value-of select="@src"/></xsl:otherwise>
6893
+ </xsl:choose>
6894
+ </xsl:variable>
6861
6895
 
6862
- <xsl:variable name="scale" select="java:org.metanorma.fop.Util.getImageScale($img_src, $image_width_effective, $height_effective)"/>
6863
- <xsl:if test="number($scale) &lt; 100">
6896
+ <xsl:variable name="image_width_effective">
6864
6897
 
6865
- <xsl:attribute name="content-width"><xsl:value-of select="$scale"/>%</xsl:attribute>
6898
+ <xsl:value-of select="$width_effective"/>
6866
6899
 
6867
- </xsl:if>
6900
+ </xsl:variable>
6901
+
6902
+ <xsl:variable name="scale" select="java:org.metanorma.fop.Util.getImageScale($img_src, $image_width_effective, $height_effective)"/>
6903
+ <xsl:if test="number($scale) &lt; 100">
6904
+
6905
+ <xsl:attribute name="content-width"><xsl:value-of select="$scale"/>%</xsl:attribute>
6906
+
6907
+ </xsl:if>
6908
+ </xsl:otherwise>
6909
+ </xsl:choose>
6868
6910
 
6869
6911
  </xsl:if>
6870
6912
 
@@ -10508,7 +10550,7 @@
10508
10550
  <xsl:template match="*[local-name() = 'span']" mode="update_xml_step1">
10509
10551
  <xsl:apply-templates mode="update_xml_step1"/>
10510
10552
  </xsl:template>
10511
- <xsl:template match="*[local-name() = 'sourcecode']//*[local-name() = 'span'][@class]" mode="update_xml_step1" priority="2">
10553
+ <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">
10512
10554
  <xsl:copy>
10513
10555
  <xsl:copy-of select="@*"/>
10514
10556
  <xsl:apply-templates mode="update_xml_step1"/>
@@ -73,34 +73,21 @@ module IsoDoc
73
73
  end
74
74
  end
75
75
 
76
- def make_body2(body, docxml)
77
- body.div class: "WordSection2" do |div2|
78
- info docxml, div2
79
- boilerplate docxml, div2
80
- front docxml, div2
81
- div2.p { |p| p << "&#xa0;" } # placeholder
82
- end
83
- section_break(body)
84
- end
85
-
86
- ENDLINE = <<~END.freeze
76
+ ENDLINE = <<~ENDLINE.freeze
87
77
  <v:line
88
78
  alt="" style='position:absolute;left:0;text-align:left;z-index:251662848;
89
79
  mso-wrap-edited:f;mso-width-percent:0;mso-height-percent:0;
90
80
  mso-width-percent:0;mso-height-percent:0'
91
81
  from="6.375cm,20.95pt" to="10.625cm,20.95pt"
92
82
  strokeweight="1.5pt"/>
93
- END
83
+ ENDLINE
94
84
 
95
85
  def end_line(_isoxml, out)
96
86
  out.parent.add_child(ENDLINE)
97
87
  end
98
88
 
99
- def middle(isoxml, out)
100
- middle_admonitions(isoxml, out)
101
- clause isoxml, out
102
- annex isoxml, out
103
- bibliography isoxml, out
89
+ def make_body3(out, isoxml)
90
+ super
104
91
  end_line(isoxml, out)
105
92
  end
106
93
 
@@ -108,7 +95,7 @@ module IsoDoc
108
95
  out.div class: "Section3", id: clause["id"] do |div|
109
96
  page_break(out)
110
97
  div.p(class: "IntroTitle") do |h1|
111
- clause&.at(ns("./title"))&.children&.each { |n| parse(n, h1) }
98
+ clause.at(ns("./title"))&.children&.each { |n| parse(n, h1) }
112
99
  end
113
100
  clause.elements.each do |e|
114
101
  parse(e, div) unless e.name == "title"
@@ -120,7 +107,7 @@ module IsoDoc
120
107
  out.div **attr_code(id: clause["id"]) do |s|
121
108
  page_break(out)
122
109
  s.p(class: "ForewordTitle") do |h1|
123
- clause&.at(ns("./title"))&.children&.each { |n| parse(n, h1) }
110
+ clause.at(ns("./title"))&.children&.each { |n| parse(n, h1) }
124
111
  end
125
112
  clause.elements.each { |e| parse(e, s) unless e.name == "title" }
126
113
  end
@@ -137,7 +124,7 @@ module IsoDoc
137
124
  abstract.parent = (abstractbox || preface_container) if abstract &&
138
125
  (abstractbox || preface_container)
139
126
  abstractbox and abstract&.xpath(".//p/br")&.each do |a|
140
- a.parent.remove if /page-break-before:always/.match?(a["style"])
127
+ a.parent.remove if a["style"].include?("page-break-before:always")
141
128
  end
142
129
  docxml&.at("//p[@class = 'AbstractTitle']")&.remove if abstractbox
143
130
  foreword.parent = preface_container if foreword && preface_container
@@ -157,7 +144,7 @@ module IsoDoc
157
144
  out.div **attr_code(id: clause["id"]) do |s|
158
145
  page_break(out)
159
146
  s.p(class: "AbstractTitle") do |h1|
160
- clause&.at(ns("./title"))&.children&.each { |n| parse(n, h1) }
147
+ clause.at(ns("./title"))&.children&.each { |n| parse(n, h1) }
161
148
  end
162
149
  clause.elements.each { |e| parse(e, s) unless e.name == "title" }
163
150
  end
@@ -167,7 +154,7 @@ module IsoDoc
167
154
  super
168
155
  a = docxml.at("//div[@id = 'boilerplate-ECEhdr']") and
169
156
  a["class"] = "boilerplate-ECEhdr"
170
- docxml&.at("//div[@class = 'authority']")&.remove
157
+ docxml.at("//div[@class = 'authority']")&.remove
171
158
  end
172
159
 
173
160
  include BaseConvert
@@ -3,59 +3,36 @@ require "roman-numerals"
3
3
  module IsoDoc
4
4
  module UN
5
5
  class Xref < IsoDoc::Xref
6
- def initial_anchor_names(doc)
7
- if @parse_settings.empty? || @parse_settings[:clauses]
8
- preface_names(doc.at(ns("//preface/abstract")))
9
- preface_names(doc.at(ns("//foreword")))
10
- preface_names(doc.at(ns("//introduction")))
11
- doc.xpath(ns("//preface/clause")).each do |c|
12
- preface_names(c)
13
- end
14
- preface_names(doc.at(ns("//acknowledgements")))
15
- clause_names(doc, 0)
16
- end
17
- if @parse_settings.empty?
18
- sequential_asset_names(
19
- doc.xpath(ns("//preface/abstract | //foreword | //introduction | "\
20
- "//preface/clause | //acknowledgements")),
21
- )
22
- middle_section_asset_names(doc)
23
- termnote_anchor_names(doc)
24
- termexample_anchor_names(doc)
25
- end
6
+ def clause_order_main(_docxml)
7
+ [{ path: "//sections/clause | //sections/terms | //sections/definitions", multi: true }]
26
8
  end
27
9
 
28
10
  def asset_anchor_names(doc)
29
11
  super
30
12
  @parse_settings.empty? or return
31
13
  sequential_asset_names(
32
- doc.xpath(ns("//preface/abstract | //foreword | //introduction | "\
14
+ doc.xpath(ns("//preface/abstract | //foreword | //introduction | " \
33
15
  "//preface/clause | //acknowledgements")),
34
16
  )
35
17
  end
36
18
 
37
- def clause_names(docxml, _sect_num)
38
- q = "//clause[parent::sections]"
19
+ def main_anchor_names(xml)
39
20
  @paranumber = 0
40
- i = 0
41
- docxml.xpath(ns(q)).each do |c|
42
- section_names(c, i, 1)
43
- i += 1
44
- end
21
+ super
45
22
  end
46
23
 
47
24
  def levelnumber(num, lvl)
48
25
  case lvl % 3
49
- when 1 then RomanNumerals.to_roman(num)
50
- when 2 then ("A".ord + num - 1).chr
26
+ when 1 then RomanNumerals.to_roman(num.to_i)
27
+ when 2 then ("A".ord + num.to_i - 1).chr
51
28
  when 0 then num.to_s
52
29
  end
53
30
  end
54
31
 
55
32
  def annex_levelnum(num, lvl)
56
33
  case lvl % 3
57
- when 0 then RomanNumerals.to_roman(num)
58
- when 1 then ("A".ord + num - 1).chr
34
+ when 0 then RomanNumerals.to_roman(num.to_i)
35
+ when 1 then ("A".ord + num.to_i - 1).chr
59
36
  when 2 then num.to_s
60
37
  end
61
38
  end
@@ -70,6 +47,7 @@ module IsoDoc
70
47
  end
71
48
 
72
49
  def label_leaf_section(clause, lvl)
50
+ @paranumber.nil? and @paranumber = 0
73
51
  @paranumber += 1
74
52
  @anchors[clause["id"]] =
75
53
  { label: @paranumber.to_s, elem: @labels["paragraph"],
@@ -86,11 +64,9 @@ module IsoDoc
86
64
  end
87
65
 
88
66
  def section_names(clause, num, lvl)
89
- return num if clause.nil?
90
-
67
+ clause.nil? and return num
91
68
  leaf_section?(clause) and label_leaf_section(clause, lvl) and return
92
- num = num + 1
93
- lbl = levelnumber(num, 1)
69
+ lbl = levelnumber(num.increment(clause).print, 1)
94
70
  @anchors[clause["id"]] = { label: lbl, level: lvl, type: "clause",
95
71
  elem: @labels["clause"],
96
72
  xref: l10n("#{@labels['clause']} #{lbl}") }
@@ -116,6 +92,16 @@ module IsoDoc
116
92
  end
117
93
  end
118
94
 
95
+ def annex_anchor_names(xml)
96
+ i = ::IsoDoc::XrefGen::Counter.new
97
+ clause_order_annex(xml).each do |a|
98
+ xml.xpath(ns(a[:path])).each do |c|
99
+ annex_names(c, i.increment(c).print)
100
+ a[:multi] or break
101
+ end
102
+ end
103
+ end
104
+
119
105
  def annex_name_lbl(_clause, num)
120
106
  l10n("<strong>#{@labels['annex']} #{num}</strong>")
121
107
  end
@@ -130,7 +116,9 @@ module IsoDoc
130
116
  xref: "#{@labels['annex']} #{num}" }
131
117
  end
132
118
 
133
- def annex_names(clause, num)
119
+ def annex_names(clause, number)
120
+ @paranumber = 0
121
+ num = annex_levelnum(number, 0)
134
122
  hierarchical_asset_names(clause, num)
135
123
  leaf_section?(clause) and
136
124
  label_annex_leaf_section(clause, num, 1) and return
@@ -141,8 +129,7 @@ module IsoDoc
141
129
  else
142
130
  i = 1
143
131
  clause.xpath(ns(SUBCLAUSES)).each do |c|
144
- next if c["unnumbered"] == "true"
145
-
132
+ c["unnumbered"] == "true" and next
146
133
  annex_names1(c, "#{num}.#{annex_levelnum(i, 2)}", 2)
147
134
  i += 1 if !leaf_section?(c)
148
135
  end
@@ -157,32 +144,24 @@ module IsoDoc
157
144
  level: level, type: "clause", elem: @labels["annex"] }
158
145
  i = 1
159
146
  clause.xpath(ns("./clause | ./references")).each do |c|
160
- next if c["unnumbered"] == "true"
161
-
147
+ c["unnumbered"] == "true" and next
162
148
  annex_names1(c, "#{num}.#{annex_levelnum(i, level + 1)}", level + 1)
163
149
  i += 1 if !leaf_section?(c)
164
150
  end
165
151
  end
166
152
 
167
- def back_anchor_names(docxml)
168
- docxml.xpath(ns("//annex")).each_with_index do |c, i|
169
- @paranumber = 0
170
- annex_names(c, RomanNumerals.to_roman(i + 1))
171
- end
172
- docxml.xpath(ns("//bibliography/clause |"\
173
- "//bibliography/references")).each do |b|
174
- preface_names(b)
175
- end
176
- docxml.xpath(ns("//bibitem[not(ancestor::bibitem)]")).each do |ref|
177
- reference_names(ref)
178
- end
153
+ def clause_order_back(_docxml)
154
+ [
155
+ { path: "//bibliography/references | //bibliography/clause",
156
+ multi: true },
157
+ { path: "//indexsect", multi: true },
158
+ { path: "//colophon/*", multi: true },
159
+ ]
179
160
  end
180
161
 
181
162
  def sequential_admonition_names(clause)
182
163
  i = 0
183
- clause.xpath(ns(".//admonition")).each do |t|
184
- next if t["id"].nil? || t["id"].empty?
185
-
164
+ clause.xpath(ns(".//admonition")).noblank.each do |t|
186
165
  i += 1 unless t["unnumbered"] == "true"
187
166
  @anchors[t["id"]] = anchor_struct(i.to_s, nil, @labels["admonition"],
188
167
  "box", t["unnumbered"])
@@ -191,9 +170,7 @@ module IsoDoc
191
170
 
192
171
  def hierarchical_admonition_names(clause, num)
193
172
  i = 0
194
- clause.xpath(ns(".//admonition")).each do |t|
195
- next if t["id"].nil? || t["id"].empty?
196
-
173
+ clause.xpath(ns(".//admonition")).noblank.each do |t|
197
174
  i += 1 unless t["unnumbered"] == "true"
198
175
  @anchors[t["id"]] =
199
176
  anchor_struct("#{num}.#{i}", nil, @labels["admonition"], "box",
@@ -17,7 +17,7 @@
17
17
  these elements; we just want one namespace for any child grammars
18
18
  of this.
19
19
  -->
20
- <!-- VERSION v1.2.2 -->
20
+ <!-- VERSION v1.2.4 -->
21
21
  <grammar xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
22
22
  <include href="reqt.rng"/>
23
23
  <include href="basicdoc.rng">
@@ -192,9 +192,11 @@
192
192
  </attribute>
193
193
  </optional>
194
194
  <attribute name="citeas"/>
195
- <attribute name="type">
196
- <ref name="ReferenceFormat"/>
197
- </attribute>
195
+ <optional>
196
+ <attribute name="type">
197
+ <ref name="ReferenceFormat"/>
198
+ </attribute>
199
+ </optional>
198
200
  <optional>
199
201
  <attribute name="alt"/>
200
202
  </optional>
@@ -836,6 +838,26 @@
836
838
  <ref name="paragraph"/>
837
839
  </element>
838
840
  </define>
841
+ <define name="stem">
842
+ <element name="stem">
843
+ <attribute name="type">
844
+ <choice>
845
+ <value>MathML</value>
846
+ <value>AsciiMath</value>
847
+ <value>LatexMath</value>
848
+ </choice>
849
+ </attribute>
850
+ <attribute name="block">
851
+ <data type="boolean"/>
852
+ </attribute>
853
+ <oneOrMore>
854
+ <choice>
855
+ <text/>
856
+ <ref name="AnyElement"/>
857
+ </choice>
858
+ </oneOrMore>
859
+ </element>
860
+ </define>
839
861
  <define name="em">
840
862
  <element name="em">
841
863
  <zeroOrMore>
@@ -2046,6 +2068,9 @@
2046
2068
  </define>
2047
2069
  <define name="termdefinition">
2048
2070
  <element name="definition">
2071
+ <optional>
2072
+ <attribute name="type"/>
2073
+ </optional>
2049
2074
  <choice>
2050
2075
  <ref name="verbaldefinition"/>
2051
2076
  <ref name="nonverbalrep"/>
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module UN
3
- VERSION = "0.10.13".freeze
3
+ VERSION = "0.11.1".freeze
4
4
  end
5
5
  end
data/metanorma-un.gemspec CHANGED
@@ -31,7 +31,7 @@ Gem::Specification.new do |spec|
31
31
  spec.add_dependency "roman-numerals"
32
32
  spec.add_dependency "twitter_cldr"
33
33
 
34
- spec.add_dependency "metanorma-standoc", "~> 2.4.2"
34
+ spec.add_dependency "metanorma-standoc", "~> 2.5.4"
35
35
 
36
36
  spec.add_development_dependency "debug"
37
37
  spec.add_development_dependency "equivalent-xml", "~> 0.6"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-un
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.13
4
+ version: 0.11.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-07-24 00:00:00.000000000 Z
11
+ date: 2023-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: iso-639
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 2.4.2
61
+ version: 2.5.4
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 2.4.2
68
+ version: 2.5.4
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: debug
71
71
  requirement: !ruby/object:Gem::Requirement