metanorma-iso 2.1.0 → 2.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/lib/html2doc/lists.rb +145 -10
  3. data/lib/isodoc/iso/base_convert.rb +11 -1
  4. data/lib/isodoc/iso/html/html_iso_titlepage.html +2 -0
  5. data/lib/isodoc/iso/html/isodoc-dis.css +216 -278
  6. data/lib/isodoc/iso/html/isodoc-dis.scss +294 -288
  7. data/lib/isodoc/iso/html/isodoc.css +38 -13
  8. data/lib/isodoc/iso/html/isodoc.scss +38 -12
  9. data/lib/isodoc/iso/html/style-human.css +14 -1
  10. data/lib/isodoc/iso/html/style-human.scss +10 -1
  11. data/lib/isodoc/iso/html/style-iso.css +35 -23
  12. data/lib/isodoc/iso/html/style-iso.scss +31 -23
  13. data/lib/isodoc/iso/html/word_iso_intro-dis.html +1 -6
  14. data/lib/isodoc/iso/html/word_iso_titlepage-dis.html +24 -13
  15. data/lib/isodoc/iso/html/word_iso_titlepage-prf.html +58 -0
  16. data/lib/isodoc/iso/html/word_iso_titlepage.html +10 -6
  17. data/lib/isodoc/iso/html/wordstyle-dis.css +12 -62
  18. data/lib/isodoc/iso/html/wordstyle-dis.scss +7 -56
  19. data/lib/isodoc/iso/html_convert.rb +7 -2
  20. data/lib/isodoc/iso/i18n-en.yaml +32 -4
  21. data/lib/isodoc/iso/i18n-fr.yaml +29 -3
  22. data/lib/isodoc/iso/i18n-ru.yaml +32 -4
  23. data/lib/isodoc/iso/i18n-zh-Hans.yaml +32 -3
  24. data/lib/isodoc/iso/i18n.rb +1 -1
  25. data/lib/isodoc/iso/iso.amendment.xsl +1570 -246
  26. data/lib/isodoc/iso/iso.international-standard.xsl +1570 -246
  27. data/lib/isodoc/iso/metadata.rb +67 -67
  28. data/lib/isodoc/iso/presentation_bibdata.rb +74 -0
  29. data/lib/isodoc/iso/presentation_xml_convert.rb +16 -5
  30. data/lib/isodoc/iso/presentation_xref.rb +10 -4
  31. data/lib/isodoc/iso/sections.rb +3 -3
  32. data/lib/isodoc/iso/word_cleanup.rb +3 -0
  33. data/lib/isodoc/iso/word_convert.rb +8 -5
  34. data/lib/isodoc/iso/word_dis_cleanup.rb +235 -0
  35. data/lib/isodoc/iso/word_dis_convert.rb +48 -100
  36. data/lib/isodoc/iso/xref.rb +34 -6
  37. data/lib/metanorma/iso/base.rb +20 -1
  38. data/lib/metanorma/iso/biblio.rng +134 -39
  39. data/lib/metanorma/iso/boilerplate-fr.xml +3 -0
  40. data/lib/metanorma/iso/boilerplate-ru.xml +3 -0
  41. data/lib/metanorma/iso/boilerplate.xml +3 -0
  42. data/lib/metanorma/iso/cleanup.rb +49 -11
  43. data/lib/metanorma/iso/front.rb +38 -6
  44. data/lib/metanorma/iso/front_id.rb +2 -0
  45. data/lib/metanorma/iso/isodoc.rng +16 -0
  46. data/lib/metanorma/iso/isostandard.rng +30 -12
  47. data/lib/metanorma/iso/macros.rb +29 -0
  48. data/lib/metanorma/iso/validate_section.rb +0 -12
  49. data/lib/metanorma/iso/version.rb +1 -1
  50. data/spec/isodoc/amd_spec.rb +20 -46
  51. data/spec/isodoc/blocks_spec.rb +499 -2
  52. data/spec/isodoc/i18n_spec.rb +145 -80
  53. data/spec/isodoc/iso_spec.rb +50 -169
  54. data/spec/isodoc/metadata_spec.rb +240 -99
  55. data/spec/isodoc/postproc_spec.rb +43 -7
  56. data/spec/isodoc/section_spec.rb +9 -9
  57. data/spec/isodoc/word_dis_spec.rb +1332 -146
  58. data/spec/isodoc/xref_spec.rb +87 -13
  59. data/spec/metanorma/amd_spec.rb +39 -23
  60. data/spec/metanorma/base_spec.rb +174 -44
  61. data/spec/metanorma/blocks_spec.rb +54 -0
  62. data/spec/metanorma/lists_spec.rb +2 -2
  63. data/spec/metanorma/section_spec.rb +2 -2
  64. data/spec/metanorma/validate_spec.rb +8 -19
  65. data/spec/spec_helper.rb +17 -7
  66. data/spec/vcr_cassettes/withdrawn_iso.yml +30 -30
  67. metadata +7 -8
  68. data/docs/asciiiso-syntax.adoc +0 -307
  69. data/docs/guidance.adoc +0 -487
  70. data/docs/navigation.adoc +0 -23
  71. data/docs/quickstart.adoc +0 -179
  72. data/lib/isodoc/iso/presentation_inline.rb +0 -90
@@ -0,0 +1,235 @@
1
+ module IsoDoc
2
+ module Iso
3
+ class WordDISConvert < WordConvert
4
+ def style_cleanup(docxml)
5
+ super
6
+ dis_styles(docxml)
7
+ end
8
+
9
+ STYLESMAP = {
10
+ AltTerms: "AdmittedTerm",
11
+ TableFootnote: "Tablefootnote",
12
+ formula: "Formula",
13
+ note: "Note",
14
+ example: "Example",
15
+ admonition: "Admonition",
16
+ admonitiontitle: "AdmonitionTitle",
17
+ sourcetitle: "SourceTitle",
18
+ tabletitle: "TableTitle",
19
+ titlepagesbhead: "TablePageSubhead",
20
+ NormRef: "RefNorm",
21
+ Biblio: "BiblioEntry",
22
+ MsoNormal: "MsoBodyText",
23
+ FigureTitle: "Figuretitle",
24
+ zzwarning: "zzWarning",
25
+ zzwarninghdr: "zzWarningHdr",
26
+ quoteattribution: "QuoteAttribution",
27
+ Sourcecode: "Code",
28
+ zzSTDTitle1: "zzSTDTitle",
29
+ zzSTDTitle2: "zzSTDTitle",
30
+ zzCopyright1: "zzCopyright",
31
+ }.freeze
32
+
33
+ def dis_styles(docxml)
34
+ STYLESMAP.each do |k, v|
35
+ docxml.xpath("//*[@class = '#{k}']").each { |s| s["class"] = v }
36
+ end
37
+ docxml.xpath("//h1[@class = 'ForewordTitle' or @class = 'IntroTitle']")
38
+ .each { |h| h.name = "p" }
39
+ dis_styles1(docxml)
40
+ docxml.xpath("//p[not(@class)]").each { |p| p["class"] = "MsoBodyText" }
41
+ end
42
+
43
+ def dis_styles1(docxml)
44
+ amd_style(docxml)
45
+ code_style(docxml)
46
+ figure_style(docxml)
47
+ note_style(docxml)
48
+ example_style(docxml)
49
+ quote_style(docxml)
50
+ dis_style_interactions(docxml)
51
+ end
52
+
53
+ def dis_style_interactions(docxml)
54
+ docxml.xpath("//p[@class = 'Code' or @class = 'Code-' or "\
55
+ "@class = 'Code--']"\
56
+ "[following::p[@class = 'Examplecontinued']]").each do |p|
57
+ p["style"] ||= ""
58
+ p["style"] = "margin-bottom:12pt;#{p['style']}"
59
+ end
60
+ end
61
+
62
+ def amd_style(docxml)
63
+ return unless @meta.get[:doctype] == "Amendment"
64
+
65
+ docxml.xpath("//div[@class = 'WordSection3']//h1").each do |h|
66
+ h.name = "p"
67
+ h["style"] = "font-style:italic;page-break-after:avoid;"
68
+ end
69
+ end
70
+
71
+ def quote_style(docxml)
72
+ docxml.xpath("//div[@class = 'Quote' or @class = 'Note' or "\
73
+ "@class = 'Example' or @class = 'Admonition']").each do |d|
74
+ quote_style1(d)
75
+ end
76
+ end
77
+
78
+ def para_style_change(div, class1, class2)
79
+ s = class1 ? "@class = '#{class1}'" : "not(@class)"
80
+ div.xpath(".//p[#{s}]").each do |p|
81
+ p["class"] = class2
82
+ end
83
+ end
84
+
85
+ def quote_style1(div)
86
+ para_style_change(div, nil, "BodyTextindent1")
87
+ para_style_change(div, "Code-", "Code--")
88
+ para_style_change(div, "Code", "Code-")
89
+ if div["class"] != "Example"
90
+ para_style_change(div, "Example", "Exampleindent")
91
+ para_style_change(div, "Examplecontinued", "Exampleindentcontinued")
92
+ end
93
+ if div["class"] != "Note"
94
+ para_style_change(div, "Note", "Noteindent")
95
+ para_style_change(div, "Notecontinued", "Noteindentcontinued")
96
+ end
97
+ div.xpath(".//table[@class = 'dl']").each do |t|
98
+ t["style"] = "margin-left: 1cm;"
99
+ end
100
+ end
101
+
102
+ def remove_note_label(doc)
103
+ doc.xpath("//span[@class = 'note_label' or @class = 'example_label']")
104
+ .each do |s|
105
+ s.replace(s.children)
106
+ end
107
+ end
108
+
109
+ def note_style(docxml)
110
+ remove_note_label(docxml)
111
+ note_continued_style(docxml)
112
+ end
113
+
114
+ def example_style(docxml)
115
+ example_continued_style(docxml)
116
+ end
117
+
118
+ def example_continued_style(docxml)
119
+ docxml.xpath("//div[@class = 'Example']").each do |d|
120
+ d.xpath("./p").each_with_index do |p, i|
121
+ next if p["class"] && p["class"] != "Example"
122
+
123
+ p["class"] = (i.zero? ? "Example" : "Examplecontinued")
124
+ end
125
+ end
126
+ end
127
+
128
+ def note_continued_style(docxml)
129
+ docxml.xpath("//div[@class = 'Note']").each do |d|
130
+ d.xpath("./p").each_with_index do |p, i|
131
+ next if p["class"] && p["class"] != "Note"
132
+
133
+ p["class"] = (i.zero? ? "Note" : "Notecontinued")
134
+ end
135
+ end
136
+ end
137
+
138
+ FIGURE_NESTED_STYLES =
139
+ { Note: "Figurenote", example: "Figureexample" }.freeze
140
+
141
+ def figure_style(docxml)
142
+ docxml.xpath("//div[@class = 'figure']").each do |f|
143
+ FIGURE_NESTED_STYLES.each do |k, v|
144
+ f.xpath(".//*[@class = '#{k}']").each { |n| n["class"] = v }
145
+ end
146
+ f.xpath("./img").each do |i|
147
+ i.replace("<p class='FigureGraphic'>#{i.to_xml}</p>")
148
+ end
149
+ end
150
+ end
151
+
152
+ def code_style(doc)
153
+ span_style((doc.xpath("//tt//b") - doc.xpath("//tt//i//b")),
154
+ "ISOCodebold")
155
+ span_style((doc.xpath("//tt//i") - doc.xpath("//tt//b//i")),
156
+ "ISOCodeitalic")
157
+ span_style((doc.xpath("//b//tt") - doc.xpath("//b//i//tt")),
158
+ "ISOCodebold")
159
+ span_style((doc.xpath("//i//tt") - doc.xpath("//i//b//tt")),
160
+ "ISOCodeitalic")
161
+ span_style(doc.xpath("//tt"), "ISOCode")
162
+ end
163
+
164
+ def span_style(xpath, style)
165
+ xpath.each do |elem|
166
+ elem.name = "span"
167
+ elem["class"] = style
168
+ end
169
+ end
170
+
171
+ def word_annex_cleanup1(docxml, lvl)
172
+ docxml.xpath("//h#{lvl}[ancestor::*[@class = 'Section3']]").each do |h2|
173
+ h2.name = "p"
174
+ h2["class"] = "a#{lvl}"
175
+ end
176
+ end
177
+
178
+ def word_cleanup(docxml)
179
+ word_table_cell_para(docxml)
180
+ super
181
+ word_section_end_empty_para(docxml)
182
+ docxml
183
+ end
184
+
185
+ def authority_cleanup(docxml)
186
+ super
187
+ if @meta.get[:stage_int].to_s[0] == "9" ||
188
+ @meta.get[:stage_int].to_s[0] == "6"
189
+ copyright_prf(docxml)
190
+ else
191
+ copyright_dis(docxml)
192
+ end
193
+ end
194
+
195
+ def copyright_prf(docxml)
196
+ docxml.xpath("//p[@id = 'boilerplate-address']")&.each do |p|
197
+ p["class"] = "zzCopyright"
198
+ p["style"] = "text-indent:20.15pt;"
199
+ p.replace(p.to_xml.gsub(%r{<br/>}, "</p>\n<p class='zzCopyright' "\
200
+ "style='text-indent:20.15pt;'>"))
201
+ end
202
+ docxml.xpath("//p[@class = 'zzCopyrightHdr']")&.each do |p|
203
+ # p["class"] = "zzCopyright"
204
+ p.remove
205
+ end
206
+ end
207
+
208
+ def copyright_dis(docxml)
209
+ docxml.xpath("//p[@id = 'boilerplate-address']")&.each do |p|
210
+ p["class"] = "zzCopyright"
211
+ p.replace(p.to_xml.gsub(%r{<br/>}, "</p>\n<p class='zzCopyright'>"))
212
+ end
213
+ docxml.xpath("//p[@class = 'zzCopyrightHdr']")&.each do |p|
214
+ p.remove
215
+ end
216
+ end
217
+
218
+ def word_section_end_empty_para(docxml)
219
+ docxml.at("//div[@class='WordSection1']/p[last()]").remove
220
+ end
221
+
222
+ def word_table_cell_para(docxml)
223
+ docxml.xpath("//td | //th").each do |t|
224
+ s = t["header"] == "true" ? "Tableheader" : "Tablebody"
225
+ t.delete("header")
226
+ if t.at("./p |./div")
227
+ t.xpath("./p | ./div").each { |p| p["class"] = s }
228
+ else
229
+ t.children = "<div class='#{s}'>#{t.children.to_xml}</div>"
230
+ end
231
+ end
232
+ end
233
+ end
234
+ end
235
+ end
@@ -1,16 +1,16 @@
1
+ require_relative "word_dis_cleanup"
2
+
1
3
  module IsoDoc
2
4
  module Iso
3
5
  class WordDISConvert < WordConvert
4
6
  def default_file_locations(_options)
5
- {
6
- wordstylesheet: html_doc_path("wordstyle-dis.scss"),
7
+ { wordstylesheet: html_doc_path("wordstyle-dis.scss"),
7
8
  standardstylesheet: html_doc_path("isodoc-dis.scss"),
8
9
  header: html_doc_path("header-dis.html"),
9
10
  wordcoverpage: html_doc_path("word_iso_titlepage-dis.html"),
10
11
  wordintropage: html_doc_path("word_iso_intro-dis.html"),
11
12
  ulstyle: "l3",
12
- olstyle: "l2",
13
- }
13
+ olstyle: "l2" }
14
14
  end
15
15
 
16
16
  def initialize(options)
@@ -19,47 +19,20 @@ module IsoDoc
19
19
  super
20
20
  end
21
21
 
22
- def init_dis; end
22
+ def init_dis(options); end
23
23
 
24
- def style_cleanup(docxml)
24
+ def convert1(docxml, filename, dir)
25
+ update_coverpage(docxml)
25
26
  super
26
- dis_styles(docxml)
27
27
  end
28
28
 
29
- STYLESMAP = {
30
- AltTerms: "AdmittedTerm",
31
- TableFootnote: "Tablefootnote",
32
- formula: "Formula",
33
- note: "Note",
34
- NormRef: "RefNorm",
35
- biblio: "BiblioEntry",
36
- MsoNormal: "MsoBodyText",
37
- FigureTitle: "Figuretitle",
38
- }.freeze
39
-
40
- def dis_styles(docxml)
41
- STYLESMAP.each do |k, v|
42
- docxml.xpath("//*[@class = '#{k}']").each { |s| s["class"] = v }
43
- end
44
- docxml.xpath("//h1[@class = 'ForewordTitle' or @class = 'IntroTitle']")
45
- .each { |h| h.name = "p" }
46
- dis_styles1(docxml)
47
- docxml.xpath("//p[not(@class)]").each { |p| p["class"] = "MsoBodyText" }
48
- end
49
-
50
- def dis_styles1(docxml)
51
- code_style(docxml)
52
- figure_style(docxml)
53
- example_style(docxml)
54
- end
55
-
56
- def example_style(docxml)
57
- docxml.xpath("//div[@class = 'Example']").each do |d|
58
- d.xpath("./p").each_with_index do |p, i|
59
- next if p["class"] && p["class"] != "Example"
60
-
61
- p["class"] = (i.zero? ? "Example" : "Examplecontinued")
62
- end
29
+ def update_coverpage(docxml)
30
+ stage = docxml.at(ns("//bibdata/status/stage"))&.text
31
+ substage = docxml.at(ns("//bibdata/status/substage"))&.text
32
+ if /^9/.match?(stage) || (stage == "60" && substage == "60")
33
+ @wordcoverpage = html_doc_path("word_iso_titlepage.html")
34
+ elsif stage == "60" && substage == "00"
35
+ @wordcoverpage = html_doc_path("word_iso_titlepage-prf.html")
63
36
  end
64
37
  end
65
38
 
@@ -71,13 +44,6 @@ module IsoDoc
71
44
  { class: "Tabletitle", style: "text-align:center;" }
72
45
  end
73
46
 
74
- def word_annex_cleanup1(docxml, lvl)
75
- docxml.xpath("//h#{lvl}[ancestor::*[@class = 'Section3']]").each do |h2|
76
- h2.name = "p"
77
- h2["class"] = "a#{lvl}"
78
- end
79
- end
80
-
81
47
  def span_parse(node, out)
82
48
  out.span **{ class: node["class"] } do |x|
83
49
  node.children.each { |n| parse(n, x) }
@@ -88,8 +54,8 @@ module IsoDoc
88
54
  <<~TOC.freeze
89
55
  <span lang="EN-GB"><span
90
56
  style='mso-element:field-begin'></span><span
91
- style='mso-spacerun:yes'>&#xA0;</span>TOC \\o &quot;2-#{level}&quot; \\h \\z \\t
92
- &quot;Heading 1;1;ANNEX;1;Biblio Title;1;Foreword Title;1;Intro Title;1;ANNEXN;1;ANNEXZ;1;na2;1;na3;1;na4;1;na5;1;na6;1;Title;1;Base_Heading;1;Box-title;1;Front Head;1;Index Head;1;AMEND Terms Heading;1;AMEND Heading 1 Unnumbered;1&quot;
57
+ style='mso-spacerun:yes'>&#xA0;</span>TOC \\o "2-#{level}" \\h \\z \\t
58
+ "Heading 1,1,ANNEX,1,Biblio Title,1,Foreword Title,1,Intro Title,1,ANNEXN,1,ANNEXZ,1,na2,1,na3,1,na4,1,na5,1,na6,1,Title,1,Base_Heading,1,Box-title,1,Front Head,1,Index Head,1,AMEND Terms Heading,1,AMEND Heading 1 Unnumbered,1"
93
59
  <span style='mso-element:field-separator'></span></span>
94
60
  TOC
95
61
  end
@@ -100,60 +66,10 @@ module IsoDoc
100
66
  ret
101
67
  end
102
68
 
103
- FIGURE_NESTED_STYLES =
104
- { Note: "Figurenote", example: "Figureexample" }.freeze
105
-
106
- def figure_style(docxml)
107
- docxml.xpath("//div[@class = 'figure']").each do |f|
108
- FIGURE_NESTED_STYLES.each do |k, v|
109
- f.xpath(".//*[@class = '#{k}']").each { |n| n["class"] = v }
110
- end
111
- f.xpath("./img").each do |i|
112
- i.replace("<p class='FigureGraphic'>#{i.to_xml}</p>")
113
- end
114
- end
115
- end
116
-
117
- def code_style(doc)
118
- span_style((doc.xpath("//tt//b") - doc.xpath("//tt//i//b")),
119
- "ISOCodebold")
120
- span_style((doc.xpath("//tt//i") - doc.xpath("//tt//b//i")),
121
- "ISOCodeitalic")
122
- span_style((doc.xpath("//b//tt") - doc.xpath("//b//i//tt")),
123
- "ISOCodebold")
124
- span_style((doc.xpath("//i//tt") - doc.xpath("//i//b//tt")),
125
- "ISOCodeitalic")
126
- span_style(doc.xpath("//tt"), "ISOCode")
127
- end
128
-
129
- def span_style(xpath, style)
130
- xpath.each do |elem|
131
- elem.name = "span"
132
- elem["class"] = style
133
- end
134
- end
135
-
136
69
  def make_tr_attr(cell, row, totalrows, header)
137
70
  super.merge(header: header)
138
71
  end
139
72
 
140
- def word_cleanup(docxml)
141
- word_table_cell_para(docxml)
142
- super
143
- end
144
-
145
- def word_table_cell_para(docxml)
146
- docxml.xpath("//td | //th").each do |t|
147
- s = t["header"] == "true" ? "Tableheader" : "Tablebody"
148
- t.delete("header")
149
- if t.at("./p |./div")
150
- t.xpath("./p | ./div").each { |p| p["class"] = s }
151
- else
152
- t.children = "<div class='#{s}'>#{t.children.to_xml}</div>"
153
- end
154
- end
155
- end
156
-
157
73
  def toWord(result, filename, dir, header)
158
74
  result = from_xhtml(word_cleanup(to_xhtml(result)))
159
75
  .gsub(/-DOUBLE_HYPHEN_ESCAPE-/, "--")
@@ -169,6 +85,38 @@ module IsoDoc
169
85
  header&.unlink
170
86
  @wordstylesheet.unlink if @wordstylesheet.is_a?(Tempfile)
171
87
  end
88
+
89
+ def middle_title(_isoxml, out)
90
+ middle_title_dis(out)
91
+ end
92
+
93
+ def middle_title_dis(out)
94
+ out.p(**{ class: "zzSTDTitle" }) do |p|
95
+ p << @meta.get[:doctitleintro]
96
+ @meta.get[:doctitleintro] && @meta.get[:doctitlemain] and p << " &#x2014; "
97
+ p << @meta.get[:doctitlemain]
98
+ @meta.get[:doctitlemain] && @meta.get[:doctitlepart] and p << " &#x2014; "
99
+ if @meta.get[:doctitlepart]
100
+ b = @meta.get[:doctitlepartlabel] and
101
+ p << "<span style='font-weight:normal'>#{b}</span> "
102
+ p << " #{@meta.get[:doctitlepart]}"
103
+ end
104
+ @meta.get[:doctitleamdlabel] || @meta.get[:doctitleamd] ||
105
+ @meta.get[:doctitlecorrlabel] and middle_title_dis_amd(p)
106
+ end
107
+ end
108
+
109
+ def middle_title_dis_amd(para)
110
+ para.span(**{ style: "font-weight:normal" }) do |p|
111
+ if a = @meta.get[:doctitleamdlabel]
112
+ p << " #{a}"
113
+ a = @meta.get[:doctitleamd] and p << ": #{a}"
114
+ end
115
+ if a = @meta.get[:doctitlecorrlabel]
116
+ p << " #{a}"
117
+ end
118
+ end
119
+ end
172
120
  end
173
121
  end
174
122
  end
@@ -77,11 +77,10 @@ module IsoDoc
77
77
  i = Counter.new
78
78
  clause.xpath(ns("./appendix")).each do |c|
79
79
  i.increment(c)
80
- @anchors[c["id"]] = anchor_struct(i.print, nil, @labels["appendix"],
81
- "clause")
82
- @anchors[c["id"]][:level] = 2
83
- @anchors[c["id"]][:subtype] = "annex"
84
- @anchors[c["id"]][:container] = clause["id"]
80
+ @anchors[c["id"]] =
81
+ anchor_struct(i.print, nil, @labels["appendix"],
82
+ "clause").merge(level: 2, subtype: "annex",
83
+ container: clause["id"])
85
84
  j = Counter.new
86
85
  c.xpath(ns("./clause | ./references")).each do |c1|
87
86
  j.increment(c1)
@@ -92,7 +91,7 @@ module IsoDoc
92
91
  end
93
92
 
94
93
  # subclauses are not prefixed with "Clause"
95
- # retaining sybtupe for the semantics
94
+ # retaining subtype for the semantics
96
95
  def section_names1(clause, num, level)
97
96
  @anchors[clause["id"]] =
98
97
  { label: num, level: level, xref: num, subtype: "clause" }
@@ -189,6 +188,35 @@ module IsoDoc
189
188
  def annex_name_lbl(clause, num)
190
189
  super.sub(%r{<br/>(.*)$}, "<br/><span class='obligation'>\\1</span>")
191
190
  end
191
+
192
+ def list_anchor_names(sections)
193
+ sections.each do |s|
194
+ notes = s.xpath(ns(".//ol")) - s.xpath(ns(".//clause//ol")) -
195
+ s.xpath(ns(".//appendix//ol")) - s.xpath(ns(".//ol//ol"))
196
+ c = Counter.new
197
+ notes.reject { |n| blank?(n["id"]) }.each do |n|
198
+ @anchors[n["id"]] = anchor_struct(increment_label(notes, n, c), n,
199
+ @labels["list"], "list", false)
200
+ list_item_anchor_names(n, @anchors[n["id"]], 1, "",
201
+ !single_ol_for_xrefs?(notes))
202
+ end
203
+ list_anchor_names(s.xpath(ns(CHILD_SECTIONS)))
204
+ end
205
+ end
206
+
207
+ # all li in the ol in lists are consecutively numbered through @start
208
+ def single_ol_for_xrefs?(lists)
209
+ return true if lists.size == 1
210
+
211
+ start = 0
212
+ lists.each_with_index do |l, i|
213
+ next if i.zero?
214
+
215
+ start += lists[i - 1].xpath(ns("./li")).size
216
+ return false unless l["start"]&.to_i == start + 1
217
+ end
218
+ true
219
+ end
192
220
  end
193
221
  end
194
222
  end
@@ -5,10 +5,16 @@ require "pathname"
5
5
  require "open-uri"
6
6
  require "isodoc"
7
7
  require "fileutils"
8
+ require_relative "macros"
8
9
 
9
10
  module Metanorma
10
11
  module ISO
11
12
  class Converter < Standoc::Converter
13
+ Asciidoctor::Extensions.register do
14
+ block Metanorma::ISO::EditorAdmonitionBlock
15
+ treeprocessor Metanorma::ISO::EditorInlineAdmonitionBlock
16
+ end
17
+
12
18
  XML_ROOT_TAG = "iso-standard".freeze
13
19
  XML_NAMESPACE = "https://www.metanorma.org/ns/iso".freeze
14
20
 
@@ -25,6 +31,10 @@ module Metanorma
25
31
  IsoDoc::Iso::WordConvert.new(doc_extract_attributes(node))
26
32
  end
27
33
 
34
+ def doc_extract_attributes(node)
35
+ super.merge(isowordtemplate: node.attr("iso-word-template"))
36
+ end
37
+
28
38
  def pdf_converter(node)
29
39
  return nil if node.attr("no-pdf")
30
40
 
@@ -49,7 +59,16 @@ module Metanorma
49
59
 
50
60
  def ol_attrs(node)
51
61
  attr_code(keep_attrs(node)
52
- .merge(id: ::Metanorma::Utils::anchor_or_uuid(node)))
62
+ .merge(id: ::Metanorma::Utils::anchor_or_uuid(node),
63
+ start: node.attr("start")))
64
+ end
65
+
66
+ def admonition_name(node)
67
+ name = super
68
+ a = node.attr("type") and ["editorial"].each do |t|
69
+ name = t if a.casecmp(t).zero?
70
+ end
71
+ name
53
72
  end
54
73
 
55
74
  def outputs(node, ret)