metanorma-iso 2.0.8 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/lib/html2doc/lists.rb +37 -0
  3. data/lib/isodoc/iso/base_convert.rb +1 -1
  4. data/lib/isodoc/iso/html/html_iso_titlepage.html +5 -0
  5. data/lib/isodoc/iso/html/isodoc-dis.css +304 -242
  6. data/lib/isodoc/iso/html/isodoc-dis.scss +379 -260
  7. data/lib/isodoc/iso/html/word_iso_intro-dis.html +7 -0
  8. data/lib/isodoc/iso/html/word_iso_titlepage-dis.html +4 -3
  9. data/lib/isodoc/iso/html/word_iso_titlepage.html +10 -4
  10. data/lib/isodoc/iso/html/wordstyle-dis.css +168 -48
  11. data/lib/isodoc/iso/html/wordstyle-dis.scss +158 -43
  12. data/lib/isodoc/iso/html_convert.rb +2 -2
  13. data/lib/isodoc/iso/i18n-en.yaml +1 -0
  14. data/lib/isodoc/iso/i18n-fr.yaml +1 -0
  15. data/lib/isodoc/iso/i18n-ru.yaml +1 -0
  16. data/lib/isodoc/iso/i18n-zh-Hans.yaml +1 -0
  17. data/lib/isodoc/iso/init.rb +17 -1
  18. data/lib/isodoc/iso/iso.amendment.xsl +1697 -426
  19. data/lib/isodoc/iso/iso.international-standard.xsl +1697 -426
  20. data/lib/isodoc/iso/metadata.rb +13 -19
  21. data/lib/isodoc/iso/presentation_inline.rb +90 -0
  22. data/lib/isodoc/iso/presentation_xml_convert.rb +41 -100
  23. data/lib/isodoc/iso/presentation_xref.rb +126 -0
  24. data/lib/isodoc/iso/sections.rb +2 -2
  25. data/lib/isodoc/iso/word_cleanup.rb +16 -2
  26. data/lib/isodoc/iso/word_convert.rb +29 -12
  27. data/lib/isodoc/iso/word_dis_convert.rb +183 -0
  28. data/lib/isodoc/iso/xref.rb +46 -25
  29. data/lib/metanorma/iso/biblio.rng +37 -8
  30. data/lib/metanorma/iso/boilerplate-fr.xml +1 -1
  31. data/lib/metanorma/iso/boilerplate-ru.xml +1 -3
  32. data/lib/metanorma/iso/boilerplate.xml +1 -3
  33. data/lib/metanorma/iso/cleanup.rb +2 -1
  34. data/lib/metanorma/iso/isodoc.rng +56 -0
  35. data/lib/metanorma/iso/version.rb +1 -1
  36. data/lib/metanorma-iso.rb +1 -0
  37. data/lib/relaton/render/config.yml +4 -0
  38. data/lib/relaton/render/general.rb +13 -0
  39. data/metanorma-iso.gemspec +1 -1
  40. data/spec/isodoc/amd_spec.rb +31 -30
  41. data/spec/isodoc/blocks_spec.rb +286 -179
  42. data/spec/isodoc/i18n_spec.rb +187 -21
  43. data/spec/isodoc/inline_spec.rb +35 -42
  44. data/spec/isodoc/iso_spec.rb +1 -1
  45. data/spec/isodoc/metadata_spec.rb +17 -17
  46. data/spec/isodoc/postproc_spec.rb +28 -3
  47. data/spec/isodoc/ref_spec.rb +66 -69
  48. data/spec/isodoc/section_spec.rb +78 -76
  49. data/spec/isodoc/table_spec.rb +2 -2
  50. data/spec/isodoc/terms_spec.rb +2 -2
  51. data/spec/isodoc/word_dis_spec.rb +760 -0
  52. data/spec/isodoc/xref_spec.rb +51 -51
  53. data/spec/metanorma/base_spec.rb +10 -10
  54. data/spec/spec_helper.rb +11 -1
  55. data/spec/vcr_cassettes/withdrawn_iso.yml +26 -26
  56. metadata +11 -5
  57. data/spec/vcr_cassettes/docrels.yml +0 -385
@@ -21,8 +21,7 @@ module IsoDoc
21
21
  stage = "DTS" if stage == "DIS"
22
22
  stage = "FDTS" if stage == "FDIS"
23
23
  end
24
- %w(PWI NWIP WD CD).include?(stage) && iter and
25
- stage += iter
24
+ %w(PWI NWIP WD CD).include?(stage) && iter and stage += iter
26
25
  stage = "Pre#{stage}" if /^0\./.match?(draft)
27
26
  stage
28
27
  end
@@ -32,9 +31,7 @@ module IsoDoc
32
31
  set(:unpublished, false)
33
32
  revdate = isoxml.at(ns("//bibdata/version/revision-date"))
34
33
  set(:revdate, revdate&.text)
35
- if docstatus
36
- docstatus1(isoxml, docstatus)
37
- end
34
+ docstatus and docstatus1(isoxml, docstatus)
38
35
  end
39
36
 
40
37
  def docstatus1(isoxml, docstatus)
@@ -97,25 +94,25 @@ module IsoDoc
97
94
  suffix = @c.encode(part.text, :hexadecimal)
98
95
  p = titlenums[:part]
99
96
  titlenums[:part] && titlenums[:subpart] and
100
- p = "#{titlenums[:part]}–#{titlenums[:subpart]}"
97
+ p = "#{titlenums[:part]}–#{titlenums[:subpart]}"
101
98
  titlenums[:part] and
102
- suffix = "#{part_label(lang)} #{p}: " + suffix
99
+ suffix = "#{part_label(lang)} #{p}: " + suffix
103
100
  suffix
104
101
  end
105
102
 
106
103
  def part_prefix(titlenums, lang)
107
104
  p = titlenums[:part]
108
105
  titlenums[:part] && titlenums[:subpart] and
109
- p = "#{titlenums[:part]}–#{titlenums[:subpart]}"
110
- "#{part_label(lang)} #{p}"
106
+ p = "#{titlenums[:part]}–#{titlenums[:subpart]}"
107
+ "#{part_label(lang)} #{p}"
111
108
  end
112
109
 
113
110
  def amd_prefix(titlenums, lang)
114
- "#{amd_label(lang)} #{titlenums[:amd]}"
111
+ "#{amd_label(lang)} #{titlenums[:amd]}"
115
112
  end
116
113
 
117
114
  def corr_prefix(titlenums, lang)
118
- "#{corr_label(lang)} #{titlenums[:corr]}"
115
+ "#{corr_label(lang)} #{titlenums[:corr]}"
119
116
  end
120
117
 
121
118
  def compose_title(tparts, tnums, lang)
@@ -124,10 +121,10 @@ module IsoDoc
124
121
  main = @c.encode(tparts[:main].text, :hexadecimal)
125
122
  tparts[:intro] &&
126
123
  main = "#{@c.encode(tparts[:intro].text,
127
- :hexadecimal)} — #{main}"
124
+ :hexadecimal)} — #{main}"
128
125
  if tparts[:part]
129
126
  suffix = part_title(tparts[:part], tnums, lang)
130
- main = "#{main} — #{suffix}"
127
+ main = "#{main} — #{suffix}"
131
128
  end
132
129
  main
133
130
  end
@@ -164,10 +161,9 @@ module IsoDoc
164
161
  @c.encode(tp[:main] ? tp[:main].text : "", :hexadecimal))
165
162
  main = compose_title(tp, tn, lang)
166
163
  set(:doctitle, main)
167
- if tp[:intro]
164
+ tp[:intro] and
168
165
  set(:doctitleintro,
169
166
  @c.encode(tp[:intro] ? tp[:intro].text : "", :hexadecimal))
170
- end
171
167
  set(:doctitlepartlabel, part_prefix(tn, lang))
172
168
  set(:doctitlepart, @c.encode(tp[:part].text, :hexadecimal)) if tp[:part]
173
169
  set(:doctitleamdlabel, amd_prefix(tn, lang)) if tn[:amd]
@@ -184,15 +180,13 @@ module IsoDoc
184
180
  @c.encode(tp[:main] ? tp[:main].text : "", :hexadecimal))
185
181
  main = compose_title(tp, tn, lang)
186
182
  set(:docsubtitle, main)
187
- if tp[:intro]
183
+ tp[:intro] and
188
184
  set(:docsubtitleintro,
189
185
  @c.encode(tp[:intro] ? tp[:intro].text : "", :hexadecimal))
190
- end
191
186
  set(:docsubtitlepartlabel, part_prefix(tn, lang))
192
- if tp[:part]
187
+ tp[:part] and
193
188
  set(:docsubtitlepart,
194
189
  @c.encode(tp[:part].text, :hexadecimal))
195
- end
196
190
  set(:docsubtitleamdlabel, amd_prefix(tn, lang)) if tn[:amd]
197
191
  set(:docsubtitleamd, @c.encode(tp[:amd].text, :hexadecimal)) if tp[:amd]
198
192
  set(:docsubtitlecorrlabel, corr_prefix(tn, lang)) if tn[:corr]
@@ -0,0 +1,90 @@
1
+ module IsoDoc
2
+ module Iso
3
+ class PresentationXMLConvert < IsoDoc::PresentationXMLConvert
4
+ def xref_init(lang, script, klass, labels, options)
5
+ @xrefs = Xref.new(lang, script, klass, labels, options)
6
+ end
7
+
8
+ def eref_delim(delim, type)
9
+ if delim == ";" then ";"
10
+ else type == "list" ? " " : delim
11
+ end
12
+ end
13
+
14
+ def can_conflate_eref_rendering?(refs)
15
+ super or return false
16
+
17
+ first = subclause?(nil, refs.first.at(ns("./locality/@type"))&.text,
18
+ refs.first.at(ns("./locality/referenceFrom"))&.text)
19
+ refs.all? do |r|
20
+ subclause?(nil, r.at(ns("./locality/@type"))&.text,
21
+ r.at(ns("./locality/referenceFrom"))&.text) == first
22
+ end
23
+ end
24
+
25
+ def locality_delimiter(loc)
26
+ loc&.next_element&.attribute("type")&.text == "list" and return " "
27
+ super
28
+ end
29
+
30
+ def eref_localities_conflated(refs, target, node)
31
+ droploc = node["droploc"]
32
+ node["droploc"] = true
33
+ ret = resolve_eref_connectives(eref_locality_stacks(refs, target,
34
+ node))
35
+ node["droploc"] = droploc
36
+ eref_localities1(target,
37
+ prefix_clause(target, refs.first.at(ns("./locality"))),
38
+ l10n(ret[1..-1].join), nil, node, @lang)
39
+ end
40
+
41
+ def prefix_clause(target, loc)
42
+ loc["type"] == "clause" or return loc["type"]
43
+
44
+ if subclause?(target, loc["type"],
45
+ loc&.at(ns("./referenceFrom"))&.text)
46
+ ""
47
+ else
48
+ "clause"
49
+ end
50
+ end
51
+
52
+ def subclause?(target, type, from)
53
+ (from&.match?(/\./) && type == "clause") ||
54
+ type == "list" || target&.match(/^IEV$|^IEC 60050-/)
55
+ end
56
+
57
+ def eref_localities1_zh(target, type, from, upto, node)
58
+ ret = " 第#{from}" if from
59
+ ret += "&#x2013;#{upto}" if upto
60
+ if node["droploc"] != "true" && !subclause?(target, type, from)
61
+ ret += eref_locality_populate(type, node)
62
+ end
63
+ ret += ")" if type == "list"
64
+ ret
65
+ end
66
+
67
+ def eref_localities1(target, type, from, upto, node, lang = "en")
68
+ return nil if type == "anchor"
69
+
70
+ type = type.downcase
71
+ lang == "zh" and
72
+ return l10n(eref_localities1_zh(target, type, from, upto, node))
73
+ ret = if node["droploc"] != "true" && !subclause?(target, type,
74
+ from)
75
+ eref_locality_populate(type, node)
76
+ else ""
77
+ end
78
+ ret += " #{from}" if from
79
+ ret += "&#x2013;#{upto}" if upto
80
+ ret += ")" if type == "list"
81
+ l10n(ret)
82
+ end
83
+
84
+ def prefix_container(container, linkend, target)
85
+ delim = @xrefs.anchor(target, :type) == "listitem" ? " " : ", "
86
+ l10n(@xrefs.anchor(container, :xref) + delim + linkend)
87
+ end
88
+ end
89
+ end
90
+ end
@@ -1,11 +1,15 @@
1
1
  require_relative "init"
2
2
  require "isodoc"
3
3
  require_relative "index"
4
+ require_relative "presentation_inline"
5
+ require_relative "presentation_xref"
6
+ require_relative "../../relaton/render/general"
4
7
 
5
8
  module IsoDoc
6
9
  module Iso
7
10
  class PresentationXMLConvert < IsoDoc::PresentationXMLConvert
8
11
  def convert1(docxml, filename, dir)
12
+ @iso_class = instance_of?(IsoDoc::Iso::PresentationXMLConvert)
9
13
  if amd(docxml)
10
14
  @oldsuppressheadingnumbers = @suppressheadingnumbers
11
15
  @suppressheadingnumbers = true
@@ -22,104 +26,19 @@ module IsoDoc
22
26
  amd(isoxml) and @suppressheadingnumbers = true
23
27
  end
24
28
 
25
- def xref_init(lang, script, klass, labels, options)
26
- @xrefs = Xref.new(lang, script, klass, labels, options)
27
- end
28
-
29
29
  def figure1(node)
30
30
  lbl = @xrefs.anchor(node["id"], :label, false) or return
31
31
  figname = node.parent.name == "figure" ? "" : "#{@i18n.figure} "
32
- connective = node.parent.name == "figure" ? "&nbsp; " : "&nbsp;&mdash; "
32
+ connective = node.parent.name == "figure" ? "&#xa0; " : "&#xa0;&#x2014; "
33
33
  prefix_name(node, connective, l10n("#{figname}#{lbl}"), "name")
34
34
  end
35
35
 
36
36
  def example1(node)
37
37
  n = @xrefs.get[node["id"]]
38
- lbl = if n.nil? || n[:label].nil? || n[:label].empty?
39
- @i18n.example
40
- else
41
- l10n("#{@i18n.example} #{n[:label]}")
38
+ lbl = if n.nil? || blank?(n[:label]) then @i18n.example
39
+ else l10n("#{@i18n.example} #{n[:label]}")
42
40
  end
43
- prefix_name(node, "&nbsp;&mdash; ", lbl, "name")
44
- end
45
-
46
- def eref_delim(delim, type)
47
- if delim == ";" then ";"
48
- else type == "list" ? " " : delim
49
- end
50
- end
51
-
52
- def can_conflate_eref_rendering?(refs)
53
- super or return false
54
-
55
- first = subclause?(nil, refs.first.at(ns("./locality/@type"))&.text,
56
- refs.first.at(ns("./locality/referenceFrom"))&.text)
57
- refs.all? do |r|
58
- subclause?(nil, r.at(ns("./locality/@type"))&.text,
59
- r.at(ns("./locality/referenceFrom"))&.text) == first
60
- end
61
- end
62
-
63
- def locality_delimiter(loc)
64
- loc&.next_element&.attribute("type")&.text == "list" and return " "
65
- super
66
- end
67
-
68
- def eref_localities_conflated(refs, target, node)
69
- droploc = node["droploc"]
70
- node["droploc"] = true
71
- ret = resolve_eref_connectives(eref_locality_stacks(refs, target,
72
- node))
73
- node["droploc"] = droploc
74
- eref_localities1(target,
75
- prefix_clause(target, refs.first.at(ns("./locality"))),
76
- l10n(ret[1..-1].join), nil, node, @lang)
77
- end
78
-
79
- def prefix_clause(target, loc)
80
- loc["type"] == "clause" or return loc["type"]
81
-
82
- if subclause?(target, loc["type"], loc&.at(ns("./referenceFrom"))&.text)
83
- ""
84
- else
85
- "clause"
86
- end
87
- end
88
-
89
- def subclause?(target, type, from)
90
- (from&.match?(/\./) && type == "clause") ||
91
- type == "list" || target&.match(/^IEV$|^IEC 60050-/)
92
- end
93
-
94
- def eref_localities1_zh(target, type, from, upto, node)
95
- ret = " 第#{from}" if from
96
- ret += "&ndash;#{upto}" if upto
97
- if node["droploc"] != "true" && !subclause?(target, type, from)
98
- ret += eref_locality_populate(type, node)
99
- end
100
- ret += ")" if type == "list"
101
- ret
102
- end
103
-
104
- def eref_localities1(target, type, from, upto, node, lang = "en")
105
- return nil if type == "anchor"
106
-
107
- type = type.downcase
108
- lang == "zh" and
109
- return l10n(eref_localities1_zh(target, type, from, upto, node))
110
- ret = if node["droploc"] != "true" && !subclause?(target, type, from)
111
- eref_locality_populate(type, node)
112
- else ""
113
- end
114
- ret += " #{from}" if from
115
- ret += "&ndash;#{upto}" if upto
116
- ret += ")" if type == "list"
117
- l10n(ret)
118
- end
119
-
120
- def prefix_container(container, linkend, target)
121
- delim = @xrefs.anchor(target, :type) == "listitem" ? " " : ", "
122
- l10n(@xrefs.anchor(container, :xref) + delim + linkend)
41
+ prefix_name(node, "&#xa0;&#x2014; ", lbl, "name")
123
42
  end
124
43
 
125
44
  def example_span_label(_node, div, name)
@@ -141,8 +60,7 @@ module IsoDoc
141
60
  def clause(docxml)
142
61
  docxml.xpath(ns("//clause[not(ancestor::annex)] | "\
143
62
  "//terms | //definitions | //references | "\
144
- "//preface/introduction[clause]"))
145
- .each do |f|
63
+ "//preface/introduction[clause]")).each do |f|
146
64
  clause1(f)
147
65
  end
148
66
  end
@@ -158,9 +76,7 @@ module IsoDoc
158
76
  def concept_term(docxml)
159
77
  docxml.xpath(ns("//term")).each do |f|
160
78
  m = {}
161
- f.xpath(ns(".//concept")).each do |c|
162
- concept_term1(c, m)
163
- end
79
+ f.xpath(ns(".//concept")).each { |c| concept_term1(c, m) }
164
80
  end
165
81
  end
166
82
 
@@ -177,12 +93,11 @@ module IsoDoc
177
93
  end
178
94
 
179
95
  def concept1_ref_content(ref)
180
- if ref.name == "termref"
181
- ref.replace(@i18n.term_defined_in.sub(/%/,
182
- ref.to_xml))
183
- else
184
- ref.replace("(#{ref.to_xml})")
185
- end
96
+ repl = if ref.name == "termref"
97
+ @i18n.term_defined_in.sub(/%/, ref.to_xml)
98
+ else "(#{ref.to_xml})"
99
+ end
100
+ ref.replace(repl)
186
101
  end
187
102
 
188
103
  def concept1(node)
@@ -244,6 +159,32 @@ module IsoDoc
244
159
  super
245
160
  end
246
161
 
162
+ def admonition1(elem)
163
+ super
164
+ return unless n = elem.at(ns("./name"))
165
+
166
+ p = n.next_element
167
+ return unless p.name == "p"
168
+
169
+ p.children.first.previous = admonition_name(n.remove.children.to_xml)
170
+ end
171
+
172
+ def admonition_name(xml)
173
+ "#{xml} &#x2014; "
174
+ end
175
+
176
+ def bibrenderer
177
+ ::Relaton::Render::Iso::General.new(language: @lang, i18nhash: @i18n.get)
178
+ end
179
+
180
+ def bibrender(xml)
181
+ unless xml.at(ns("./formattedref"))
182
+ xml.children =
183
+ "#{bibrenderer.render(xml.to_xml)}"\
184
+ "#{xml.xpath(ns('./docidentifier | ./uri | ./note')).to_xml}"
185
+ end
186
+ end
187
+
247
188
  include Init
248
189
  end
249
190
  end
@@ -0,0 +1,126 @@
1
+ module IsoDoc
2
+ module Iso
3
+ class PresentationXMLConvert < IsoDoc::PresentationXMLConvert
4
+ def xref_init(lang, script, klass, labels, options)
5
+ @xrefs = Xref.new(lang, script, klass, labels, options)
6
+ end
7
+
8
+ def eref_delim(delim, type)
9
+ if delim == ";" then ";"
10
+ else type == "list" ? " " : delim
11
+ end
12
+ end
13
+
14
+ def can_conflate_eref_rendering?(refs)
15
+ super or return false
16
+
17
+ first = subclause?(nil, refs.first.at(ns("./locality/@type"))&.text,
18
+ refs.first.at(ns("./locality/referenceFrom"))&.text)
19
+ refs.all? do |r|
20
+ subclause?(nil, r.at(ns("./locality/@type"))&.text,
21
+ r.at(ns("./locality/referenceFrom"))&.text) == first
22
+ end
23
+ end
24
+
25
+ def locality_delimiter(loc)
26
+ loc&.next_element&.attribute("type")&.text == "list" and return " "
27
+ super
28
+ end
29
+
30
+ def eref_localities_conflated(refs, target, node)
31
+ droploc = node["droploc"]
32
+ node["droploc"] = true
33
+ ret = resolve_eref_connectives(eref_locality_stacks(refs, target,
34
+ node))
35
+ node["droploc"] = droploc
36
+ eref_localities1(target,
37
+ prefix_clause(target, refs.first.at(ns("./locality"))),
38
+ l10n(ret[1..-1].join), nil, node, @lang)
39
+ end
40
+
41
+ def prefix_clause(target, loc)
42
+ loc["type"] == "clause" or return loc["type"]
43
+
44
+ if subclause?(target, loc["type"],
45
+ loc&.at(ns("./referenceFrom"))&.text)
46
+ ""
47
+ else "clause"
48
+ end
49
+ end
50
+
51
+ def subclause?(target, type, from)
52
+ (from&.match?(/\./) && type == "clause") ||
53
+ type == "list" ||
54
+ target&.gsub(/<[^>]+>/, "")&.match(/^IEV$|^IEC 60050-/)
55
+ end
56
+
57
+ LOCALITY2SPAN = {
58
+ annex: "citeapp",
59
+ dunno: "citebase",
60
+ dunno2: "citebib",
61
+ dunno3: "citebox",
62
+ dunno4: "citeen",
63
+ dunno5: "citeeq",
64
+ figure: "citefig",
65
+ dunno6: "citefn",
66
+ clause: "citesec",
67
+ dunno7: "citesection",
68
+ table: "citetbl",
69
+ dunno8: "citetfn",
70
+ }.freeze
71
+
72
+ def locality_span_wrap(ret, type)
73
+ type or return ret
74
+ m = /^(\s*)(.+?)(\s*)$/.match(ret) or return ret
75
+ ret = [m[1], m[2], m[3]]
76
+ spanclass = LOCALITY2SPAN[type.to_sym] and
77
+ ret[1] = "<span class='#{spanclass}'>#{ret[1]}</span>"
78
+ ret.join
79
+ end
80
+
81
+ def eref_localities1_zh(target, type, from, upto, node)
82
+ ret = " 第#{from}" if from
83
+ ret += "&#x2013;#{upto}" if upto
84
+ node["droploc"] != "true" && !subclause?(target, type, from) and
85
+ ret += eref_locality_populate(type, node)
86
+ ret += ")" if type == "list"
87
+ locality_span_wrap(ret, type)
88
+ end
89
+
90
+ def eref_localities1(target, type, from, upto, node, lang = "en")
91
+ return nil if type == "anchor"
92
+
93
+ type = type.downcase
94
+ lang == "zh" and
95
+ return l10n(eref_localities1_zh(target, type, from, upto, node))
96
+ ret = ""
97
+ node["droploc"] != "true" && !subclause?(target, type, from) and
98
+ ret = eref_locality_populate(type, node)
99
+ ret += " #{from}" if from
100
+ ret += "&#x2013;#{upto}" if upto
101
+ ret += ")" if type == "list"
102
+ ret = l10n(ret)
103
+ locality_span_wrap(ret, type)
104
+ end
105
+
106
+ def prefix_container(container, linkend, target)
107
+ delim = @xrefs.anchor(target, :type) == "listitem" ? " " : ", "
108
+ l10n(@xrefs.anchor(container, :xref) + delim + linkend)
109
+ end
110
+
111
+ def expand_citeas(text)
112
+ std_docid_semantic(super)
113
+ end
114
+
115
+ def anchor_value(id)
116
+ locality_span_wrap(super, @xrefs.anchor(id, :subtype) ||
117
+ @xrefs.anchor(id, :type))
118
+ end
119
+
120
+ def anchor_linkend1(node)
121
+ locality_span_wrap(super, @xrefs.anchor(node["target"], :subtype) ||
122
+ @xrefs.anchor(node["target"], :type))
123
+ end
124
+ end
125
+ end
126
+ end
@@ -9,9 +9,9 @@ module IsoDoc
9
9
  def middle_title_main(out)
10
10
  out.p(**{ class: "zzSTDTitle1" }) do |p|
11
11
  p << @meta.get[:doctitleintro]
12
- p << " &mdash; " if @meta.get[:doctitleintro] && @meta.get[:doctitlemain]
12
+ p << " &#x2014; " if @meta.get[:doctitleintro] && @meta.get[:doctitlemain]
13
13
  p << @meta.get[:doctitlemain]
14
- p << " &mdash; " if @meta.get[:doctitlemain] && @meta.get[:doctitlepart]
14
+ p << " &#x2014; " if @meta.get[:doctitlemain] && @meta.get[:doctitlepart]
15
15
  end
16
16
  a = @meta.get[:doctitlepart] and out.p(**{ class: "zzSTDTitle2" }) do |p|
17
17
  b = @meta.get[:doctitlepartlabel] and p << "#{b}: "
@@ -65,7 +65,7 @@ module IsoDoc
65
65
  insert = docxml.at("//div[@id = 'boilerplate-license-destination']")
66
66
  auth = docxml&.at("//div[@class = 'boilerplate-license']")&.remove
67
67
  auth&.xpath(".//p[not(@class)]")&.each { |p| p["class"] = "zzWarning" }
68
- auth and insert.children = auth
68
+ auth and insert and insert.children = auth
69
69
  insert = docxml.at("//div[@id = 'boilerplate-copyright-destination']")
70
70
  auth = docxml&.at("//div[@class = 'boilerplate-copyright']")&.remove
71
71
  auth&.xpath(".//p[not(@class)]")&.each do |p|
@@ -80,7 +80,8 @@ module IsoDoc
80
80
  auth&.xpath(".//p[@id = 'boilerplate-place']")&.each do |p|
81
81
  p["class"] = "zzCopyright1"
82
82
  end
83
- auth and insert.children = auth
83
+ auth and insert and insert.children = auth
84
+ coverpage_note_cleanup(docxml)
84
85
  end
85
86
 
86
87
  def word_cleanup(docxml)
@@ -89,6 +90,19 @@ module IsoDoc
89
90
  style_cleanup(docxml)
90
91
  docxml
91
92
  end
93
+
94
+ # supply missing annex title
95
+ def make_WordToC(docxml, level)
96
+ toc = ""
97
+ xpath = (1..level).each.map { |i| "//h#{i}" }.join (" | ")
98
+ docxml.xpath(xpath).each do |h|
99
+ x = ""
100
+ x = @anchor[h.parent["id"]][:xref] if h["class"] == "ANNEX"
101
+ toc += word_toc_entry(h.name[1].to_i, x + header_strip(h))
102
+ end
103
+ toc.sub(/(<p class="MsoToc1">)/,
104
+ %{\\1#{word_toc_preface(level)}}) + WORD_TOC_SUFFIX1
105
+ end
92
106
  end
93
107
  end
94
108
  end
@@ -2,6 +2,7 @@ require_relative "base_convert"
2
2
  require "isodoc"
3
3
  require_relative "init"
4
4
  require_relative "word_cleanup"
5
+ require_relative "word_dis_convert"
5
6
 
6
7
  module IsoDoc
7
8
  module Iso
@@ -13,6 +14,11 @@ module IsoDoc
13
14
  @wordToClevels = 3 if @wordToClevels.zero?
14
15
  @htmlToClevels = options[:htmltoclevels].to_i
15
16
  @htmlToClevels = 3 if @htmlToClevels.zero?
17
+ init_dis
18
+ end
19
+
20
+ def init_dis
21
+ @dis = ::IsoDoc::Iso::WordDISConvert.new(options)
16
22
  end
17
23
 
18
24
  def font_choice(options)
@@ -45,16 +51,16 @@ module IsoDoc
45
51
  olstyle: "l2" }
46
52
  end
47
53
 
48
- def convert1(docxml, filename, dir)
49
- @dis = /^[45].$/.match?(docxml&.at(ns("//bibdata/status/stage"))&.text)
50
- if @dis
51
- @wordstylesheet_name = html_doc_path("wordstyle-dis.scss")
52
- @standardstylesheet_name = html_doc_path("isodoc-dis.scss")
53
- @wordcoverpage = html_doc_path("word_iso_titlepage-dis.html")
54
- @wordintropage = html_doc_path("word_iso_intro-dis.html")
55
- @header = html_doc_path("header-dis.html")
54
+ def convert(input_filename, file = nil, debug = false,
55
+ output_filename = nil)
56
+ file = File.read(input_filename, encoding: "utf-8") if file.nil?
57
+ docxml = Nokogiri::XML(file) { |config| config.huge }
58
+ if @dis &&
59
+ /^[45].$/.match?(docxml&.at(ns("//bibdata/status/stage"))&.text)
60
+ @dis.convert(input_filename, file, debug, output_filename)
61
+ else
62
+ super
56
63
  end
57
- super
58
64
  end
59
65
 
60
66
  def make_body(xml, docxml)
@@ -82,8 +88,8 @@ module IsoDoc
82
88
  <span lang="EN-GB"><span
83
89
  style='mso-element:field-begin'></span><span
84
90
  style='mso-spacerun:yes'>&#xA0;</span>TOC
85
- \\o &quot;1-#{level}&quot; \\h \\z \\t &quot;Heading
86
- 1;1;ANNEX;1;Biblio Title;1;Foreword Title;1;Intro Title;1&quot; <span
91
+ \\o "1-#{level}" \\h \\z \\t "Heading
92
+ 1;1;ANNEX;1;Biblio Title;1;Foreword Title;1;Intro Title;1" <span
87
93
  style='mso-element:field-separator'></span></span>
88
94
  TOC
89
95
  end
@@ -171,11 +177,22 @@ module IsoDoc
171
177
 
172
178
  name&.at(ns("./strong"))&.remove # supplied by CSS list numbering
173
179
  div.h1 **{ class: "Annex" } do |t|
174
- name.children.each { |c2| parse(c2, t) }
180
+ annex_name1(name, t)
175
181
  clause_parse_subtitle(name, t)
176
182
  end
177
183
  end
178
184
 
185
+ def annex_name1(name, out)
186
+ name.children.each do |c2|
187
+ if c2.name == "span" && c2["class"] == "obligation"
188
+ out.span **{ style: "font-weight:normal;" } do |s|
189
+ c2.children.each { |c3| parse(c3, s) }
190
+ end
191
+ else parse(c2, out)
192
+ end
193
+ end
194
+ end
195
+
179
196
  include BaseConvert
180
197
  include Init
181
198
  end