metanorma-iso 2.1.1 → 2.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/lib/html2doc/lists.rb +145 -10
  3. data/lib/isodoc/iso/base_convert.rb +10 -0
  4. data/lib/isodoc/iso/html/html_iso_titlepage.html +2 -0
  5. data/lib/isodoc/iso/html/isodoc-dis.css +173 -257
  6. data/lib/isodoc/iso/html/isodoc-dis.scss +173 -249
  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 +6 -2
  17. data/lib/isodoc/iso/html_convert.rb +5 -0
  18. data/lib/isodoc/iso/i18n-en.yaml +32 -4
  19. data/lib/isodoc/iso/i18n-fr.yaml +29 -3
  20. data/lib/isodoc/iso/i18n-ru.yaml +32 -4
  21. data/lib/isodoc/iso/i18n-zh-Hans.yaml +32 -3
  22. data/lib/isodoc/iso/i18n.rb +1 -1
  23. data/lib/isodoc/iso/iso.amendment.xsl +750 -307
  24. data/lib/isodoc/iso/iso.international-standard.xsl +750 -307
  25. data/lib/isodoc/iso/metadata.rb +63 -63
  26. data/lib/isodoc/iso/presentation_bibdata.rb +74 -0
  27. data/lib/isodoc/iso/presentation_xml_convert.rb +15 -4
  28. data/lib/isodoc/iso/presentation_xref.rb +8 -2
  29. data/lib/isodoc/iso/sections.rb +1 -1
  30. data/lib/isodoc/iso/word_cleanup.rb +3 -0
  31. data/lib/isodoc/iso/word_convert.rb +6 -3
  32. data/lib/isodoc/iso/word_dis_cleanup.rb +243 -0
  33. data/lib/isodoc/iso/word_dis_convert.rb +47 -108
  34. data/lib/isodoc/iso/xref.rb +34 -6
  35. data/lib/metanorma/iso/base.rb +14 -1
  36. data/lib/metanorma/iso/biblio.rng +134 -39
  37. data/lib/metanorma/iso/boilerplate-fr.xml +3 -0
  38. data/lib/metanorma/iso/boilerplate-ru.xml +3 -0
  39. data/lib/metanorma/iso/boilerplate.xml +3 -0
  40. data/lib/metanorma/iso/cleanup.rb +53 -13
  41. data/lib/metanorma/iso/front.rb +38 -6
  42. data/lib/metanorma/iso/front_id.rb +2 -0
  43. data/lib/metanorma/iso/isodoc.rng +32 -0
  44. data/lib/metanorma/iso/isostandard.rng +32 -12
  45. data/lib/metanorma/iso/validate_section.rb +0 -12
  46. data/lib/metanorma/iso/version.rb +1 -1
  47. data/spec/isodoc/amd_spec.rb +4 -30
  48. data/spec/isodoc/blocks_spec.rb +499 -2
  49. data/spec/isodoc/i18n_spec.rb +145 -80
  50. data/spec/isodoc/iso_spec.rb +50 -169
  51. data/spec/isodoc/metadata_spec.rb +223 -83
  52. data/spec/isodoc/postproc_spec.rb +41 -5
  53. data/spec/isodoc/section_spec.rb +9 -9
  54. data/spec/isodoc/word_dis_spec.rb +1332 -146
  55. data/spec/isodoc/xref_spec.rb +87 -13
  56. data/spec/metanorma/amd_spec.rb +39 -23
  57. data/spec/metanorma/base_spec.rb +174 -44
  58. data/spec/metanorma/blocks_spec.rb +21 -0
  59. data/spec/metanorma/cleanup_spec.rb +196 -196
  60. data/spec/metanorma/lists_spec.rb +2 -2
  61. data/spec/metanorma/section_spec.rb +2 -2
  62. data/spec/metanorma/validate_spec.rb +8 -19
  63. data/spec/spec_helper.rb +10 -7
  64. data/spec/vcr_cassettes/withdrawn_iso.yml +30 -30
  65. metadata +6 -8
  66. data/docs/asciiiso-syntax.adoc +0 -307
  67. data/docs/guidance.adoc +0 -487
  68. data/docs/navigation.adoc +0 -23
  69. data/docs/quickstart.adoc +0 -179
  70. data/lib/isodoc/iso/presentation_inline.rb +0 -90
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3154af64aad28148d931cad79a5e4ba8633d7fe8db27dd87b1c721d660a46e27
4
- data.tar.gz: 784bb188b1397fabf8978e5896382b3dd724ab0458f2b758268b8ffb202ab6fc
3
+ metadata.gz: da005628ba019121c2c72d9e74dcfe32dcd01fc555d7cc14d2a9936766375d51
4
+ data.tar.gz: 1e415f917d4d2737ecfad1b15bdcb6f4071d2c35df4b8a91e94926d7434c081d
5
5
  SHA512:
6
- metadata.gz: 53719e79cd10a8b3f8cf6df804e9dd6e89c365eadbb8c3a6e6a3cf7881162b4d68dcf49daf27fd324960d36981ee16d49abd03ee1abe507e070c75524d382939
7
- data.tar.gz: b9cce4a6a713f9d6844359a1ddd25f6771adb754418d4662b415840f6885b86020ff5c929dbdf234f76c19eee61df0572c037607d021d1f5d6ca746450065bfd
6
+ metadata.gz: a7d82b3fe97c1e2ed1a078c335d97b32f16f23f0d0640e97d978ec8fb7b99243f023cc8ef9946f0c5f2a425daa0bb657cf14c61691c1f943b6790645901b08e1
7
+ data.tar.gz: faf3e8a9eff4650f60b7a4db80d429e1c7c9b68b9de1e9b708cf0d49030d62b1b62bc2114a581ac09db40c8eae7f97ee81e6f17a8036e3cc0ff62e5067e15dd1
@@ -4,17 +4,45 @@ class Html2Doc
4
4
  return if list.xpath("./li").empty?
5
5
 
6
6
  list.xpath("./li").each do |l|
7
- l.name = "p"
8
- if m = /level(\d) lfo/.match(l["style"])
9
- l["class"] = list2para_style(list.name, m[1])
10
- l.xpath("./p").each do |p|
11
- p["class"] = list2para_style(list.name, m[1])
12
- end
13
- end
14
- l&.first_element_child&.name == "p" and
15
- l.first_element_child.replace(l.first_element_child.children)
7
+ list2para_level(l, list)
8
+ end
9
+ end
10
+
11
+ def list2para_level(item, list)
12
+ level = item["level"]
13
+ item.delete("level")
14
+ item.name = "p"
15
+ list2para_nest(item, level, list) if level
16
+ end
17
+
18
+ def list2para_nest(item, level, list)
19
+ item["class"] = list2para_style(list.name, level)
20
+ item.xpath("./p").each do |p|
21
+ p["class"] = list2para_style(list.name, level)
22
+ end
23
+ p1 = item.at("./p") or return
24
+ prev = p1.xpath("./preceding-sibling::* | ./preceding-sibling::text()")
25
+ if prev[-1].name == "span" && prev[-1]["style"] == "mso-tab-count:1" &&
26
+ prev.size == 2
27
+ p1.children.first.previous = prev[1]
28
+ p1.children.first.previous = prev[0]
29
+ end
30
+ end
31
+
32
+ def list2para_unnest_para(para, first_p, last_p)
33
+ return if last_p.xpath("./following-sibling::* | ./following-sibling::text()")
34
+ .any? do |x|
35
+ !x.text.strip.empty?
36
+ end
37
+
38
+ prev = first_p.xpath("./preceding-sibling::* | "\
39
+ "./preceding-sibling::text()[normalize-space()]")
40
+ # bullet, tab, paragraph: ignore bullet, tab
41
+ if prev.empty? then para.replace(para.children)
42
+ elsif prev.size == 2 && prev[-1].name == "span" &&
43
+ prev[-1]["style"] == "mso-tab-count:1"
44
+ first_p.replace(first_p.children)
16
45
  end
17
- list.replace(list.children)
18
46
  end
19
47
 
20
48
  def list2para_style(listtype, depth)
@@ -33,5 +61,112 @@ class Html2Doc
33
61
  end
34
62
  end
35
63
  end
64
+
65
+ def lists(docxml, liststyles)
66
+ super
67
+ docxml.xpath("//p[ol | ul]").each do |p|
68
+ list2para_unnest_para(p, p.at("./ol | ./ul"),
69
+ p.at("./*[name() = 'ul' or name() = 'ol'][last()]"))
70
+ end
71
+ docxml.xpath("//ol | //ul").each do |u|
72
+ u.replace(u.children)
73
+ end
74
+ unnest_list_paras(docxml)
75
+ indent_lists(docxml)
76
+ end
77
+
78
+ def unnest_list_paras(docxml)
79
+ docxml.xpath("//p[@class = 'ListContinue1' or @class = 'ListNumber1']"\
80
+ "[.//p]").each do |p|
81
+ p.at("./p") and
82
+ list2para_unnest_para(p, p.at("./p"),
83
+ p.at("./p[last()]"))
84
+ p.xpath(".//p[p]").each do |p1|
85
+ list2para_unnest_para(p1, p1.at("./p"),
86
+ p1.at("./p[last()]"))
87
+ end
88
+ end
89
+ end
90
+
91
+ def indent_lists(docxml)
92
+ docxml.xpath("//div[@class = 'Note' or @class = 'Example' or "\
93
+ "@class = 'Quote']").each do |d|
94
+ d.xpath(".//p").each do |p|
95
+ indent_lists1(p)
96
+ end
97
+ end
98
+ end
99
+
100
+ def indent_lists1(para)
101
+ m = /^(ListContinue|ListNumber|MsoListContinue|MsoListNumber)(\d)$/
102
+ .match(para["class"]) or return
103
+ base = m[1].sub(/^Mso/, "")
104
+ level = m[2].to_i + 1
105
+ level = 5 if level > 5
106
+ para["class"] = "#{base}#{level}-"
107
+ end
108
+
109
+ def list_add(xpath, liststyles, listtype, level)
110
+ xpath.each do |l|
111
+ l["seen"] = true if level == 1
112
+ l["id"] ||= UUIDTools::UUID.random_create
113
+ list_add_number(l, liststyles, listtype, level)
114
+ list_add_tail(l, liststyles, listtype, level)
115
+ end
116
+ end
117
+
118
+ def list_add_number(list, liststyles, listtype, level)
119
+ i = list["start"] ? list["start"].to_i - 1 : 0
120
+ (list.xpath(".//li") - list.xpath(".//ol//li | .//ul//li")).each do |li|
121
+ i = style_list_iso(li, level, listtype, i)
122
+ list_add1(li, liststyles, listtype, level)
123
+ end
124
+ end
125
+
126
+ def list_add_tail(list, liststyles, listtype, level)
127
+ list.xpath(".//ul[not(ancestor::li/ancestor::*/@id = '#{list['id']}')] | "\
128
+ ".//ol[not(ancestor::li/ancestor::*/@id = '#{list['id']}')]")
129
+ .each do |li|
130
+ list_add1(li.parent, liststyles, listtype, level - 1)
131
+ end
132
+ end
133
+
134
+ def style_list_iso(elem, level, listtype, idx)
135
+ return idx if elem.at(".//ol | .//ul") && !elem.at("./p")
136
+
137
+ idx += 1
138
+ ol = elem.xpath("./ancestor::ol")&.last
139
+ label = listlabel(listtype, idx, ol ? ol["type"] : nil)
140
+ elem.children.first.previous =
141
+ "#{label}<span style='mso-tab-count:1'>&#xa0;</span>"
142
+ elem["level"] = level
143
+ idx
144
+ end
145
+
146
+ def listlabel(listtype, idx, level)
147
+ case listtype
148
+ when :ul then "&#x2014;"
149
+ when :ol then "#{listidx(idx, level)})"
150
+ end
151
+ end
152
+
153
+ def listidx(idx, level)
154
+ case level
155
+ when "a" then (96 + idx).chr.to_s
156
+ when "1" then idx.to_s
157
+ when "i" then RomanNumerals.to_roman(idx).downcase
158
+ when "A" then (64 + idx).chr.to_s
159
+ when "I" then RomanNumerals.to_roman(idx).upcase
160
+ end
161
+ end
162
+
163
+ def cleanup(docxml)
164
+ super
165
+ docxml.xpath("//div[@class = 'Quote' or @class = 'Example' or "\
166
+ "@class = 'Note']").each do |d|
167
+ d.delete("class")
168
+ end
169
+ docxml
170
+ end
36
171
  end
37
172
  end
@@ -112,6 +112,12 @@ module IsoDoc
112
112
  end
113
113
  end
114
114
 
115
+ def admonition_class(node)
116
+ if node["type"] == "editorial" then "zzHelp"
117
+ else super
118
+ end
119
+ end
120
+
115
121
  def admonition_parse1(node, div, name)
116
122
  div.p do |p|
117
123
  admonition_name_parse(node, p, name) if name
@@ -177,6 +183,10 @@ module IsoDoc
177
183
  clause_parse(i, out)
178
184
  end
179
185
  end
186
+
187
+ def ol_attrs(node)
188
+ super.merge(start: node["start"]).compact
189
+ end
180
190
  end
181
191
  end
182
192
  end
@@ -21,8 +21,10 @@
21
21
 
22
22
  <p class="coverpage_techcommittee">{{ agency }}/{{ editorialgroup | join: "/" }}</p>
23
23
 
24
+ {% if secretariat %}
24
25
  <p class="coverpage_techcommittee"><a
25
26
  name="CVP_Secretariat_Loca">{{ labels["secretariat"] }}</a>: {{ secretariat }}</p>
27
+ {% endif %}
26
28
 
27
29
  <div class="doctitle-en"><div><span class="title">{{ doctitleintro }}{% if doctitleintro and doctitlemain %} &mdash; {% endif %}</span><span class="subtitle">{{ doctitlemain }}{% if doctitlemain and doctitlepart %} &mdash;{% endif %}</span>
28
30
  {% if doctitlepart %}