metanorma-iso 2.4.8 → 2.5.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -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"/>
@@ -11,7 +11,7 @@ module IsoDoc
11
11
  class PresentationXMLConvert < IsoDoc::PresentationXMLConvert
12
12
  def convert1(docxml, filename, dir)
13
13
  @iso_class = instance_of?(IsoDoc::Iso::PresentationXMLConvert)
14
- if amd(docxml)
14
+ if amd?(docxml)
15
15
  @oldsuppressheadingnumbers = @suppressheadingnumbers
16
16
  @suppressheadingnumbers = true
17
17
  end
@@ -38,12 +38,12 @@ module IsoDoc
38
38
  end
39
39
 
40
40
  def annex(isoxml)
41
- amd(isoxml) and @suppressheadingnumbers = @oldsuppressheadingnumbers
41
+ amd?(isoxml) and @suppressheadingnumbers = @oldsuppressheadingnumbers
42
42
  super
43
43
  isoxml.xpath(ns("//annex//clause | //annex//appendix")).each do |f|
44
44
  clause1(f)
45
45
  end
46
- amd(isoxml) and @suppressheadingnumbers = true
46
+ amd?(isoxml) and @suppressheadingnumbers = true
47
47
  end
48
48
 
49
49
  def figure1(node)
@@ -87,23 +87,25 @@ module IsoDoc
87
87
  end
88
88
  end
89
89
 
90
- # we're assuming terms and clauses in the right place for display,
91
- # to cope with multiple terms sections
92
- def display_order(docxml)
93
- i = 0
94
- i = display_order_xpath(docxml, "//preface/*", i)
95
- i = display_order_at(docxml, "//clause[@type = 'scope']", i)
96
- i = display_order_at(docxml, @xrefs.klass.norm_ref_xpath, i)
97
- i = display_order_xpath(docxml,
98
- "//sections/clause[not(@type = 'scope')] | " \
99
- "//sections/terms | //sections/definitions", i)
100
- i = display_order_xpath(docxml, "//annex", i)
101
- i = display_order_xpath(docxml, @xrefs.klass.bibliography_xpath, i)
102
- display_order_xpath(docxml, "//indexsect", i)
103
- end
104
-
105
90
  def admonition1(elem)
106
91
  super
92
+ admonition_inline_name(elem)
93
+ admonition_outside_clauses(elem)
94
+ end
95
+
96
+ def admonition_outside_clauses(elem)
97
+ elem.parent.name == "sections" or return
98
+ wrap_in_bold(elem)
99
+ end
100
+
101
+ def wrap_in_bold(cell)
102
+ cell.text? && cell.text.strip.empty? and return
103
+ cell.text? and cell.swap("<strong>#{cell.to_xml}</strong>")
104
+ %w(strong fn).include?(cell.name) and return
105
+ cell.children.each { |p| wrap_in_bold(p) }
106
+ end
107
+
108
+ def admonition_inline_name(elem)
107
109
  n = elem.at(ns("./name")) or return
108
110
  if (p = n.next_element) && p&.name == "p"
109
111
  p.children.first.previous = admonition_name(to_xml(n.remove.children))
@@ -161,6 +163,45 @@ module IsoDoc
161
163
  super
162
164
  end
163
165
 
166
+ def middle_title(docxml)
167
+ @meta.get[:doctitlemain].nil? || @meta.get[:doctitlemain].empty? and
168
+ return
169
+ s = docxml.at(ns("//sections")) or return
170
+ ret = "#{middle_title_main}#{middle_title_amd}"
171
+ s.children.first.previous = ret
172
+ end
173
+
174
+ def middle_title_main
175
+ ret = "<span class='boldtitle'>#{@meta.get[:doctitleintro]}"
176
+ ret += " &#x2014; " if @meta.get[:doctitleintro] && @meta.get[:doctitlemain]
177
+ ret += @meta.get[:doctitlemain]
178
+ ret += " &#x2014; " if @meta.get[:doctitlemain] && @meta.get[:doctitlepart]
179
+ ret += "</span>"
180
+ if a = @meta.get[:doctitlepart]
181
+ b = @meta.get[:doctitlepartlabel] and ret += "<span class='nonboldtitle'>#{b}:</span> "
182
+ ret += "<span class='boldtitle'>#{a}</span>"
183
+ end
184
+ "<p class='zzSTDTitle1'>#{ret}</p>"
185
+ end
186
+
187
+ def middle_title_amd
188
+ ret = ""
189
+ if a = @meta.get[:doctitleamdlabel]
190
+ ret += "<p class='zzSTDTitle2'>#{a}"
191
+ a = @meta.get[:doctitleamd] and ret += ": #{a}"
192
+ ret += "</p>"
193
+ end
194
+ a = @meta.get[:doctitlecorrlabel] and
195
+ ret += "<p class='zzSTDTitle2'>#{a}</p>"
196
+ ret
197
+ end
198
+
199
+ def move_norm_ref_to_sections(docxml)
200
+ if amd?(docxml)
201
+ else super
202
+ end
203
+ end
204
+
164
205
  include Init
165
206
  end
166
207
  end
@@ -1,52 +1,12 @@
1
1
  module IsoDoc
2
2
  module Iso
3
3
  module BaseConvert
4
- def middle_title(_isoxml, out)
5
- middle_title_main(out)
6
- middle_title_amd(out)
7
- end
8
-
9
- def middle_title_main(out)
10
- out.p(class: "zzSTDTitle1") do |p|
11
- p << @meta.get[:doctitleintro]
12
- p << " &#x2014; " if @meta.get[:doctitleintro] && @meta.get[:doctitlemain]
13
- p << @meta.get[:doctitlemain]
14
- p << " &#x2014; " if @meta.get[:doctitlemain] && @meta.get[:doctitlepart]
15
- end
16
- a = @meta.get[:doctitlepart] and out.p(class: "zzSTDTitle2") do |p|
17
- b = @meta.get[:doctitlepartlabel] and p << "#{b}: "
18
- p << "<br/><b>#{a}</b>"
19
- end
20
- end
21
-
22
- def middle_title_amd(out)
23
- a = @meta.get[:doctitleamdlabel] and out.p(class: "zzSTDTitle2") do |p|
24
- p << a
25
- a = @meta.get[:doctitleamd] and p << ": #{a}"
26
- end
27
- a = @meta.get[:doctitlecorrlabel] and out.p(class: "zzSTDTitle2") do |p|
28
- p << a
29
- end
30
- end
31
-
32
- def annex(isoxml, out)
33
- amd(isoxml) and @suppressheadingnumbers = @oldsuppressheadingnumbers
4
+ def annex(node, out)
5
+ amd?(node.document) and
6
+ @suppressheadingnumbers = @oldsuppressheadingnumbers
34
7
  super
35
- amd(isoxml) and @suppressheadingnumbers = true
36
- end
37
-
38
- =begin
39
- def introduction(clause, out)
40
- title_attr = { class: "IntroTitle" }
41
- page_break(out)
42
- out.div class: "Section3", id: clause["id"] do |div|
43
- clause_name(clause, clause.at(ns("./title")), div, title_attr)
44
- clause.elements.each do |e|
45
- parse(e, div) unless e.name == "title"
46
- end
47
- end
8
+ amd?(node.document) and @suppressheadingnumbers = true
48
9
  end
49
- =end
50
10
 
51
11
  def foreword(clause, out)
52
12
  @foreword = true
@@ -70,8 +70,8 @@ module IsoDoc
70
70
  make_body1(body, docxml)
71
71
  make_body2(body, docxml)
72
72
  make_body3(body, docxml)
73
- indexsect(docxml, body)
74
- colophon(body, docxml)
73
+ indexsect_section(docxml, body)
74
+ colophon_section(docxml, body)
75
75
  end
76
76
  end
77
77
 
@@ -80,23 +80,31 @@ module IsoDoc
80
80
  "mso-break-type:section-break"
81
81
  end
82
82
 
83
- def colophon(body, _docxml)
83
+ MAIN_ELEMENTS =
84
+ "//sections/*[@displayorder] | //annex[@displayorder] | " \
85
+ "//bibliography/*[@displayorder]".freeze
86
+
87
+ def colophon_section(_isoxml, out)
84
88
  stage = @meta.get[:stage_int]
85
89
  return if !stage.nil? && stage < 60
86
90
 
87
- br(body, "left")
88
- body.div class: "colophon" do |div|
91
+ br(out, "left")
92
+ out.div class: "colophon" do |div|
89
93
  end
90
94
  end
91
95
 
92
- def indexsect(isoxml, out)
96
+ def indexsect_section(isoxml, out)
93
97
  isoxml.xpath(ns("//indexsect")).each do |i|
94
- indexsect_title(i, out)
95
- br(out, "auto")
96
- out.div class: "index" do |div|
97
- i.children.each do |e|
98
- parse(e, div) unless e.name == "title"
99
- end
98
+ indexsect(i, out)
99
+ end
100
+ end
101
+
102
+ def indexsect(elem, out)
103
+ indexsect_title(elem, out)
104
+ br(out, "auto")
105
+ out.div class: "index" do |div|
106
+ elem.children.each do |e|
107
+ parse(e, div) unless e.name == "title"
100
108
  end
101
109
  end
102
110
  end
@@ -128,14 +136,14 @@ module IsoDoc
128
136
  { class: "BiblioTitle" }
129
137
  end
130
138
 
131
- def bibliography(xml, out)
132
- (f = xml.at(ns(bibliography_xpath)) and f["hidden"] != "true") or return
139
+ def bibliography(node, out)
140
+ node["hidden"] != "true" or return
133
141
  page_break(out)
134
142
  out.div do |div|
135
143
  div.h1 **bibliography_attrs do |h1|
136
- f&.at(ns("./title"))&.children&.each { |c2| parse(c2, h1) }
144
+ node&.at(ns("./title"))&.children&.each { |c2| parse(c2, h1) }
137
145
  end
138
- biblio_list(f, div, true)
146
+ biblio_list(node, div, true)
139
147
  end
140
148
  end
141
149
 
@@ -197,7 +205,6 @@ module IsoDoc
197
205
  end
198
206
 
199
207
  def annex_name(_annex, name, div)
200
- preceding_floating_titles(name, div)
201
208
  return if name.nil?
202
209
 
203
210
  name&.at(ns("./strong"))&.remove # supplied by CSS list numbering
@@ -41,6 +41,7 @@ module IsoDoc
41
41
 
42
42
  def dis_styles1(docxml)
43
43
  amd_style(docxml)
44
+ middle_title_style(docxml)
44
45
  code_style(docxml)
45
46
  figure_style(docxml)
46
47
  formula_style(docxml)
@@ -71,6 +72,14 @@ module IsoDoc
71
72
  end
72
73
  end
73
74
 
75
+ def middle_title_style(docxml)
76
+ docxml.xpath("//p[@class = 'zzSTDTitle2']").each do |p|
77
+ p1 = p.previous_element && p1.name == p &&
78
+ p1["class"] = "zzSTDTitle2" or next
79
+ p1 << " #{p.remove.children.to_xml}"
80
+ end
81
+ end
82
+
74
83
  def dis_style_interactions(docxml)
75
84
  docxml.xpath("//p[@class = 'Code' or @class = 'Code-' or " \
76
85
  "@class = 'Code--']" \
@@ -46,12 +46,6 @@ module IsoDoc
46
46
  { class: "TableTitle", style: "text-align:center;" }
47
47
  end
48
48
 
49
- def span_parse(node, out)
50
- out.span class: node["class"] do |x|
51
- node.children.each { |n| parse(n, x) }
52
- end
53
- end
54
-
55
49
  def word_toc_preface(level)
56
50
  <<~TOC.freeze
57
51
  <span lang="EN-GB"><span
@@ -68,7 +62,7 @@ module IsoDoc
68
62
 
69
63
  def toWord(result, filename, dir, header)
70
64
  result = from_xhtml(word_cleanup(to_xhtml(result)))
71
- .gsub(/-DOUBLE_HYPHEN_ESCAPE-/, "--")
65
+ .gsub("-DOUBLE_HYPHEN_ESCAPE-", "--")
72
66
  @wordstylesheet = wordstylesheet_update
73
67
  ::Html2Doc::IsoDIS.new(
74
68
  filename: filename,
@@ -86,30 +80,42 @@ module IsoDoc
86
80
  middle_title_dis(out)
87
81
  end
88
82
 
89
- def middle_title_dis(out)
83
+ def middle_title_dis(node, out)
90
84
  out.p(class: "zzSTDTitle") do |p|
91
- p << @meta.get[:doctitleintro]
92
- @meta.get[:doctitleintro] && @meta.get[:doctitlemain] and p << " &#x2014; "
93
- p << @meta.get[:doctitlemain]
94
- @meta.get[:doctitlemain] && @meta.get[:doctitlepart] and p << " &#x2014; "
95
- if @meta.get[:doctitlepart]
96
- b = @meta.get[:doctitlepartlabel] and
97
- p << "<span style='font-weight:normal'>#{b}:</span> "
98
- p << " #{@meta.get[:doctitlepart]}"
85
+ node.children.each { |n| parse(n, p) }
86
+ end
87
+ end
88
+
89
+ def middle_title_amd(node, out)
90
+ out.p(class: "zzSTDTitle2") do |p|
91
+ p.span(style: "font-weight:normal") do |s|
92
+ node.children.each { |n| parse(n, s) }
99
93
  end
100
- @meta.get[:doctitleamdlabel] || @meta.get[:doctitleamd] ||
101
- @meta.get[:doctitlecorrlabel] and middle_title_dis_amd(p)
102
94
  end
103
95
  end
104
96
 
105
- def middle_title_dis_amd(para)
106
- para.span(style: "font-weight:normal") do |p|
107
- if a = @meta.get[:doctitleamdlabel]
108
- p << " #{a}"
109
- a = @meta.get[:doctitleamd] and p << ": #{a}"
97
+ def para_parse(node, out)
98
+ case node["class"]
99
+ when "zzSTDTitle1" then middle_title_dis(node, out)
100
+ when "zzSTDTitle2" then middle_title_amd(node, out)
101
+ else super
102
+ end
103
+ end
104
+
105
+ def span_parse(node, out)
106
+ st = node["style"]
107
+ case node["class"]
108
+ when "nonboldtitle"
109
+ out.span **attr_code(style: "#{st};font-weight:normal") do |s|
110
+ node.children.each { |n| parse(n, s) }
111
+ end
112
+ when "boldtitle"
113
+ out.span **attr_code(style: st) do |s|
114
+ node.children.each { |n| parse(n, s) }
110
115
  end
111
- if a = @meta.get[:doctitlecorrlabel]
112
- p << " #{a}"
116
+ else
117
+ out.span **attr_code(class: node["class"], style: st) do |x|
118
+ node.children.each { |n| parse(n, x) }
113
119
  end
114
120
  end
115
121
  end