metanorma-ogc 1.3.8 → 1.4.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/lib/asciidoctor/ogc/boilerplate.xml +6 -6
  3. data/lib/asciidoctor/ogc/cleanup.rb +173 -0
  4. data/lib/asciidoctor/ogc/converter.rb +62 -64
  5. data/lib/asciidoctor/ogc/front.rb +1 -1
  6. data/lib/asciidoctor/ogc/isodoc.rng +49 -11
  7. data/lib/asciidoctor/ogc/ogc.rng +13 -13
  8. data/lib/asciidoctor/ogc/reqt.rng +15 -4
  9. data/lib/asciidoctor/ogc/validate.rb +35 -20
  10. data/lib/isodoc/ogc/base_convert.rb +47 -10
  11. data/lib/isodoc/ogc/biblio.rb +57 -51
  12. data/lib/isodoc/ogc/html/htmlstyle.css +10 -0
  13. data/lib/isodoc/ogc/html/htmlstyle.scss +12 -0
  14. data/lib/isodoc/ogc/html/ogc.css +4 -0
  15. data/lib/isodoc/ogc/html/ogc.scss +4 -0
  16. data/lib/isodoc/ogc/i18n-en.yaml +24 -8
  17. data/lib/isodoc/ogc/metadata.rb +1 -1
  18. data/lib/isodoc/ogc/ogc.abstract-specification-topic.xsl +541 -155
  19. data/lib/isodoc/ogc/ogc.best-practice.xsl +541 -155
  20. data/lib/isodoc/ogc/ogc.change-request-supporting-document.xsl +541 -155
  21. data/lib/isodoc/ogc/ogc.community-practice.xsl +541 -155
  22. data/lib/isodoc/ogc/ogc.community-standard.xsl +541 -155
  23. data/lib/isodoc/ogc/ogc.discussion-paper.xsl +541 -155
  24. data/lib/isodoc/ogc/ogc.engineering-report.xsl +541 -155
  25. data/lib/isodoc/ogc/ogc.other.xsl +541 -155
  26. data/lib/isodoc/ogc/ogc.policy.xsl +541 -155
  27. data/lib/isodoc/ogc/ogc.reference-model.xsl +541 -155
  28. data/lib/isodoc/ogc/ogc.release-notes.xsl +541 -155
  29. data/lib/isodoc/ogc/ogc.standard.xsl +541 -155
  30. data/lib/isodoc/ogc/ogc.test-suite.xsl +541 -155
  31. data/lib/isodoc/ogc/ogc.user-guide.xsl +541 -155
  32. data/lib/isodoc/ogc/ogc.white-paper.xsl +400 -96
  33. data/lib/isodoc/ogc/presentation_xml_convert.rb +58 -48
  34. data/lib/isodoc/ogc/reqt.rb +90 -36
  35. data/lib/isodoc/ogc/xref.rb +59 -43
  36. data/lib/metanorma/ogc/processor.rb +2 -1
  37. data/lib/metanorma/ogc/version.rb +1 -1
  38. metadata +3 -2
@@ -20,15 +20,15 @@ module IsoDoc
20
20
 
21
21
  def preface_init_insert_pt(docxml)
22
22
  docxml.at(ns("//preface")) ||
23
- docxml.at(ns("//sections")).
24
- add_previous_sibling("<preface> </preface>").first
23
+ docxml.at(ns("//sections"))
24
+ .add_previous_sibling("<preface> </preface>").first
25
25
  end
26
26
 
27
27
  def submit_orgs_append_pt(docxml)
28
28
  docxml.at(ns("//introduction")) ||
29
- docxml.at(ns("//foreword")) ||
30
- docxml.at(ns("//preface/clause[@type = 'keywords']")) ||
31
- docxml.at(ns("//preface/abstract"))
29
+ docxml.at(ns("//foreword")) ||
30
+ docxml.at(ns("//preface/clause[@type = 'keywords']")) ||
31
+ docxml.at(ns("//preface/abstract"))
32
32
  end
33
33
 
34
34
  def insert_security(docxml)
@@ -37,42 +37,45 @@ module IsoDoc
37
37
  if a = submit_orgs_append_pt(docxml)
38
38
  a.next = s
39
39
  else
40
- preface_init_insert_pt(docxml)&.children&.first&.
41
- add_previous_sibling(s)
40
+ preface_init_insert_pt(docxml)&.children&.first
41
+ &.add_previous_sibling(s)
42
42
  end
43
43
  end
44
44
 
45
45
  def insert_submitting_orgs(docxml)
46
- orgs = []
47
- docxml.xpath(ns(submittingorgs_path)).each { |org| orgs << org.text }
46
+ orgs = docxml.xpath(ns(submittingorgs_path))
47
+ .each_with_object([]) do |org, m|
48
+ m << org.text
49
+ end
48
50
  return if orgs.empty?
51
+
49
52
  if a = submit_orgs_append_pt(docxml)
50
53
  a.next = submitting_orgs_clause(orgs)
51
54
  else
52
- preface_init_insert_pt(docxml)&.children&.first&.
53
- add_previous_sibling(submitting_orgs_clause(orgs))
55
+ preface_init_insert_pt(docxml)&.children&.first
56
+ &.add_previous_sibling(submitting_orgs_clause(orgs))
54
57
  end
55
58
  end
56
59
 
57
60
  def submitting_orgs_clause(orgs)
58
- <<~END
59
- <clause id="_#{UUIDTools::UUID.random_create}" type="submitting_orgs">
60
- <title>Submitting Organizations</title>
61
- <p>The following organizations submitted this Document to the
62
- Open Geospatial Consortium (OGC):</p>
63
- <ul>#{orgs.map { |m| "<li>#{m}</li>" }.join("\n")}</ul>
64
- </clause>
65
- END
66
- end
67
-
68
- def keyword_clause(kw)
69
- <<~END
70
- <clause id="_#{UUIDTools::UUID.random_create}" type="keywords">
71
- <title>Keywords</title>
72
- <p>The following are keywords to be used by search engines and
73
- document catalogues.</p>
74
- <p>#{kw.join(", ")}</p></clause>
75
- END
61
+ <<~SUBMITTING
62
+ <clause id="_#{UUIDTools::UUID.random_create}" type="submitting_orgs">
63
+ <title>Submitting Organizations</title>
64
+ <p>The following organizations submitted this Document to the
65
+ Open Geospatial Consortium (OGC):</p>
66
+ <ul>#{orgs.map { |m| "<li>#{m}</li>" }.join("\n")}</ul>
67
+ </clause>
68
+ SUBMITTING
69
+ end
70
+
71
+ def keyword_clause(kwords)
72
+ <<~KEYWORDS
73
+ <clause id="_#{UUIDTools::UUID.random_create}" type="keywords">
74
+ <title>Keywords</title>
75
+ <p>The following are keywords to be used by search engines and
76
+ document catalogues.</p>
77
+ <p>#{kwords.join(', ')}</p></clause>
78
+ KEYWORDS
76
79
  end
77
80
 
78
81
  def insert_keywords(docxml)
@@ -81,28 +84,29 @@ module IsoDoc
81
84
  if abstract = docxml.at(ns("//preface/abstract"))
82
85
  abstract.next = keyword_clause(kw)
83
86
  else
84
- preface_init_insert_pt(docxml)&.children&.first&.
85
- add_previous_sibling(keyword_clause(kw))
87
+ preface_init_insert_pt(docxml)&.children&.first
88
+ &.add_previous_sibling(keyword_clause(kw))
86
89
  end
87
90
  end
88
91
 
89
- def example1(f)
90
- lbl = @xrefs.anchor(f['id'], :label, false) or return
91
- prefix_name(f, "&nbsp;&mdash; ", l10n("#{@i18n.example} #{lbl}"), "name")
92
+ def example1(elem)
93
+ lbl = @xrefs.anchor(elem["id"], :label, false) or return
94
+ prefix_name(elem, "&nbsp;&mdash; ", l10n("#{@i18n.example} #{lbl}"),
95
+ "name")
92
96
  end
93
97
 
94
- def recommendation1(f, type)
95
- type = recommendation_class_label(f)
96
- label = f&.at(ns("./label"))&.text
97
- if inject_crossreference_reqt?(f, label)
98
+ def recommendation1(elem, _type)
99
+ type = recommendation_class_label(elem)
100
+ label = elem&.at(ns("./label"))&.text
101
+ if inject_crossreference_reqt?(elem, label)
98
102
  n = @xrefs.anchor(@xrefs.reqtlabels[label], :xref, false)
99
103
  lbl = (n.nil? ? type : n)
100
- f&.at(ns("./title"))&.remove # suppress from display if embedded
104
+ elem&.at(ns("./title"))&.remove # suppress from display if embedded
101
105
  else
102
- n = @xrefs.anchor(f['id'], :label, false)
106
+ n = @xrefs.anchor(elem["id"], :label, false)
103
107
  lbl = (n.nil? ? type : l10n("#{type} #{n}"))
104
108
  end
105
- prefix_name(f, "", lbl, "name")
109
+ prefix_name(elem, "", lbl, "name")
106
110
  end
107
111
 
108
112
  # embedded reqts xref to top level reqts via label lookup
@@ -126,23 +130,30 @@ module IsoDoc
126
130
  end
127
131
  end
128
132
 
129
- def annex1(f)
130
- lbl = @xrefs.anchor(f['id'], :label)
131
- if t = f.at(ns("./title"))
133
+ def annex1(elem)
134
+ lbl = @xrefs.anchor(elem["id"], :label)
135
+ if t = elem.at(ns("./title"))
132
136
  t.children = "<strong>#{t.children.to_xml}</strong>"
133
137
  end
134
- prefix_name(f, "<br/>", lbl, "title")
138
+ prefix_name(elem, "<br/>", lbl, "title")
135
139
  end
136
140
 
137
141
  def clause(docxml)
138
142
  super
139
143
  docxml.xpath(ns("//foreword | //preface/abstract | "\
140
- "//submitters | //introduction | //acknowledgements")).
141
- each do |f|
144
+ "//submitters | //introduction | //acknowledgements"))
145
+ .each do |f|
142
146
  clause1(f)
143
147
  end
144
148
  end
145
149
 
150
+ def clause1(elem)
151
+ return if elem.name == "terms" && elem.parent.name == "annex" &&
152
+ elem.parent.xpath(ns("./terms")).size == 1
153
+
154
+ super
155
+ end
156
+
146
157
  def block(docxml)
147
158
  super
148
159
  recommendation_to_table(docxml)
@@ -166,4 +177,3 @@ module IsoDoc
166
177
  end
167
178
  end
168
179
  end
169
-
@@ -1,4 +1,5 @@
1
1
  require "isodoc"
2
+ require "metanorma-utils"
2
3
 
3
4
  module IsoDoc
4
5
  module Ogc
@@ -12,6 +13,10 @@ module IsoDoc
12
13
  "recommend"
13
14
  end
14
15
 
16
+ def recommend_class?(node)
17
+ %w(recommendtest recommendclass recommend).include? node["type"]
18
+ end
19
+
15
20
  def recommendation_class(node)
16
21
  if node["type"] == "recommendtest"
17
22
  "RecommendationTestTitle"
@@ -20,45 +25,75 @@ module IsoDoc
20
25
  end
21
26
  end
22
27
 
23
- def recommendation_header(r)
24
- h = r.add_child("<thead><tr><th scope='colgroup' colspan='2'></th></tr></thead>")
25
- recommendation_name(r, h.at(ns(".//th")))
28
+ def recommendation_header(recommend)
29
+ h = recommend.add_child("<thead><tr><th scope='colgroup' colspan='2'>"\
30
+ "</th></tr></thead>")
31
+ recommendation_name(recommend, h.at(ns(".//th")))
26
32
  end
27
33
 
28
34
  def recommendation_name(node, out)
29
35
  b = out.add_child("<p class='#{recommendation_class(node)}'></p>").first
30
36
  if name = node&.at(ns("./name"))&.remove
31
37
  name.children.each { |n| b << n }
32
- b << l10n(":")
33
38
  end
34
39
  if title = node&.at(ns("./title"))&.remove
35
- b << l10n(" ") if name
40
+ b << l10n(": ") if name
36
41
  title.children.each { |n| b << n }
37
42
  end
38
43
  end
39
44
 
40
45
  def recommend_title(node, out)
41
46
  label = node&.at(ns("./label"))&.remove or return
47
+ label.xpath(ns(".//xref | .//eref | .//quote/source"))
48
+ .each { |f| xref1(f) }
49
+ label.xpath(ns(".//concept")).each { |f| concept1(f) }
42
50
  b = out.add_child("<tr><td colspan='2'><p></p></td></tr>")
43
51
  p = b.at(ns(".//p"))
44
- p << label.children
52
+ p << label.text
45
53
  end
46
54
 
47
55
  def recommendation_attributes1(node)
48
- out = []
56
+ out = recommendation_attributes1_head(node, [])
57
+ node.xpath(ns("./classification")).each do |c|
58
+ line = recommendation_attr_keyvalue(c, "tag", "value") and out << line
59
+ end
60
+ out
61
+ end
62
+
63
+ def recommendation_attributes1_head(node, out)
49
64
  oblig = node["obligation"] and out << ["Obligation", oblig]
50
- subj = node&.at(ns("./subject"))&.remove&.children and out << [rec_subj(node), subj]
65
+ subj = node&.at(ns("./subject"))&.remove&.children and
66
+ out << [rec_subj(node), subj]
51
67
  node.xpath(ns("./inherit")).each do |i|
52
68
  out << ["Dependency", i.remove.children]
53
69
  end
54
- node.xpath(ns("./classification")).each do |c|
55
- line = recommendation_attr_keyvalue(c, "tag", "value") and out << line
56
- end
57
70
  out
58
71
  end
59
72
 
73
+ def recommendation_steps(node)
74
+ node.elements.each { |e| recommendation_steps(e) }
75
+ return node unless node.at(ns("./component[@class = 'step']"))
76
+
77
+ d = node.at(ns("./component[@class = 'step']"))
78
+ d = d.replace("<ol><li>#{d.children.to_xml}</li></ol>").first
79
+ node.xpath(ns("./component[@class = 'step']")).each do |f|
80
+ f = f.replace("<li>#{f.children.to_xml}</li>").first
81
+ d << f
82
+ end
83
+ end
84
+
85
+ def recommendation_attributes1_component(node, out)
86
+ node = recommendation_steps(node)
87
+ out << "<tr><td>#{node['label']}</td><td>#{node.children}</td></tr>"
88
+ end
89
+
60
90
  def rec_subj(node)
61
- node["type"] == "recommendclass" ? "Target Type" : "Subject"
91
+ case node["type_original"]
92
+ when "class" then "Target type"
93
+ when "conformanceclass" then "Requirements class"
94
+ when "verification", "abstracttest" then "Requirement"
95
+ else "Subject"
96
+ end
62
97
  end
63
98
 
64
99
  def recommendation_attr_keyvalue(node, key, value)
@@ -70,13 +105,15 @@ module IsoDoc
70
105
  end
71
106
 
72
107
  def recommendation_attributes(node, out)
108
+ recommend_title(node, out)
73
109
  recommendation_attributes1(node).each do |i|
74
110
  out.add_child("<tr><td>#{i[0]}</td><td>#{i[1]}</td></tr>")
75
111
  end
76
112
  end
77
113
 
78
114
  def preserve_in_nested_table?(node)
79
- return true if %w(recommendation requirement permission table).include?(node.name)
115
+ return true if %w(recommendation requirement permission
116
+ table).include?(node.name)
80
117
 
81
118
  false
82
119
  end
@@ -87,8 +124,11 @@ module IsoDoc
87
124
 
88
125
  node.elements.size == 1 && node.first_element_child.name == "dl" and
89
126
  return reqt_dl(node.first_element_child, out)
127
+ node.name == "component" and
128
+ return recommendation_attributes1_component(node, out)
90
129
  b = out.add_child("<tr><td colspan='2'></td></tr>").first
91
- b.at(ns(".//td")) << (preserve_in_nested_table?(node) ? node : node.children)
130
+ b.at(ns(".//td")) <<
131
+ (preserve_in_nested_table?(node) ? node : node.children)
92
132
  end
93
133
 
94
134
  def reqt_dl(node, out)
@@ -105,20 +145,34 @@ module IsoDoc
105
145
  def recommendation_base(node, klass)
106
146
  node.name = "table"
107
147
  node["class"] = klass
148
+ node["type_original"] = node["type"]
108
149
  node["type"] = recommend_class(node)
150
+ recommendation_component_labels(node)
151
+ end
152
+
153
+ def recommendation_component_labels(node)
154
+ node.xpath(ns("./component[@class = 'part']")).each_with_index do |c, i|
155
+ c["label"] = (i + "A".ord).chr.to_s
156
+ end
157
+ node.xpath(ns("./component[not(@class = 'part')]")).each do |c|
158
+ c["label"] = case c["class"]
159
+ when "test-purpose" then "Test purpose"
160
+ when "test-method" then "Test method"
161
+ else Metanorma::Utils.strict_capitalize_first(c["class"])
162
+ end
163
+ end
109
164
  end
110
165
 
111
166
  def recommendation_parse1(node, klass)
112
167
  recommendation_base(node, klass)
113
168
  recommendation_header(node)
114
169
  b = node.add_child("<tbody></tbody>").first
115
- recommend_title(node, b)
116
170
  recommendation_attributes(node, b)
117
- node.elements.each do |n|
118
- next if %w(thead tbody).include?(n.name)
119
-
120
- requirement_component_parse(n, b)
121
- end
171
+ node.elements.reject do |n|
172
+ %w(thead tbody classification subject
173
+ inherit).include?(n.name)
174
+ end.each { |n| requirement_component_parse(n, b) }
175
+ node.delete("type_original")
122
176
  end
123
177
 
124
178
  def recommendation_to_table(docxml)
@@ -135,27 +189,27 @@ module IsoDoc
135
189
  end
136
190
 
137
191
  # table nested in table: merge label and caption into a single row
138
- def requirement_table_cleanup1(x, y)
139
- x.delete("colspan")
140
- x.delete("scope")
141
- y.delete("colspan")
142
- y.delete("scope")
143
- x.name = "td"
144
- p = x.at(ns("./p[@class = 'RecommendationTitle']")) and
192
+ def requirement_table_cleanup1(outer, inner)
193
+ outer.delete("colspan")
194
+ outer.delete("scope")
195
+ inner.delete("colspan")
196
+ inner.delete("scope")
197
+ outer.name = "td"
198
+ p = outer.at(ns("./p[@class = 'RecommendationTitle']")) and
145
199
  p.delete("class")
146
- x.parent << y.dup
147
- y.parent.remove
200
+ outer.parent << inner.dup
201
+ inner.parent.remove
148
202
  end
149
203
 
150
204
  def requirement_table_cleanup(docxml)
151
- docxml.xpath(ns("//table[@type = 'recommendclass']/tbody/tr/td/table")).each do |t|
152
- x = t.at(ns("./thead")) and x.replace(x.children)
153
- x = t.at(ns("./tbody")) and x.replace(x.children)
154
- x = t.at(ns("./tfoot")) and x.replace(x.children)
155
- if (x = t.at(ns("./tr/th[@colspan = '2']"))) &&
156
- (y = t.at(ns("./tr/td[@colspan = '2']")))
157
- requirement_table_cleanup1(x, y)
205
+ docxml.xpath(ns("//table[@type = 'recommendclass']/tbody/tr/td/table"))
206
+ .each do |t|
207
+ t.xpath(ns("./thead | ./tbody |./tfoot")).each do |x|
208
+ x.replace(x.children)
158
209
  end
210
+ (x = t.at(ns("./tr/th[@colspan = '2']"))) &&
211
+ (y = t.at(ns("./tr/td[@colspan = '2']"))) and
212
+ requirement_table_cleanup1(x, y)
159
213
  t.parent.parent.replace(t.children)
160
214
  end
161
215
  end
@@ -24,6 +24,7 @@ module IsoDoc
24
24
  @anchors[t["id"]] = anchor_struct(id, t, label, klass,
25
25
  t["unnumbered"])
26
26
  l = t.at(ns("./label"))&.text and @reqtlabels[l] = t["id"]
27
+ permission_parts(t, label, klass)
27
28
  sequential_permission_children(t, id)
28
29
  end
29
30
  end
@@ -32,7 +33,7 @@ module IsoDoc
32
33
  { "class" => "@type = 'class'",
33
34
  "test" => "@type = 'verification'",
34
35
  "" => "not(@type = 'verification' or @type = 'class' or "\
35
- "@type = 'abstracttest' or @type = 'conformanceclass')" }
36
+ "@type = 'abstracttest' or @type = 'conformanceclass')" }
36
37
  end
37
38
 
38
39
  def req_class_paths2
@@ -40,15 +41,27 @@ module IsoDoc
40
41
  "conformanceclass" => "@type = 'conformanceclass'" }
41
42
  end
42
43
 
43
- def sequential_permission_children(t, id)
44
+ def permission_parts(block, label, klass)
45
+ block.xpath(ns("./component[@class = 'part']"))
46
+ .each_with_index do |c, i|
47
+ next if c["id"].nil? || c["id"].empty?
48
+
49
+ @anchors[c["id"]] = anchor_struct((i + "A".ord).chr.to_s, c, label,
50
+ klass, c["unnumbered"])
51
+ end
52
+ end
53
+
54
+ REQS = %w(permission requirement recommendation).freeze
55
+
56
+ def sequential_permission_children(block, idx)
44
57
  req_class_paths.each do |k, v|
45
- %w(permission requirement recommendation).each do |r|
46
- sequential_permission_names1(t, id, "#{r}[#{v}]",
58
+ REQS.each do |r|
59
+ sequential_permission_names1(block, idx, "#{r}[#{v}]",
47
60
  @labels["#{r}#{k}"])
48
61
  end
49
62
  end
50
63
  req_class_paths2.each do |k, v|
51
- sequential_permission_names1(t, id, "*[#{v}]", @labels[k])
64
+ sequential_permission_names1(block, idx, "*[#{v}]", @labels[k])
52
65
  end
53
66
  end
54
67
 
@@ -60,6 +73,7 @@ module IsoDoc
60
73
  id = "#{lbl}#{hierfigsep}#{c.increment(t).print}"
61
74
  @anchors[t["id"]] = anchor_struct(id, t, label, klass,
62
75
  t["unnumbered"])
76
+ permission_parts(t, label, klass)
63
77
  sequential_permission_children(t, id)
64
78
  end
65
79
  end
@@ -69,7 +83,7 @@ module IsoDoc
69
83
  sequential_figure_names(clause)
70
84
  sequential_formula_names(clause)
71
85
  req_class_paths.each do |k, v|
72
- %w(permission requirement recommendation).each do |r|
86
+ REQS.each do |r|
73
87
  sequential_permission_names(clause, "#{r}[#{v}]",
74
88
  @labels["#{r}#{k}"])
75
89
  end
@@ -84,7 +98,7 @@ module IsoDoc
84
98
  hierarchical_figure_names(clause, num)
85
99
  hierarchical_formula_names(clause, num)
86
100
  req_class_paths.each do |k, v|
87
- %w(permission requirement recommendation).each do |r|
101
+ REQS.each do |r|
88
102
  hierarchical_permission_names(clause, num, "#{r}[#{v}]",
89
103
  @labels["#{r}#{k}"])
90
104
  end
@@ -103,51 +117,54 @@ module IsoDoc
103
117
  @anchors[t["id"]] = anchor_struct(lbl, t, label, klass,
104
118
  t["unnumbered"])
105
119
  l = t.at(ns("./label"))&.text and @reqtlabels[l] = t["id"]
120
+ permission_parts(t, label, klass)
106
121
  sequential_permission_children(t, lbl)
107
122
  end
108
123
  end
109
124
 
110
- def initial_anchor_names(d)
111
- @prefacenum = 0
112
- preface_names_numbered(d.at(ns("//preface/abstract")))
113
- preface_names_numbered(d.at(ns("//preface/clause[@type = 'keywords']")))
114
- preface_names_numbered(d.at(ns("//foreword")))
115
- preface_names_numbered(d.at(ns("//introduction")))
116
- preface_names_numbered(d.at(ns("//preface/clause[@type = 'security']")))
117
- preface_names_numbered(d.at(ns("//preface/clause"\
118
- "[@type = 'submitting_orgs']")))
119
- preface_names_numbered(d.at(ns("//submitters")))
120
- d.xpath(ns("//preface/clause[not(@type = 'keywords' or "\
121
- "@type = 'submitting_orgs' or @type = 'security')]")).each do |c|
122
- preface_names_numbered(c)
123
- end
124
- preface_names_numbered(d.at(ns("//acknowledgements")))
125
- sequential_asset_names(d.xpath(ns(
126
- "//preface/abstract | //foreword | //introduction | "\
127
- "//submitters | //acknowledgements | //preface/clause",
128
- )))
125
+ def initial_anchor_names(doc)
126
+ preface_anchor_names(doc)
129
127
  n = Counter.new
130
- n = section_names(d.at(ns("//clause[@type = 'scope']")), n, 1)
131
- n = section_names(d.at(ns("//clause[@type = 'conformance']")), n, 1)
132
- n = section_names(d.at(ns(@klass.norm_ref_xpath)), n, 1)
128
+ n = section_names(doc.at(ns("//clause[@type = 'scope']")), n, 1)
129
+ n = section_names(doc.at(ns("//clause[@type = 'conformance']")), n, 1)
130
+ n = section_names(doc.at(ns(@klass.norm_ref_xpath)), n, 1)
133
131
  n = section_names(
134
- d.at(ns("//sections/terms | //sections/clause[descendant::terms]")),
132
+ doc.at(ns("//sections/terms | //sections/clause[descendant::terms]")),
135
133
  n, 1
136
134
  )
137
- n = section_names(d.at(ns("//sections/definitions")), n, 1)
138
- middle_section_asset_names(d)
139
- clause_names(d, n)
140
- termnote_anchor_names(d)
141
- termexample_anchor_names(d)
135
+ n = section_names(doc.at(ns("//sections/definitions")), n, 1)
136
+ middle_section_asset_names(doc)
137
+ clause_names(doc, n)
138
+ termnote_anchor_names(doc)
139
+ termexample_anchor_names(doc)
140
+ end
141
+
142
+ def preface_anchor_names(doc)
143
+ @prefacenum = 0
144
+ ["//preface/abstract", "//preface/clause[@type = 'keywords']",
145
+ "//foreword", "//introduction", "//preface/clause[@type = 'security']",
146
+ "//preface/clause[@type = 'submitting_orgs']",
147
+ "//submitters"].each do |path|
148
+ preface_names_numbered(doc.at(ns(path)))
149
+ end
150
+ doc.xpath(ns("//preface/clause[not(@type = 'keywords' or "\
151
+ "@type = 'submitting_orgs' or @type = 'security')]"))
152
+ .each { |c| preface_names_numbered(c) }
153
+ preface_names_numbered(doc.at(ns("//acknowledgements")))
154
+ sequential_asset_names(
155
+ doc.xpath(ns("//preface/abstract | //foreword | //introduction | "\
156
+ "//submitters | //acknowledgements | //preface/clause")),
157
+ )
142
158
  end
143
159
 
144
- def middle_section_asset_names(d)
145
- middle_sections = "//clause[@type = 'scope' or @type = 'conformance'] "\
146
- "| //foreword | //introduction | //preface/abstract | "\
147
- "//submitters | //acknowledgements | //preface/clause | "\
160
+ def middle_section_asset_names(doc)
161
+ middle_sections =
162
+ "//clause[@type = 'scope' or @type = 'conformance'] | //foreword | "\
163
+ "//introduction | //preface/abstract | //submitters | "\
164
+ "//acknowledgements | //preface/clause | "\
148
165
  " #{@klass.norm_ref_xpath} | //sections/terms | "\
149
166
  "//sections/definitions | //clause[parent::sections]"
150
- sequential_asset_names(d.xpath(ns(middle_sections)))
167
+ sequential_asset_names(doc.xpath(ns(middle_sections)))
151
168
  end
152
169
 
153
170
  def preface_names_numbered(clause)
@@ -183,8 +200,7 @@ module IsoDoc
183
200
  when 6 then "(#{num})"
184
201
  when 7 then "(#{(96 + num).chr})"
185
202
  when 8 then "(#{RomanNumerals.to_roman(num).downcase})"
186
- else
187
- num.to_s
203
+ else num.to_s
188
204
  end
189
205
  end
190
206
 
@@ -192,7 +208,7 @@ module IsoDoc
192
208
  super
193
209
  return unless @klass.ogc_draft_ref?(ref)
194
210
 
195
- @anchors[ref["id"]] = { xref: @anchors[ref["id"]][:xref] + " (draft)" }
211
+ @anchors[ref["id"]] = { xref: "#{@anchors[ref['id']][:xref]} (draft)" }
196
212
  end
197
213
  end
198
214
  end
@@ -22,11 +22,12 @@ module Metanorma
22
22
  def fonts_manifest
23
23
  {
24
24
  "Lato" => nil,
25
+ "Lato Light" => nil,
25
26
  "Arial" => nil,
26
27
  "STIX Two Math" => nil,
27
28
  "Source Han Sans" => nil,
29
+ "Source Han Sans Normal" => nil,
28
30
  "Fira Code" => nil,
29
- "Courier" => nil,
30
31
  "Courier New" => nil,
31
32
  "Times New Roman" => nil,
32
33
  "Overpass" => nil,
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Ogc
3
- VERSION = "1.3.8".freeze
3
+ VERSION = "1.4.3".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-ogc
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.8
4
+ version: 1.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-08-02 00:00:00.000000000 Z
11
+ date: 2021-09-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: iso-639
@@ -218,6 +218,7 @@ files:
218
218
  - lib/asciidoctor/ogc/basicdoc.rng
219
219
  - lib/asciidoctor/ogc/biblio.rng
220
220
  - lib/asciidoctor/ogc/boilerplate.xml
221
+ - lib/asciidoctor/ogc/cleanup.rb
221
222
  - lib/asciidoctor/ogc/converter.rb
222
223
  - lib/asciidoctor/ogc/front.rb
223
224
  - lib/asciidoctor/ogc/isodoc.rng