metanorma-ogc 2.4.2 → 2.4.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -86,25 +86,26 @@ module Metanorma
86
86
  end
87
87
 
88
88
  def section_names_terms_cleanup(xml)
89
- replace_title(xml, "//definitions[@type = 'symbols']", @i18n&.symbols)
89
+ @i18n or return
90
+ replace_title(xml, "//definitions[@type = 'symbols']", @i18n.symbols)
90
91
  replace_title(xml, "//definitions[@type = 'abbreviated_terms']",
91
- @i18n&.abbrev)
92
- replace_title(xml, "//definitions[not(@type)]", @i18n&.symbolsabbrev)
92
+ @i18n.abbrev)
93
+ replace_title(xml, "//definitions[not(@type)]", @i18n.symbolsabbrev)
93
94
  replace_title(xml, "//sections//terms#{SYMnoABBR} | " \
94
95
  "//sections//clause[.//terms]#{SYMnoABBR}",
95
- @i18n&.termsdefsymbols, true)
96
+ @i18n.termsdefsymbols, true)
96
97
  replace_title(xml, "//sections//terms#{ABBRnoSYM} | " \
97
98
  "//sections//clause[.//terms]#{ABBRnoSYM}",
98
- @i18n&.termsdefabbrev, true)
99
+ @i18n.termsdefabbrev, true)
99
100
  replace_title(xml, "//sections//terms#{SYMABBR} | " \
100
101
  "//sections//clause[.//terms]#{SYMABBR}",
101
- @i18n&.termsdefsymbolsabbrev, true)
102
+ @i18n.termsdefsymbolsabbrev, true)
102
103
  replace_title(xml, "//sections//terms#{NO_SYMABBR} | " \
103
104
  "//sections//clause[.//terms]#{NO_SYMABBR}",
104
- @i18n&.termsdefsymbolsabbrev, true)
105
+ @i18n.termsdefsymbolsabbrev, true)
105
106
  replace_title(xml, "//sections//terms[not(.//definitions)] | " \
106
107
  "//sections//clause[.//terms][not(.//definitions)]",
107
- @i18n&.termsdef, true)
108
+ @i18n.termsdef, true)
108
109
  end
109
110
 
110
111
  def termdef_cleanup(xmldoc)
@@ -115,8 +116,7 @@ module Metanorma
115
116
  # skip annex/terms/terms, which is empty node
116
117
  def termdef_subclause_cleanup(xmldoc)
117
118
  xmldoc.xpath("//annex//clause[terms]").each do |t|
118
- next unless t.xpath("./clause | ./terms | ./definitions").size == 1
119
-
119
+ t.xpath("./clause | ./terms | ./definitions").size == 1 or next
120
120
  t.children.each { |n| n.parent = t.parent }
121
121
  t.remove
122
122
  end
@@ -224,6 +224,26 @@ module Metanorma
224
224
  partid: partid&.to_i || 0,
225
225
  type: id ? id["type"] : nil }
226
226
  end
227
+
228
+ # Numbers sort *before* letters; we leave out using thorn to force that sort order.
229
+ # case insensitive
230
+ def symbol_key(sym)
231
+ @c.decode(asciimath_key(sym).text)
232
+ .gsub(/[\[\]{}<>()]/, "").gsub(/\s/m, "")
233
+ .gsub(/[[:punct:]]|[_^]/, ":\\0").gsub("`", "")
234
+ end
235
+
236
+ def symbols_cleanup(docxml)
237
+ docxml.xpath("//definitions/dl").each do |dl|
238
+ dl_out = extract_symbols_list(dl)
239
+ dl_out.sort! do |a, b|
240
+ a[:key].downcase <=> b[:key].downcase || a[:key] <=> b[:key] ||
241
+ a[:dt] <=> b[:dt]
242
+ end
243
+ dl.children = dl_out.map { |d| d[:dt].to_s + d[:dd].to_s }.join("\n")
244
+ end
245
+ docxml
246
+ end
227
247
  end
228
248
  end
229
249
  end
@@ -154,7 +154,9 @@ module Metanorma
154
154
  end
155
155
 
156
156
  def presentation_xml_converter(node)
157
- IsoDoc::Ogc::PresentationXMLConvert.new(html_extract_attributes(node))
157
+ IsoDoc::Ogc::PresentationXMLConvert
158
+ .new(html_extract_attributes(node)
159
+ .merge(output_formats: ::Metanorma::Ogc::Processor.new.output_formats))
158
160
  end
159
161
 
160
162
  def html_converter(node)
@@ -170,6 +172,17 @@ module Metanorma
170
172
  def doc_converter(node)
171
173
  IsoDoc::Ogc::WordConvert.new(doc_extract_attributes(node))
172
174
  end
175
+
176
+ # preempt subdoctype warning
177
+ def adoc2xml(text, flavour)
178
+ Nokogiri::XML(text).root and return text
179
+ c = Asciidoctor
180
+ .convert("= X\nA\n:semantic-metadata-headless: true\n" \
181
+ ":novalid:\n:docsubtype: implementation\n" \
182
+ ":doctype: standard\n\n#{text}\n",
183
+ backend: flavour, header_footer: true)
184
+ Nokogiri::XML(c).at("//xmlns:sections")
185
+ end
173
186
  end
174
187
  end
175
188
  end
@@ -11,8 +11,7 @@ module Metanorma
11
11
  end
12
12
 
13
13
  def corporate_author(node, xml)
14
- return unless node.attr("submitting-organizations")
15
-
14
+ node.attr("submitting-organizations") or return
16
15
  csv_split(HTMLEntities.new
17
16
  .decode(node.attr("submitting-organizations")), ";")&.each do |org|
18
17
  xml.contributor do |c|
@@ -49,8 +48,7 @@ module Metanorma
49
48
  end
50
49
 
51
50
  def ogc_editor(node, xml)
52
- return unless node.attr("editor")
53
-
51
+ node.attr("editor") or return
54
52
  xml.contributor do |c|
55
53
  c.role type: "editor"
56
54
  c.person do |p|
@@ -78,12 +76,15 @@ module Metanorma
78
76
  end
79
77
 
80
78
  def default_publisher
81
- "Open Geospatial Consortium"
79
+ "OGC"
82
80
  end
83
81
 
84
- def metadata_committee(node, xml)
85
- return unless node.attr("committee")
82
+ def org_abbrev
83
+ { "Open Geospatial Consortium" => "OGC" }
84
+ end
86
85
 
86
+ def metadata_committee(node, xml)
87
+ node.attr("committee") or return
87
88
  xml.editorialgroup do |a|
88
89
  metadata_committee1(node, a)
89
90
  end
@@ -102,12 +103,10 @@ module Metanorma
102
103
  end
103
104
 
104
105
  def externalid(node)
105
- return node.attr("external-id") if node.attr("external-id")
106
-
106
+ i = node.attr("external-id") and return i
107
107
  d = doctype(node)
108
108
  a = node.attr("abbrev")
109
- return unless d && a
110
-
109
+ d && a or return
111
110
  url = "http://www.opengis.net/doc/#{IsoDoc::Ogc::DOCTYPE_ABBR[d]}/#{a}"
112
111
  v = (node.attr("edition") || node.attr("version")) and url += "/#{v}"
113
112
  url
@@ -181,12 +180,12 @@ module Metanorma
181
180
  unless %w{general encoding extension profile
182
181
  profile-with-extension}.include? s
183
182
  @log.add("Document Attributes", nil,
184
- "'#{s}' is not a permitted subtype of Standard: " \
185
- "reverting to 'implementation'")
183
+ "'#{s}' is not a permitted subtype of best-practice: " \
184
+ "reverting to 'general'")
186
185
  s = "general"
187
186
  end
188
187
  end
189
- s and xml.subdoctype s
188
+ s && !s.empty? and xml.subdoctype s
190
189
  end
191
190
 
192
191
  def title(node, xml)
@@ -17,7 +17,7 @@
17
17
  these elements; we just want one namespace for any child grammars
18
18
  of this.
19
19
  -->
20
- <!-- VERSION v1.2.4 -->
20
+ <!-- VERSION v1.2.8 -->
21
21
  <grammar xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
22
22
  <include href="reqt.rng"/>
23
23
  <include href="basicdoc.rng">
@@ -485,6 +485,8 @@
485
485
  <choice>
486
486
  <text/>
487
487
  <ref name="callout"/>
488
+ <ref name="xref"/>
489
+ <ref name="eref"/>
488
490
  </choice>
489
491
  </oneOrMore>
490
492
  <zeroOrMore>
@@ -865,6 +867,7 @@
865
867
  <ref name="PureTextElement"/>
866
868
  <ref name="stem"/>
867
869
  <ref name="index"/>
870
+ <ref name="index-xref"/>
868
871
  <ref name="eref"/>
869
872
  <ref name="erefstack"/>
870
873
  <ref name="xref"/>
@@ -880,6 +883,7 @@
880
883
  <ref name="PureTextElement"/>
881
884
  <ref name="stem"/>
882
885
  <ref name="index"/>
886
+ <ref name="index-xref"/>
883
887
  <ref name="eref"/>
884
888
  <ref name="erefstack"/>
885
889
  <ref name="xref"/>
@@ -894,6 +898,7 @@
894
898
  <choice>
895
899
  <ref name="PureTextElement"/>
896
900
  <ref name="index"/>
901
+ <ref name="index-xref"/>
897
902
  <ref name="eref"/>
898
903
  <ref name="erefstack"/>
899
904
  <ref name="xref"/>
@@ -908,6 +913,7 @@
908
913
  <choice>
909
914
  <ref name="PureTextElement"/>
910
915
  <ref name="index"/>
916
+ <ref name="index-xref"/>
911
917
  </choice>
912
918
  </zeroOrMore>
913
919
  </element>
@@ -918,6 +924,7 @@
918
924
  <choice>
919
925
  <ref name="PureTextElement"/>
920
926
  <ref name="index"/>
927
+ <ref name="index-xref"/>
921
928
  </choice>
922
929
  </zeroOrMore>
923
930
  </element>
@@ -928,6 +935,7 @@
928
935
  <choice>
929
936
  <ref name="PureTextElement"/>
930
937
  <ref name="index"/>
938
+ <ref name="index-xref"/>
931
939
  </choice>
932
940
  </zeroOrMore>
933
941
  </element>
@@ -938,6 +946,7 @@
938
946
  <choice>
939
947
  <ref name="PureTextElement"/>
940
948
  <ref name="index"/>
949
+ <ref name="index-xref"/>
941
950
  </choice>
942
951
  </zeroOrMore>
943
952
  </element>
@@ -1004,6 +1013,14 @@
1004
1013
  </oneOrMore>
1005
1014
  </element>
1006
1015
  </define>
1016
+ <define name="BasicBlock" combine="choice">
1017
+ <ref name="columnbreak"/>
1018
+ </define>
1019
+ <define name="columnbreak">
1020
+ <element name="columnbreak">
1021
+ <empty/>
1022
+ </element>
1023
+ </define>
1007
1024
  <define name="MultilingualRenderingType">
1008
1025
  <choice>
1009
1026
  <value>common</value>
@@ -1037,6 +1054,17 @@
1037
1054
  <ref name="date_inline"/>
1038
1055
  </choice>
1039
1056
  </define>
1057
+ <define name="PureTextElement" combine="choice">
1058
+ <ref name="passthrough_inline"/>
1059
+ </define>
1060
+ <define name="passthrough_inline">
1061
+ <element name="passthrough">
1062
+ <optional>
1063
+ <attribute name="formats"/>
1064
+ </optional>
1065
+ <text/>
1066
+ </element>
1067
+ </define>
1040
1068
  <define name="add">
1041
1069
  <element name="add">
1042
1070
  <choice>
@@ -1047,6 +1075,8 @@
1047
1075
  <ref name="keyword"/>
1048
1076
  <ref name="xref"/>
1049
1077
  <ref name="hyperlink"/>
1078
+ <ref name="index"/>
1079
+ <ref name="index-xref"/>
1050
1080
  </choice>
1051
1081
  </element>
1052
1082
  </define>
@@ -1060,6 +1090,8 @@
1060
1090
  <ref name="keyword"/>
1061
1091
  <ref name="xref"/>
1062
1092
  <ref name="hyperlink"/>
1093
+ <ref name="index"/>
1094
+ <ref name="index-xref"/>
1063
1095
  </choice>
1064
1096
  </element>
1065
1097
  </define>
@@ -1071,6 +1103,9 @@
1071
1103
  <optional>
1072
1104
  <attribute name="style"/>
1073
1105
  </optional>
1106
+ <optional>
1107
+ <attribute name="custom-charset"/>
1108
+ </optional>
1074
1109
  <oneOrMore>
1075
1110
  <ref name="TextElement"/>
1076
1111
  </oneOrMore>
@@ -1126,6 +1161,8 @@
1126
1161
  <choice>
1127
1162
  <ref name="PureTextElement"/>
1128
1163
  <ref name="stem"/>
1164
+ <ref name="index"/>
1165
+ <ref name="index-xref"/>
1129
1166
  </choice>
1130
1167
  </zeroOrMore>
1131
1168
  </element>
@@ -1136,6 +1173,8 @@
1136
1173
  <choice>
1137
1174
  <ref name="PureTextElement"/>
1138
1175
  <ref name="stem"/>
1176
+ <ref name="index"/>
1177
+ <ref name="index-xref"/>
1139
1178
  </choice>
1140
1179
  </zeroOrMore>
1141
1180
  </element>
@@ -1369,6 +1408,9 @@
1369
1408
  <optional>
1370
1409
  <attribute name="number"/>
1371
1410
  </optional>
1411
+ <optional>
1412
+ <attribute name="branch-number"/>
1413
+ </optional>
1372
1414
  <optional>
1373
1415
  <attribute name="obligation">
1374
1416
  <choice>
@@ -1592,6 +1634,9 @@
1592
1634
  <optional>
1593
1635
  <attribute name="number"/>
1594
1636
  </optional>
1637
+ <optional>
1638
+ <attribute name="branch-number"/>
1639
+ </optional>
1595
1640
  <optional>
1596
1641
  <attribute name="type"/>
1597
1642
  </optional>
@@ -1643,6 +1688,9 @@
1643
1688
  <optional>
1644
1689
  <attribute name="number"/>
1645
1690
  </optional>
1691
+ <optional>
1692
+ <attribute name="branch-number"/>
1693
+ </optional>
1646
1694
  <optional>
1647
1695
  <ref name="section-title"/>
1648
1696
  </optional>
@@ -1740,6 +1788,9 @@
1740
1788
  <optional>
1741
1789
  <attribute name="number"/>
1742
1790
  </optional>
1791
+ <optional>
1792
+ <attribute name="branch-number"/>
1793
+ </optional>
1743
1794
  <optional>
1744
1795
  <attribute name="obligation">
1745
1796
  <choice>
@@ -40,6 +40,7 @@ module Metanorma
40
40
  end
41
41
 
42
42
  def output(isodoc_node, inname, outname, format, options={})
43
+ options_preprocess(options)
43
44
  case format
44
45
  when :html then IsoDoc::Ogc::HtmlConvert.new(options)
45
46
  .convert(inname, isodoc_node, nil, outname)
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Ogc
3
- VERSION = "2.4.2".freeze
3
+ VERSION = "2.4.6".freeze
4
4
  end
5
5
  end
@@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
26
26
  spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
27
27
 
28
28
  spec.add_dependency "iso-639"
29
- spec.add_dependency "metanorma-standoc", "~> 2.6.0"
29
+ spec.add_dependency "metanorma-standoc", "~> 2.7.0"
30
30
 
31
31
  spec.add_development_dependency "debug"
32
32
  spec.add_development_dependency "equivalent-xml", "~> 0.6"
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: 2.4.2
4
+ version: 2.4.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-09-11 00:00:00.000000000 Z
11
+ date: 2023-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: iso-639
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 2.6.0
33
+ version: 2.7.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 2.6.0
40
+ version: 2.7.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: debug
43
43
  requirement: !ruby/object:Gem::Requirement