metanorma-unece 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -46,8 +46,11 @@
46
46
 
47
47
  <div class="coverpage-stage-block" >
48
48
  <p><span class="coverpage-maturity" id="{{ status | replace: ' ', '-' | downcase }}">{% if unpublished %}{{ status }}{% endif %}</span></p>
49
- {% if security %}
50
- <p><span class="coverpage-maturity">Classification: {{ security }}</span></p>
49
+ {% if submissionlanguage %}
50
+ <p><span class="coverpage-maturity">Original: {{ submissionlanguage | join: "/" }}</span></p>
51
+ {% endif %}
52
+ {% if language %}
53
+ <p><span class="coverpage-maturity">{{ language | join: ", " }} only</span></p>
51
54
  {% endif %}
52
55
  </div>
53
56
 
@@ -498,7 +498,10 @@ p.Formula, li.Formula, div.Formula
498
498
  mso-even-header:url("file:///C:/Doc/FILENAME_files/header.html") eh1;
499
499
  mso-header:url("file:///C:/Doc/FILENAME_files/header.html") h1;
500
500
  mso-even-footer:url("file:///C:/Doc/FILENAME_files/header.html") ef1;
501
- mso-paper-source:0;}
501
+ mso-paper-source:0;
502
+ mso-footnote-numbering-style:chicago;
503
+ mso-footnote-numbering-restart:each-section;
504
+ }
502
505
  div.WordSection1
503
506
  {page:WordSection1;}
504
507
  @page WordSection2
@@ -511,7 +514,9 @@ div.WordSection1
511
514
  mso-header:url("file:///C:/Doc/FILENAME_files/header.html") h2;
512
515
  mso-even-footer:url("file:///C:/Doc/FILENAME_files/header.html") ef2;
513
516
  mso-footer:url("file:///C:/Doc/FILENAME_files/header.html") f2;
514
- mso-paper-source:0;}
517
+ mso-paper-source:0;
518
+ mso-footnote-numbering-restart:each-section;
519
+ }
515
520
  div.WordSection2
516
521
  {page:WordSection2;}
517
522
  @page WordSection3
@@ -524,7 +529,9 @@ div.WordSection2
524
529
  mso-header:url("file:///C:/Doc/FILENAME_files/header.html") h2;
525
530
  mso-even-footer:url("file:///C:/Doc/FILENAME_files/header.html") ef3;
526
531
  mso-footer:url("file:///C:/Doc/FILENAME_files/header.html") f3;
527
- mso-paper-source:0;}
532
+ mso-paper-source:0;
533
+ mso-footnote-numbering-restart:each-section;
534
+ }
528
535
  div.WordSection3
529
536
  {page:WordSection3;}
530
537
  ol
@@ -16,17 +16,25 @@ mso-bidi-font-size:12.0pt;font-family:"Times New Roman",serif'>Economic and
16
16
  Social Council</span></b><span lang=EN-AU style='font-family:"Times New Roman",serif'><span
17
17
  style='mso-tab-count:1'>               </span></span><span lang=EN-AU
18
18
  style='font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:"Times New Roman",serif'>Distr.:
19
- <span class=SpellE>{{ session_distribution }}</span><o:p></o:p></span></p>
19
+ <span class=SpellE>{{ distribution }}</span><o:p></o:p></span></p>
20
20
 
21
21
  <p class=MsoNormal style='tab-stops:70.9pt 12.0cm'><span lang=EN-AU
22
22
  style='font-family:"Times New Roman",serif'><span style='mso-tab-count:1'>                        </span><span
23
23
  style='mso-tab-count:1'>                                                                                          </span></span><span
24
24
  lang=EN-AU style='font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:"Times New Roman",serif'>{{ revdate }}<o:p></o:p></span></p>
25
25
 
26
+ {% if submissionlanguage %}
26
27
  <p class=MsoNormal style='tab-stops:70.9pt 12.0cm'><span lang=EN-AU
27
28
  style='font-family:"Times New Roman",serif'><span style='mso-tab-count:2'>                                                                                                                 </span></span><span
28
29
  lang=EN-AU style='font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:"Times New Roman",serif'>Original:
29
- {{ language }}<o:p></o:p></span></p>
30
+ {{ submissionlanguage | join: "/" }}<o:p></o:p></span></p>
31
+ {% endif %}
32
+
33
+ {% if language %}
34
+ <p class=MsoNormal style='tab-stops:70.9pt 12.0cm'><span lang=EN-AU
35
+ style='font-family:"Times New Roman",serif'><span style='mso-tab-count:2'>                                                                                                                 </span></span><span
36
+ lang=EN-AU style='font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:"Times New Roman",serif'>{{ language }} only<o:p></o:p></span></p>
37
+ {% endif %}
30
38
 
31
39
  <p class=MsoNormal style='tab-stops:70.9pt 12.0cm'><span lang=EN-AU
32
40
  style='font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:"Times New Roman",serif'><o:p>&nbsp;</o:p></span></p>
@@ -62,14 +70,37 @@ font-family:"Times New Roman",serif'>{{ session_number }} session<o:p></o:p></sp
62
70
  padding:0cm;mso-padding-alt:1.0pt 0cm 0cm 0cm'><span lang=EN-AU
63
71
  style='font-size:10.5pt;mso-bidi-font-size:12.0pt;font-family:"Times New Roman",serif'>{{ session_date }}<o:p></o:p></span></p>
64
72
 
73
+ {% if session_itemnumber.size == 1 %}
74
+ <p class=MsoNormal style='border:none;mso-border-top-alt:solid windowtext 2.25pt;
75
+ padding:0cm;mso-padding-alt:1.0pt 0cm 0cm 0cm'><span lang=EN-AU
76
+ style='font-size:10.5pt;mso-bidi-font-size:12.0pt;font-family:"Times New Roman",serif'>Agenda item {{ session_itemnumber[0] }}<o:p></o:p></span></p>
77
+ {% endif %}
78
+
79
+ {% if session_itemnumber.size > 1 %}
80
+ <p class=MsoNormal style='border:none;mso-border-top-alt:solid windowtext 2.25pt;
81
+ padding:0cm;mso-padding-alt:1.0pt 0cm 0cm 0cm'><span lang=EN-AU
82
+ style='font-size:10.5pt;mso-bidi-font-size:12.0pt;font-family:"Times New Roman",serif'>Agenda items {{ session_itemnumber | join: ", " }}<o:p></o:p></span></p>
83
+ {% endif %}
84
+
65
85
  <p class=MsoNormal style='border:none;mso-border-top-alt:solid windowtext 2.25pt;
66
86
  padding:0cm;mso-padding-alt:1.0pt 0cm 0cm 0cm'><span lang=EN-AU
67
- style='font-size:10.5pt;mso-bidi-font-size:12.0pt;font-family:"Times New Roman",serif'>{{ docnumber }}<o:p></o:p></span></p>
87
+ style='font-size:10.5pt;mso-bidi-font-size:12.0pt;font-family:"Times New Roman",serif'>{{ docnumber }}{% if item_footnote %}<a
88
+ style='mso-footnote-id:ftnitem' href="#ftnitem" name="_ftnrefitem" class="footnote" title=""><span
89
+ class=MsoFootnoteReference><span style='mso-special-character:footnote'></span></span></a>{% endif %}<o:p></o:p></span></p>
68
90
 
91
+ {% if session_itemname.size > 0 %}
69
92
  <p class=MsoNormal style='border:none;mso-border-top-alt:solid windowtext 2.25pt;
70
93
  padding:0cm;mso-padding-alt:1.0pt 0cm 0cm 0cm'><b style='mso-bidi-font-weight:
71
94
  normal'><span lang=EN-AU style='font-size:10.5pt;mso-bidi-font-size:12.0pt;
72
- font-family:"Times New Roman",serif'>{{ doctitle }}<o:p></o:p></span></b></p>
95
+ font-family:"Times New Roman",serif'>{{ session_itemname | join: "<br/>" }}<o:p></o:p></span></b></p>
96
+ {% endif %}
97
+
98
+ {% if session_subitemname.size > 0 %}
99
+ <p class=MsoNormal style='border:none;mso-border-top-alt:solid windowtext 2.25pt;
100
+ padding:0cm;mso-padding-alt:1.0pt 0cm 0cm 0cm'><b style='mso-bidi-font-weight:
101
+ normal'><span lang=EN-AU style='font-size:10.5pt;mso-bidi-font-size:12.0pt;
102
+ font-family:"Times New Roman",serif'>{{ session_subitemname | join: "<br/>" }}<o:p></o:p></span></b></p>
103
+ {% endif %}
73
104
 
74
105
  <p class=MsoNormal style='border:none;mso-border-top-alt:solid windowtext 2.25pt;
75
106
  padding:0cm;mso-padding-alt:1.0pt 0cm 0cm 0cm'><span lang=EN-AU
@@ -1,6 +1,19 @@
1
1
  <p class="MsoNormal" align="center" style='text-align:center'><span lang="EN-GB" style='mso-no-proof:yes'><b>UNECE</b></span><br/>
2
2
  <span lang="EN-GB"><span style='mso-no-proof:yes'><b>{{ tc | join: "/" }}</b></span></p>
3
3
 
4
+ {% if submissionlanguage %}
5
+ <p class=MsoNormal style='tab-stops:70.9pt 12.0cm'><span lang=EN-AU
6
+ style='font-family:"Times New Roman",serif'><span style='mso-tab-count:2'>?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| </span></span><span
7
+ lang=EN-AU style='font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:"Times New Roman",serif'>Original:
8
+ {{ submissionlanguage | join: "/" }}<o:p></o:p></span></p>
9
+ {% endif %}
10
+
11
+ {% if language %}
12
+ <p class=MsoNormal style='tab-stops:70.9pt 12.0cm'><span lang=EN-AU
13
+ style='font-family:"Times New Roman",serif'><span style='mso-tab-count:2'>?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| ?| </span></span><span
14
+ lang=EN-AU style='font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:"Times New Roman",serif'>{{ language }} only<o:p></o:p></span></p>
15
+ {% endif %}
16
+
4
17
  <p class="MsoNormal" align="center" style='text-align:center;line-height:18.0pt;margin-bottom:0.0pt'><b
5
18
  style='mso-bidi-font-weight:normal'><span lang="EN-GB" style='font-size:24.0pt'>{{ doctitle }}</span>
6
19
  </b><br/><span lang="EN-GB" style='font-size:16.0pt'>{{ docsubtitle }}</span></p>
@@ -68,6 +68,9 @@ module IsoDoc
68
68
  def make_body(xml, docxml)
69
69
  plenary = docxml.at(ns("//bibdata[@type = 'plenary']"))
70
70
  body_attr = { lang: "EN-US", link: "blue", vlink: "#954F72", "xml:lang": "EN-US", class: "container" }
71
+ if plenary && @htmlcoverpage == html_doc_path("html_unece_titlepage.html")
72
+ @htmlcoverpage = html_doc_path("html_unece_plenary_titlepage.html")
73
+ end
71
74
  #@htmlintropage = nil if plenary
72
75
  xml.body **body_attr do |body|
73
76
  make_body1(body, docxml)
@@ -1,5 +1,6 @@
1
1
  require "isodoc"
2
2
  require "twitter_cldr"
3
+ require "iso-639"
3
4
 
4
5
  module IsoDoc
5
6
  module Unece
@@ -20,17 +21,44 @@ module IsoDoc
20
21
  set(:docsubtitle, main)
21
22
  end
22
23
 
24
+ def extract_languages(nodeset)
25
+ lgs = []
26
+ nodeset.each do |l|
27
+ l && ISO_639&.find(l.text)&.english_name &&
28
+ lgs << ISO_639.find(l.text).english_name
29
+ end
30
+ lgs.map { |l| l == "Spanish; Castilian" ? "Spanish" : l }
31
+ end
32
+
23
33
  def author(isoxml, _out)
24
34
  tc = isoxml.at(ns("//bibdata/editorialgroup/committee"))
25
35
  set(:tc, tc.text) if tc
36
+ set(:distribution, isoxml&.at(ns("//bibdata/distribution"))&.text)
37
+ lgs = extract_languages(isoxml.xpath(ns("//bibdata/language")))
38
+ lgs = [] if lgs.sort == %w(English French Arabic Chinese German Spanish).sort
39
+ slgs = extract_languages(isoxml.xpath(ns("//bibdata/submissionlanguage")))
40
+ lgs = [] if slgs.size == 1
41
+ set(:language, lgs) unless lgs.empty?
42
+ set(:submissionlanguage, slgs) unless slgs.empty?
43
+ session(isoxml, _out)
44
+ end
45
+
46
+ def multival(isoxml, xpath)
47
+ items = []
48
+ isoxml.xpath(ns(xpath)).each { |i| items << i.text }
49
+ items
50
+ end
51
+
52
+ def session(isoxml, _out)
26
53
  set(:session_number, isoxml&.at(ns("//bibdata/session/number"))&.text&.to_i&.
27
54
  localize&.to_rbnf_s("SpelloutRules", "spellout-ordinal")&.capitalize)
28
55
  set(:session_date, isoxml&.at(ns("//bibdata/session/date"))&.text)
29
- set(:session_agendaitem, isoxml&.at(ns("//bibdata/session/agenda_item"))&.text)
30
56
  set(:session_collaborator, isoxml&.at(ns("//bibdata/session/collaborator"))&.text)
31
57
  set(:session_id, isoxml&.at(ns("//bibdata/session/id"))&.text)
32
- set(:session_distribution, isoxml&.at(ns("//bibdata/session/distribution"))&.text)
33
- set(:language, isoxml&.at(ns("//bibdata/language"))&.text)
58
+ set(:item_footnote, isoxml&.at(ns("//bibdata/session/item-footnote"))&.text)
59
+ set(:session_itemnumber, multival(isoxml, "//bibdata/session/item-number"))
60
+ set(:session_itemname, multival(isoxml, "//bibdata/session/item-name"))
61
+ set(:session_subitemname, multival(isoxml, "//bibdata/session/subitem-name"))
34
62
  end
35
63
 
36
64
  def docid(isoxml, _out)
@@ -41,319 +41,331 @@ module IsoDoc
41
41
  @meta.set(:toc, @toc)
42
42
  end
43
43
 
44
- def make_body(xml, docxml)
45
- plenary = docxml.at(ns("//bibdata[@type = 'plenary']"))
46
- if plenary && @wordcoverpage == html_doc_path("word_unece_titlepage.html")
47
- @wordcoverpage = html_doc_path("word_unece_plenary_titlepage.html")
48
- end
49
- @wordintropage = nil if plenary && !@toc
50
- body_attr = { lang: "EN-US", link: "blue", vlink: "#954F72" }
51
- xml.body **body_attr do |body|
52
- make_body1(body, docxml)
53
- make_body2(body, docxml)
54
- make_body3(body, docxml)
44
+ def footnotes(div)
45
+ if @meta.get[:item_footnote]
46
+ fn = noko do |xml|
47
+ xml.aside **{ id: "ftnitem" } do |div|
48
+ div.p @meta.get[:item_footnote]
49
+ end
50
+ end.join("\n")
51
+ @footnotes.unshift fn
55
52
  end
53
+ super
56
54
  end
57
55
 
58
- def make_body2(body, docxml)
59
- body.div **{ class: "WordSection2" } do |div2|
60
- info docxml, div2
61
- abstract docxml, div2
62
- foreword docxml, div2
63
- introduction docxml, div2
64
- div2.p { |p| p << "&nbsp;" } # placeholder
65
- end
66
- section_break(body)
56
+ def make_body(xml, docxml)
57
+ plenary = docxml.at(ns("//bibdata[@type = 'plenary']"))
58
+ if plenary && @wordcoverpage == html_doc_path("word_unece_titlepage.html")
59
+ @wordcoverpage = html_doc_path("word_unece_plenary_titlepage.html")
60
+ end
61
+ @wordintropage = nil if plenary && !@toc
62
+ body_attr = { lang: "EN-US", link: "blue", vlink: "#954F72" }
63
+ xml.body **body_attr do |body|
64
+ make_body1(body, docxml)
65
+ make_body2(body, docxml)
66
+ make_body3(body, docxml)
67
+ end
68
+ end
69
+
70
+ def make_body2(body, docxml)
71
+ body.div **{ class: "WordSection2" } do |div2|
72
+ info docxml, div2
73
+ abstract docxml, div2
74
+ foreword docxml, div2
75
+ introduction docxml, div2
76
+ div2.p { |p| p << "&nbsp;" } # placeholder
67
77
  end
78
+ section_break(body)
79
+ end
68
80
 
69
- ENDLINE = <<~END.freeze
81
+ ENDLINE = <<~END.freeze
70
82
  <v:line id="_x0000_s1026"
71
83
  alt="" style='position:absolute;left:0;text-align:left;z-index:251662848;
72
84
  mso-wrap-edited:f;mso-width-percent:0;mso-height-percent:0;
73
85
  mso-width-percent:0;mso-height-percent:0'
74
86
  from="6.375cm,20.95pt" to="10.625cm,20.95pt"
75
87
  strokeweight="1.5pt"/>
76
- END
88
+ END
77
89
 
78
- def end_line(_isoxml, out)
79
- out.parent.add_child(ENDLINE)
80
- end
90
+ def end_line(_isoxml, out)
91
+ out.parent.add_child(ENDLINE)
92
+ end
81
93
 
82
- def middle(isoxml, out)
83
- clause isoxml, out
84
- annex isoxml, out
85
- bibliography isoxml, out
86
- end_line(isoxml, out)
87
- end
94
+ def middle(isoxml, out)
95
+ clause isoxml, out
96
+ annex isoxml, out
97
+ bibliography isoxml, out
98
+ end_line(isoxml, out)
99
+ end
88
100
 
89
- def clause_parse_title(node, div, c1, out)
90
- if node["inline-header"] == "true"
91
- inline_header_title(out, node, c1)
92
- else
93
- div.send "h#{get_anchors[node['id']][:level]}" do |h|
94
- lbl = get_anchors[node['id']][:label]
95
- h << "#{lbl}. " if lbl && !@suppressheadingnumbers
96
- insert_tab(h, 1)
97
- c1&.children&.each { |c2| parse(c2, h) }
98
- end
101
+ def clause_parse_title(node, div, c1, out)
102
+ if node["inline-header"] == "true"
103
+ inline_header_title(out, node, c1)
104
+ else
105
+ div.send "h#{get_anchors[node['id']][:level]}" do |h|
106
+ lbl = get_anchors[node['id']][:label]
107
+ h << "#{lbl}. " if lbl && !@suppressheadingnumbers
108
+ insert_tab(h, 1)
109
+ c1&.children&.each { |c2| parse(c2, h) }
99
110
  end
100
111
  end
112
+ end
101
113
 
102
- def introduction(isoxml, out)
103
- f = isoxml.at(ns("//introduction")) || return
104
- out.div **{ class: "Section3", id: f["id"] } do |div|
105
- page_break(out)
106
- div.p(**{ class: "IntroTitle" }) do |h1|
107
- h1 << @introduction_lbl
108
- end
109
- f.elements.each do |e|
110
- parse(e, div) unless e.name == "title"
111
- end
114
+ def introduction(isoxml, out)
115
+ f = isoxml.at(ns("//introduction")) || return
116
+ out.div **{ class: "Section3", id: f["id"] } do |div|
117
+ page_break(out)
118
+ div.p(**{ class: "IntroTitle" }) do |h1|
119
+ h1 << @introduction_lbl
120
+ end
121
+ f.elements.each do |e|
122
+ parse(e, div) unless e.name == "title"
112
123
  end
113
124
  end
125
+ end
114
126
 
115
- def foreword(isoxml, out)
116
- f = isoxml.at(ns("//foreword")) || return
117
- out.div **attr_code(id: f["id"]) do |s|
118
- page_break(out)
119
- s.p(**{ class: "ForewordTitle" }) do |h1|
120
- h1 << @foreword_lbl
121
- end
122
- f.elements.each { |e| parse(e, s) unless e.name == "title" }
127
+ def foreword(isoxml, out)
128
+ f = isoxml.at(ns("//foreword")) || return
129
+ out.div **attr_code(id: f["id"]) do |s|
130
+ page_break(out)
131
+ s.p(**{ class: "ForewordTitle" }) do |h1|
132
+ h1 << @foreword_lbl
123
133
  end
134
+ f.elements.each { |e| parse(e, s) unless e.name == "title" }
124
135
  end
136
+ end
125
137
 
126
- def word_preface(docxml)
127
- super
128
- preface_container = docxml.at("//div[@id = 'preface_container']") # recommendation
129
- abstractbox = docxml.at("//div[@id = 'abstractbox']") # plenary
130
- foreword = docxml.at("//p[@class = 'ForewordTitle']/..")
131
- intro = docxml.at("//p[@class = 'IntroTitle']/..")
132
- abstract = docxml.at("//p[@class = 'AbstractTitle']/..")
133
- abstract.parent = (abstractbox || preface_container) if abstract
134
- abstractbox and abstract&.xpath("./br")&.each do |a|
135
- a.remove if /page-break-before:always/.match(a["style"])
136
- end
137
- docxml&.at("//p[@class = 'AbstractTitle']")&.remove if abstractbox
138
- foreword.parent = preface_container if foreword && preface_container
139
- intro.parent = preface_container if intro && preface_container
140
- if preface_container && (foreword || intro)
141
- preface_container.at("./div/br").remove # remove initial page break
142
- end
143
- if abstractbox && !intro && !foreword && !@toc
144
- sect2 = docxml.at("//div[@class='WordSection2']")
145
- sect2.next_element.remove # pagebreak
146
- sect2.remove # pagebreak
147
- end
138
+ def word_preface(docxml)
139
+ super
140
+ preface_container = docxml.at("//div[@id = 'preface_container']") # recommendation
141
+ abstractbox = docxml.at("//div[@id = 'abstractbox']") # plenary
142
+ foreword = docxml.at("//p[@class = 'ForewordTitle']/..")
143
+ intro = docxml.at("//p[@class = 'IntroTitle']/..")
144
+ abstract = docxml.at("//p[@class = 'AbstractTitle']/..")
145
+ abstract.parent = (abstractbox || preface_container) if abstract
146
+ abstractbox and abstract&.xpath("./br")&.each do |a|
147
+ a.remove if /page-break-before:always/.match(a["style"])
148
+ end
149
+ docxml&.at("//p[@class = 'AbstractTitle']")&.remove if abstractbox
150
+ foreword.parent = preface_container if foreword && preface_container
151
+ intro.parent = preface_container if intro && preface_container
152
+ if preface_container && (foreword || intro)
153
+ preface_container.at("./div/br").remove # remove initial page break
154
+ end
155
+ if abstractbox && !intro && !foreword && !@toc
156
+ sect2 = docxml.at("//div[@class='WordSection2']")
157
+ sect2.next_element.remove # pagebreak
158
+ sect2.remove # pagebreak
148
159
  end
160
+ end
149
161
 
150
- # SAME as html_convert.rb from here on, starting with annex_name
162
+ # SAME as html_convert.rb from here on, starting with annex_name
151
163
 
152
- def annex_name(annex, name, div)
153
- div.h1 **{ class: "Annex" } do |t|
154
- t << "#{get_anchors[annex['id']][:label]}"
155
- t.br
156
- t.b do |b|
157
- name&.children&.each { |c2| parse(c2, b) }
158
- end
164
+ def annex_name(annex, name, div)
165
+ div.h1 **{ class: "Annex" } do |t|
166
+ t << "#{get_anchors[annex['id']][:label]}"
167
+ t.br
168
+ t.b do |b|
169
+ name&.children&.each { |c2| parse(c2, b) }
159
170
  end
160
171
  end
172
+ end
161
173
 
162
- def i18n_init(lang, script)
163
- super
164
- @admonition_lbl = "Box"
165
- @abstract_lbl = "Summary"
166
- end
174
+ def i18n_init(lang, script)
175
+ super
176
+ @admonition_lbl = "Box"
177
+ @abstract_lbl = "Summary"
178
+ end
167
179
 
168
- def fileloc(loc)
169
- File.join(File.dirname(__FILE__), loc)
170
- end
180
+ def fileloc(loc)
181
+ File.join(File.dirname(__FILE__), loc)
182
+ end
171
183
 
172
- MIDDLE_CLAUSE = "//clause[parent::sections]".freeze
184
+ MIDDLE_CLAUSE = "//clause[parent::sections]".freeze
173
185
 
174
- def initial_anchor_names(d)
175
- preface_names(d.at(ns("//foreword")))
176
- preface_names(d.at(ns("//introduction")))
177
- sequential_asset_names(d.xpath(ns("//foreword | //introduction")))
178
- middle_section_asset_names(d)
179
- clause_names(d, 0)
180
- termnote_anchor_names(d)
181
- termexample_anchor_names(d)
182
- end
186
+ def initial_anchor_names(d)
187
+ preface_names(d.at(ns("//foreword")))
188
+ preface_names(d.at(ns("//introduction")))
189
+ sequential_asset_names(d.xpath(ns("//foreword | //introduction")))
190
+ middle_section_asset_names(d)
191
+ clause_names(d, 0)
192
+ termnote_anchor_names(d)
193
+ termexample_anchor_names(d)
194
+ end
183
195
 
184
- def clause_names(docxml, sect_num)
185
- q = "//clause[parent::sections]"
186
- @paranumber = 0
187
- docxml.xpath(ns(q)).each_with_index do |c, i|
188
- section_names(c, (i + sect_num), 1)
189
- end
196
+ def clause_names(docxml, sect_num)
197
+ q = "//clause[parent::sections]"
198
+ @paranumber = 0
199
+ docxml.xpath(ns(q)).each_with_index do |c, i|
200
+ section_names(c, (i + sect_num), 1)
190
201
  end
202
+ end
191
203
 
192
- def levelnumber(num, lvl)
193
- case lvl % 3
194
- when 1 then RomanNumerals.to_roman(num)
195
- when 2 then ("A".ord + num - 1).chr
196
- when 0 then num.to_s
197
- end
204
+ def levelnumber(num, lvl)
205
+ case lvl % 3
206
+ when 1 then RomanNumerals.to_roman(num)
207
+ when 2 then ("A".ord + num - 1).chr
208
+ when 0 then num.to_s
198
209
  end
210
+ end
199
211
 
200
- def annex_levelnumber(num, lvl)
201
- case lvl % 3
202
- when 0 then RomanNumerals.to_roman(num)
203
- when 1 then ("A".ord + num - 1).chr
204
- when 2 then num.to_s
205
- end
212
+ def annex_levelnumber(num, lvl)
213
+ case lvl % 3
214
+ when 0 then RomanNumerals.to_roman(num)
215
+ when 1 then ("A".ord + num - 1).chr
216
+ when 2 then num.to_s
206
217
  end
218
+ end
207
219
 
208
- def leaf_section(clause, lvl)
209
- @paranumber += 1
210
- @anchors[clause["id"]] = {label: @paranumber.to_s, xref: "paragraph #{@paranumber}", level: lvl, type: "paragraph" }
211
- end
220
+ def leaf_section(clause, lvl)
221
+ @paranumber += 1
222
+ @anchors[clause["id"]] = {label: @paranumber.to_s, xref: "paragraph #{@paranumber}", level: lvl, type: "paragraph" }
223
+ end
212
224
 
213
- def annex_leaf_section(clause, num, lvl)
214
- @paranumber += 1
215
- @anchors[clause["id"]] = {label: @paranumber.to_s, xref: "paragraph #{num}.#{@paranumber}", level: lvl, type: "paragraph" }
216
- end
225
+ def annex_leaf_section(clause, num, lvl)
226
+ @paranumber += 1
227
+ @anchors[clause["id"]] = {label: @paranumber.to_s, xref: "paragraph #{num}.#{@paranumber}", level: lvl, type: "paragraph" }
228
+ end
217
229
 
218
- def section_names(clause, num, lvl)
219
- return num if clause.nil?
220
- clause.at(ns("./clause | ./term | ./terms | ./definitions")) or
221
- leaf_section(clause, lvl) && return
222
- num = num + 1
223
- lbl = levelnumber(num, 1)
224
- @anchors[clause["id"]] =
225
- { label: lbl, xref: l10n("#{@clause_lbl} #{lbl}"), level: lvl, type: "clause" }
226
- i = 1
227
- clause.xpath(ns("./clause | ./term | ./terms | ./definitions")).each do |c|
228
- section_names1(c, "#{lbl}.#{levelnumber(i, lvl + 1)}", lvl + 1)
229
- i += 1 if c.at(ns("./clause | ./term | ./terms | ./definitions"))
230
- end
231
- num
232
- end
230
+ def section_names(clause, num, lvl)
231
+ return num if clause.nil?
232
+ clause.at(ns("./clause | ./term | ./terms | ./definitions")) or
233
+ leaf_section(clause, lvl) && return
234
+ num = num + 1
235
+ lbl = levelnumber(num, 1)
236
+ @anchors[clause["id"]] =
237
+ { label: lbl, xref: l10n("#{@clause_lbl} #{lbl}"), level: lvl, type: "clause" }
238
+ i = 1
239
+ clause.xpath(ns("./clause | ./term | ./terms | ./definitions")).each do |c|
240
+ section_names1(c, "#{lbl}.#{levelnumber(i, lvl + 1)}", lvl + 1)
241
+ i += 1 if c.at(ns("./clause | ./term | ./terms | ./definitions"))
242
+ end
243
+ num
244
+ end
233
245
 
234
- def section_names1(clause, num, level)
235
- unless clause.at(ns("./clause | ./term | ./terms | ./definitions"))
236
- leaf_section(clause, level) and return
237
- end
238
- /\.(?<leafnum>[^.]+$)/ =~ num
239
- @anchors[clause["id"]] =
240
- { label: leafnum, level: level, xref: l10n("#{@clause_lbl} #{num}"), type: "clause" }
241
- i = 1
242
- clause.xpath(ns("./clause | ./terms | ./term | ./definitions")).each do |c|
243
- section_names1(c, "#{num}.#{levelnumber(i, level + 1)}", level + 1)
244
- i += 1 if c.at(ns("./clause | ./term | ./terms | ./definitions"))
245
- end
246
+ def section_names1(clause, num, level)
247
+ unless clause.at(ns("./clause | ./term | ./terms | ./definitions"))
248
+ leaf_section(clause, level) and return
246
249
  end
247
-
248
- def annex_name_lbl(clause, num)
249
- l10n("<b>#{@annex_lbl} #{num}</b>")
250
+ /\.(?<leafnum>[^.]+$)/ =~ num
251
+ @anchors[clause["id"]] =
252
+ { label: leafnum, level: level, xref: l10n("#{@clause_lbl} #{num}"), type: "clause" }
253
+ i = 1
254
+ clause.xpath(ns("./clause | ./terms | ./term | ./definitions")).each do |c|
255
+ section_names1(c, "#{num}.#{levelnumber(i, level + 1)}", level + 1)
256
+ i += 1 if c.at(ns("./clause | ./term | ./terms | ./definitions"))
250
257
  end
258
+ end
251
259
 
252
- def annex_names(clause, num)
253
- hierarchical_asset_names(clause, num)
254
- unless clause.at(ns("./clause | ./term | ./terms | ./definitions"))
255
- annex_leaf_section(clause, num, 1) and return
256
- end
257
- @anchors[clause["id"]] = { label: annex_name_lbl(clause, num), type: "clause",
258
- xref: "#{@annex_lbl} #{num}", level: 1 }
259
- i = 1
260
- clause.xpath(ns("./clause")).each do |c|
261
- annex_names1(c, "#{num}.#{annex_levelnumber(i, 2)}", 2)
262
- i += 1 if c.at(ns("./clause | ./term | ./terms | ./definitions"))
263
- end
264
- end
260
+ def annex_name_lbl(clause, num)
261
+ l10n("<b>#{@annex_lbl} #{num}</b>")
262
+ end
265
263
 
266
- def annex_names1(clause, num, level)
267
- unless clause.at(ns("./clause | ./term | ./terms | ./definitions"))
268
- annex_leaf_section(clause, num, level) and return
269
- end
270
- /\.(?<leafnum>[^.]+$)/ =~ num
271
- @anchors[clause["id"]] = { label: leafnum, xref: "#{@annex_lbl} #{num}",
272
- level: level, type: "clause" }
273
- i = 1
274
- clause.xpath(ns("./clause")).each do |c|
275
- annex_names1(c, "#{num}.#{annex_levelnumber(i, level + 1)}", level + 1)
276
- i += 1 if c.at(ns("./clause | ./term | ./terms | ./definitions"))
277
- end
264
+ def annex_names(clause, num)
265
+ hierarchical_asset_names(clause, num)
266
+ unless clause.at(ns("./clause | ./term | ./terms | ./definitions"))
267
+ annex_leaf_section(clause, num, 1) and return
278
268
  end
279
-
280
- def back_anchor_names(docxml)
281
- docxml.xpath(ns("//annex")).each_with_index do |c, i|
282
- @paranumber = 0
283
- annex_names(c, RomanNumerals.to_roman(i + 1))
284
- end
285
- docxml.xpath(ns("//bibitem[not(ancestor::bibitem)]")).each do |ref|
286
- reference_names(ref)
287
- end
269
+ @anchors[clause["id"]] = { label: annex_name_lbl(clause, num), type: "clause",
270
+ xref: "#{@annex_lbl} #{num}", level: 1 }
271
+ i = 1
272
+ clause.xpath(ns("./clause")).each do |c|
273
+ annex_names1(c, "#{num}.#{annex_levelnumber(i, 2)}", 2)
274
+ i += 1 if c.at(ns("./clause | ./term | ./terms | ./definitions"))
288
275
  end
276
+ end
289
277
 
290
- def sequential_admonition_names(clause)
291
- i = 0
292
- clause.xpath(ns(".//admonition")).each do |t|
293
- i += 1
294
- next if t["id"].nil? || t["id"].empty?
295
- @anchors[t["id"]] = anchor_struct(i.to_s, nil, @admonition_lbl, "box")
296
- end
278
+ def annex_names1(clause, num, level)
279
+ unless clause.at(ns("./clause | ./term | ./terms | ./definitions"))
280
+ annex_leaf_section(clause, num, level) and return
297
281
  end
282
+ /\.(?<leafnum>[^.]+$)/ =~ num
283
+ @anchors[clause["id"]] = { label: leafnum, xref: "#{@annex_lbl} #{num}",
284
+ level: level, type: "clause" }
285
+ i = 1
286
+ clause.xpath(ns("./clause")).each do |c|
287
+ annex_names1(c, "#{num}.#{annex_levelnumber(i, level + 1)}", level + 1)
288
+ i += 1 if c.at(ns("./clause | ./term | ./terms | ./definitions"))
289
+ end
290
+ end
298
291
 
299
- def hierarchical_admonition_names(clause, num)
300
- i = 0
301
- clause.xpath(ns(".//admonition")).each do |t|
302
- i += 1
303
- next if t["id"].nil? || t["id"].empty?
304
- @anchors[t["id"]] = anchor_struct("#{num}.#{i}", nil, @admonition_lbl, "box")
305
- end
292
+ def back_anchor_names(docxml)
293
+ docxml.xpath(ns("//annex")).each_with_index do |c, i|
294
+ @paranumber = 0
295
+ annex_names(c, RomanNumerals.to_roman(i + 1))
296
+ end
297
+ docxml.xpath(ns("//bibitem[not(ancestor::bibitem)]")).each do |ref|
298
+ reference_names(ref)
306
299
  end
300
+ end
307
301
 
308
- def sequential_asset_names(clause)
309
- super
310
- sequential_admonition_names(clause)
302
+ def sequential_admonition_names(clause)
303
+ i = 0
304
+ clause.xpath(ns(".//admonition")).each do |t|
305
+ i += 1
306
+ next if t["id"].nil? || t["id"].empty?
307
+ @anchors[t["id"]] = anchor_struct(i.to_s, nil, @admonition_lbl, "box")
311
308
  end
309
+ end
312
310
 
313
- def hierarchical_asset_names(clause, num)
314
- super
315
- hierarchical_admonition_names(clause, num)
311
+ def hierarchical_admonition_names(clause, num)
312
+ i = 0
313
+ clause.xpath(ns(".//admonition")).each do |t|
314
+ i += 1
315
+ next if t["id"].nil? || t["id"].empty?
316
+ @anchors[t["id"]] = anchor_struct("#{num}.#{i}", nil, @admonition_lbl, "box")
316
317
  end
318
+ end
317
319
 
318
- def admonition_name_parse(node, div, name)
319
- div.p **{ class: "FigureTitle", align: "center" } do |p|
320
- p << l10n("#{@admonition_lbl} #{get_anchors[node['id']][:label]}")
321
- if name
322
- p << "&nbsp;&mdash; "
323
- name.children.each { |n| parse(n, div) }
324
- end
320
+ def sequential_asset_names(clause)
321
+ super
322
+ sequential_admonition_names(clause)
323
+ end
324
+
325
+ def hierarchical_asset_names(clause, num)
326
+ super
327
+ hierarchical_admonition_names(clause, num)
328
+ end
329
+
330
+ def admonition_name_parse(node, div, name)
331
+ div.p **{ class: "FigureTitle", align: "center" } do |p|
332
+ p << l10n("#{@admonition_lbl} #{get_anchors[node['id']][:label]}")
333
+ if name
334
+ p << "&nbsp;&mdash; "
335
+ name.children.each { |n| parse(n, div) }
325
336
  end
326
337
  end
338
+ end
327
339
 
328
- def admonition_parse(node, out)
329
- name = node.at(ns("./name"))
330
- out.div **{ class: "Admonition" } do |t|
331
- admonition_name_parse(node, t, name) if name
332
- node.children.each do |n|
333
- parse(n, t) unless n.name == "name"
334
- end
340
+ def admonition_parse(node, out)
341
+ name = node.at(ns("./name"))
342
+ out.div **{ class: "Admonition" } do |t|
343
+ admonition_name_parse(node, t, name) if name
344
+ node.children.each do |n|
345
+ parse(n, t) unless n.name == "name"
335
346
  end
336
347
  end
348
+ end
337
349
 
338
- def inline_header_title(out, node, c1)
339
- title = c1&.content || ""
340
- out.span **{ class: "zzMoveToFollowing" } do |s|
341
- if get_anchors[node['id']][:label]
342
- s << "#{get_anchors[node['id']][:label]}. " unless @suppressheadingnumbers
343
- insert_tab(s, 1)
344
- end
345
- s << "#{title} "
350
+ def inline_header_title(out, node, c1)
351
+ title = c1&.content || ""
352
+ out.span **{ class: "zzMoveToFollowing" } do |s|
353
+ if get_anchors[node['id']][:label]
354
+ s << "#{get_anchors[node['id']][:label]}. " unless @suppressheadingnumbers
355
+ insert_tab(s, 1)
346
356
  end
357
+ s << "#{title} "
347
358
  end
359
+ end
348
360
 
349
- def abstract(isoxml, out)
350
- f = isoxml.at(ns("//abstract")) || return
351
- out.div **attr_code(id: f["id"]) do |s|
352
- page_break(out)
353
- s.p(**{ class: "AbstractTitle" }) { |h1| h1 << @abstract_lbl }
354
- f.elements.each { |e| parse(e, s) unless e.name == "title" }
355
- end
361
+ def abstract(isoxml, out)
362
+ f = isoxml.at(ns("//abstract")) || return
363
+ out.div **attr_code(id: f["id"]) do |s|
364
+ page_break(out)
365
+ s.p(**{ class: "AbstractTitle" }) { |h1| h1 << @abstract_lbl }
366
+ f.elements.each { |e| parse(e, s) unless e.name == "title" }
356
367
  end
357
368
  end
358
369
  end
359
370
  end
371
+ end