metanorma-ietf 3.0.0 → 3.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6252e62c4528b954e8b212f8f4ecbd2743cf92ce0826851141e9bb5625a33b65
4
- data.tar.gz: 54297c4b4d966720210747f55c42f67dbaf8154cb6c4638c7c8714aebf43d032
3
+ metadata.gz: 99a9015764516ae9e7eaac9862c48e49facb45c08e3b68744d11cb0b698a0921
4
+ data.tar.gz: 5c445117afb3a242d18973a99ec0eabeb4c0cfe582bf19da1e38a35657dfa366
5
5
  SHA512:
6
- metadata.gz: 3ba0e479fa11a65a1be98cdf6b18546fc4e633411e94ad8f23fc02492eb027018648abdef26ac81c4f5faed351c70d5871d3446017811c8621c33ba75a5899d8
7
- data.tar.gz: 5381ff67f5acd1050032ee09a128e1e466fcae7624d8e3be8d1508ba401a158df4caadea2859f0cbb99ac46d32a41430f1d9f3c9ee145c0e8706cea799f307eb
6
+ metadata.gz: '0316278f956b44dbe26db8bdb236c5e42b30228c06552de7b78c61530800d46f1d00918d7f4c7bf13b76a518d8960fd204375ec2a5f6aa271f5ea3ce10f06b26'
7
+ data.tar.gz: bd4b8b4489cac7307aeee01b002a6a6db32f567489da41d6385522ab21ec6081c1c9f29f3110b3f3ed29a03e7c93be5fb603d3bb228d7aef23cfd75447c7a45b
@@ -107,10 +107,10 @@ module IsoDoc
107
107
  end
108
108
 
109
109
  def get_linkend(node)
110
- contents = node.children.reject do |c|
111
- %w{locality localityStack}.include? c.name
112
- end
113
- .select { |c| !c.text? || /\S/.match(c) }
110
+ no_loc_contents = node.children.reject do |c|
111
+ %w{locality localityStack location}.include? c.name
112
+ end
113
+ contents = no_loc_contents.select { |c| !c.text? || /\S/.match(c) }
114
114
  !contents.empty? and
115
115
  return Nokogiri::XML::NodeSet.new(node.document, contents).to_xml
116
116
  ""
@@ -122,9 +122,10 @@ module IsoDoc
122
122
  end
123
123
  relative = node["relative"] ||
124
124
  node.at(ns(".//locality[@type = 'anchor']/referenceFrom"))&.text || ""
125
- section = eref_clause(node.xpath(ns("./locality | ./localityStack")),
126
- nil) || ""
127
- #section = "" unless relative.empty?
125
+ section = @isodoc.eref_localities(
126
+ node.xpath(ns("./locality | ./localityStack")), nil, node
127
+ )&.sub(/^,/, "")&.sub(/^\s*(Section|Clause)/, "")&.strip&.sub(/,$/, "") || ""
128
+ # section = "" unless relative.empty?
128
129
  out.relref **attr_code(target: node["bibitemid"], section: section,
129
130
  relative: relative,
130
131
  displayFormat: node["displayFormat"]) do |l|
@@ -132,30 +133,6 @@ module IsoDoc
132
133
  end
133
134
  end
134
135
 
135
- def eref_clause(refs, target)
136
- ret = []
137
- ret1 = ""
138
- refs.each do |l|
139
- if l.name == "localityStack"
140
- ret << ret1
141
- ret1 = ""
142
- ret << eref_clause1(l.elements, target)
143
- else ret1 += eref_clause1([l], target)
144
- end
145
- end
146
- ret << ret1
147
- ret.reject { |c| c.nil? || c.empty? }.join("; ")
148
- end
149
-
150
- def eref_clause1(refs, _target)
151
- refs.each do |l|
152
- next unless %w(clause section).include? l["type"]
153
-
154
- return l&.at(ns("./referenceFrom"))&.text
155
- end
156
- ""
157
- end
158
-
159
136
  def index_parse(node, out)
160
137
  out.iref nil, **attr_code(item: node.at(ns("./primary")).text,
161
138
  primary: node["primary"],
@@ -67,7 +67,7 @@ module IsoDoc
67
67
  u["type"] == "DOI" and
68
68
  out.seriesInfo nil, **attr_code(value: u.text.sub(/^DOI /, ""),
69
69
  name: "DOI")
70
- u["type"] == "IETF" and docidentifier_ietf(u, out)
70
+ %w(IETF RFC).include?(u["type"]) and docidentifier_ietf(u, out)
71
71
  end
72
72
  end
73
73
 
@@ -13,85 +13,89 @@ require_relative "./validation"
13
13
  require_relative "./xref"
14
14
  require_relative "./init"
15
15
 
16
- module IsoDoc::Ietf
17
- class RfcConvert < ::IsoDoc::Convert
18
- def convert1(docxml, _filename, _dir)
19
- @xrefs.parse docxml
20
- info docxml, nil
21
- xml = noko do |xml|
22
- xml.rfc **attr_code(rfc_attributes(docxml)) do |html|
23
- make_link(html, docxml)
24
- make_front(html, docxml)
25
- make_middle(html, docxml)
26
- make_back(html, docxml)
27
- end
28
- end.join("\n").sub(/<!DOCTYPE[^>]+>\n/, "")
29
- set_pis(docxml, Nokogiri::XML(xml))
30
- end
16
+ module IsoDoc
17
+ module Ietf
18
+ class RfcConvert < ::IsoDoc::Convert
19
+ def convert1(docxml, _filename, _dir)
20
+ @xrefs.parse docxml
21
+ info docxml, nil
22
+ ret = noko do |xml|
23
+ xml.rfc **attr_code(rfc_attributes(docxml)) do |html|
24
+ make_link(html, docxml)
25
+ make_front(html, docxml)
26
+ make_middle(html, docxml)
27
+ make_back(html, docxml)
28
+ end
29
+ end.join("\n").sub(/<!DOCTYPE[^>]+>\n/, "")
30
+ set_pis(docxml, Nokogiri::XML(ret))
31
+ end
31
32
 
32
- def metadata_init(lang, script, i18n)
33
- @meta = Metadata.new(lang, script, i18n)
34
- end
33
+ def metadata_init(lang, script, i18n)
34
+ @meta = Metadata.new(lang, script, i18n)
35
+ end
35
36
 
36
- def xref_init(lang, script, klass, i18n, options)
37
- @xrefs = Xref.new(lang, script, klass, i18n, options)
38
- end
37
+ def xref_init(lang, script, klass, i18n, options)
38
+ @xrefs = Xref.new(lang, script, klass, i18n, options)
39
+ end
39
40
 
40
- def extract_delims(text)
41
- @openmathdelim = "$$"
42
- @closemathdelim = "$$"
43
- while %r{#{Regexp.escape(@openmathdelim)}}m.match(text) ||
44
- %r{#{Regexp.escape(@closemathdelim)}}m.match(text)
45
- @openmathdelim += "$"
46
- @closemathdelim += "$"
41
+ def extract_delims(text)
42
+ @openmathdelim = "$$"
43
+ @closemathdelim = "$$"
44
+ while %r{#{Regexp.escape(@openmathdelim)}}m.match(text) ||
45
+ %r{#{Regexp.escape(@closemathdelim)}}m.match(text)
46
+ @openmathdelim += "$"
47
+ @closemathdelim += "$"
48
+ end
49
+ [@openmathdelim, @closemathdelim]
47
50
  end
48
- [@openmathdelim, @closemathdelim]
49
- end
50
51
 
51
- def error_parse(node, out)
52
- case node.name
53
- when "bcp14" then bcp14_parse(node, out)
54
- when "concept" then concept_parse(node, out)
55
- when "verbal-definition", "non-verbal-representation"
56
- node.elements.each { |n| parse(n, out) }
57
- else
58
- text = node.to_xml.gsub(/</, "&lt;").gsub(/>/, "&gt;")
59
- out.t { |p| p << text }
52
+ def error_parse(node, out)
53
+ case node.name
54
+ when "bcp14" then bcp14_parse(node, out)
55
+ when "concept" then concept_parse(node, out)
56
+ when "verbal-definition", "non-verbal-representation"
57
+ node.elements.each { |n| parse(n, out) }
58
+ else
59
+ text = node.to_xml.gsub(/</, "&lt;").gsub(/>/, "&gt;")
60
+ out.t { |p| p << text }
61
+ end
60
62
  end
61
- end
62
63
 
63
- def omit_docid_prefix(prefix)
64
- return true if prefix == "IETF"
64
+ def omit_docid_prefix(prefix)
65
+ return true if %w(IETF RFC).include?(prefix)
65
66
 
66
- super
67
- end
67
+ super
68
+ end
68
69
 
69
- def textcleanup(docxml)
70
- passthrough_cleanup(docxml)
71
- end
70
+ def textcleanup(docxml)
71
+ passthrough_cleanup(docxml)
72
+ end
72
73
 
73
- def postprocess(result, filename, _dir)
74
- result = from_xhtml(cleanup(to_xhtml(textcleanup(result))))
75
- .sub(/<!DOCTYPE[^>]+>\n/, "")
76
- .sub(/(<rfc[^<]+? )lang="[^"]+"/, "\\1")
77
- File.open(filename, "w:UTF-8") { |f| f.write(result) }
78
- schema_validate(filename)
79
- @files_to_delete.each { |f| FileUtils.rm_rf f }
80
- content_validate(to_xhtml(result), filename)
81
- end
74
+ def postprocess(result, filename, _dir)
75
+ result = from_xhtml(cleanup(to_xhtml(textcleanup(result))))
76
+ .sub(/<!DOCTYPE[^>]+>\n/, "")
77
+ .sub(/(<rfc[^<]+? )lang="[^"]+"/, "\\1")
78
+ File.open(filename, "w:UTF-8") { |f| f.write(result) }
79
+ schema_validate(filename)
80
+ @files_to_delete.each { |f| FileUtils.rm_rf f }
81
+ content_validate(to_xhtml(result), filename)
82
+ end
82
83
 
83
- def init_file(filename, debug)
84
- filename = filename.sub(/\.rfc\.xml$/, ".rfc")
85
- super
86
- end
84
+ def init_file(filename, debug)
85
+ filename = filename.sub(/\.rfc\.xml$/, ".rfc")
86
+ super
87
+ end
87
88
 
88
- def initialize(options)
89
- super
90
- @xinclude = options[:use_xinclude] == "true"
91
- @format = :rfc
92
- @suffix = "rfc.xml"
93
- end
89
+ def initialize(options)
90
+ super
91
+ @xinclude = options[:use_xinclude] == "true"
92
+ @format = :rfc
93
+ @suffix = "rfc.xml"
94
+ @isodoc = IsoDoc::PresentationXMLConvert.new({})
95
+ @isodoc.i18n_init("en", "Latn")
96
+ end
94
97
 
95
- include ::IsoDoc::Ietf::Init
98
+ include ::IsoDoc::Ietf::Init
99
+ end
96
100
  end
97
101
  end
@@ -47,7 +47,7 @@ module IsoDoc
47
47
  def termdef_parse(node, out)
48
48
  set_termdomain("")
49
49
  node.xpath(ns("./definition")).size > 1 and
50
- IsoDoc::PresentationXMLConvert.new({}).multidef(node)
50
+ @isodoc.multidef(node)
51
51
  clause_parse(node, out)
52
52
  end
53
53
 
@@ -6,9 +6,10 @@ module IsoDoc
6
6
  def termnote_anchor_names(docxml)
7
7
  docxml.xpath(ns("//term[descendant::termnote]")).each do |t|
8
8
  c = IsoDoc::XrefGen::Counter.new
9
- notes = t.xpath(ns(".//termnote"))
9
+ notes = t.xpath(ns("./termnote"))
10
10
  notes.each do |n|
11
11
  next if n["id"].nil? || n["id"].empty?
12
+
12
13
  idx = notes.size == 1 ? "" : " #{c.increment(n).print}"
13
14
  @anchors[n["id"]] =
14
15
  anchor_struct(idx, n, @labels["note_xref"], "note", false)
@@ -173,9 +173,11 @@
173
173
  <data type="dateTime"/>
174
174
  </attribute>
175
175
  </optional>
176
- <attribute name="from">
177
- <data type="IDREF"/>
178
- </attribute>
176
+ <optional>
177
+ <attribute name="from">
178
+ <data type="IDREF"/>
179
+ </attribute>
180
+ </optional>
179
181
  <optional>
180
182
  <attribute name="to">
181
183
  <data type="IDREF"/>
@@ -209,9 +209,6 @@
209
209
  <zeroOrMore>
210
210
  <ref name="contact"/>
211
211
  </zeroOrMore>
212
- <zeroOrMore>
213
- <ref name="uri"/>
214
- </zeroOrMore>
215
212
  </element>
216
213
  </define>
217
214
  <define name="fullname">
@@ -401,9 +398,9 @@
401
398
  <choice>
402
399
  <!-- iso191606 TODO -->
403
400
  <group>
404
- <oneOrMore>
401
+ <zeroOrMore>
405
402
  <ref name="street"/>
406
- </oneOrMore>
403
+ </zeroOrMore>
407
404
  <ref name="city"/>
408
405
  <optional>
409
406
  <ref name="state"/>
@@ -828,6 +825,11 @@
828
825
  <optional>
829
826
  <attribute name="scope"/>
830
827
  </optional>
828
+ <optional>
829
+ <attribute name="primary">
830
+ <data type="boolean"/>
831
+ </attribute>
832
+ </optional>
831
833
  <text/>
832
834
  </element>
833
835
  </define>
@@ -43,11 +43,11 @@ module Metanorma
43
43
  end
44
44
 
45
45
  def rfc_anchor_cleanup(xml)
46
- map = xml.xpath("//bibitem[docidentifier[@type = 'IETF']"\
46
+ map = xml.xpath("//bibitem[docidentifier[@type = 'IETF' or @type = 'RFC']"\
47
47
  "[@scope = 'anchor']]").each_with_object({}) do |b, m|
48
48
  next if b.at("./ancestor::bibdata | ./ancestor::bibitem")
49
49
 
50
- id = b.at("./docidentifier[@type = 'IETF'][@scope = 'anchor']").text
50
+ id = b.at("./docidentifier[@type = 'IETF' or @type = 'RFC'][@scope = 'anchor']").text
51
51
  m[b["id"]] = id
52
52
  b["id"] = id
53
53
  end
@@ -345,7 +345,7 @@
345
345
  <optional>
346
346
  <attribute name="format"/>
347
347
  </optional>
348
- <text/>
348
+ <ref name="XrefBody"/>
349
349
  </element>
350
350
  </define>
351
351
  <define name="erefType">
@@ -32,6 +32,43 @@
32
32
  <ref name="DocumentType"/>
33
33
  </element>
34
34
  </define>
35
+ <define name="index">
36
+ <element name="index">
37
+ <optional>
38
+ <attribute name="to">
39
+ <data type="IDREF"/>
40
+ </attribute>
41
+ </optional>
42
+ <element name="primary">
43
+ <oneOrMore>
44
+ <choice>
45
+ <ref name="PureTextElement"/>
46
+ <ref name="stem"/>
47
+ </choice>
48
+ </oneOrMore>
49
+ </element>
50
+ <optional>
51
+ <element name="secondary">
52
+ <oneOrMore>
53
+ <choice>
54
+ <ref name="PureTextElement"/>
55
+ <ref name="stem"/>
56
+ </choice>
57
+ </oneOrMore>
58
+ </element>
59
+ </optional>
60
+ <optional>
61
+ <element name="tertiary">
62
+ <oneOrMore>
63
+ <choice>
64
+ <ref name="PureTextElement"/>
65
+ <ref name="stem"/>
66
+ </choice>
67
+ </oneOrMore>
68
+ </element>
69
+ </optional>
70
+ </element>
71
+ </define>
35
72
  <define name="bibitem">
36
73
  <element name="bibitem">
37
74
  <attribute name="id">
@@ -115,9 +152,7 @@
115
152
  <data type="boolean"/>
116
153
  </attribute>
117
154
  </optional>
118
- <oneOrMore>
119
- <ref name="PureTextElement"/>
120
- </oneOrMore>
155
+ <ref name="XrefBody"/>
121
156
  </element>
122
157
  </define>
123
158
  <define name="erefType">
@@ -151,6 +186,42 @@
151
186
  <ref name="PureTextElement"/>
152
187
  </oneOrMore>
153
188
  </define>
189
+ <define name="localityStack">
190
+ <element name="localityStack">
191
+ <optional>
192
+ <attribute name="connective">
193
+ <choice>
194
+ <value>and</value>
195
+ <value>or</value>
196
+ <value>from</value>
197
+ <value>to</value>
198
+ <value/>
199
+ </choice>
200
+ </attribute>
201
+ </optional>
202
+ <zeroOrMore>
203
+ <ref name="locality"/>
204
+ </zeroOrMore>
205
+ </element>
206
+ </define>
207
+ <define name="sourceLocalityStack">
208
+ <element name="sourceLocalityStack">
209
+ <optional>
210
+ <attribute name="connective">
211
+ <choice>
212
+ <value>and</value>
213
+ <value>or</value>
214
+ <value>from</value>
215
+ <value>to</value>
216
+ <value/>
217
+ </choice>
218
+ </attribute>
219
+ </optional>
220
+ <zeroOrMore>
221
+ <ref name="sourceLocality"/>
222
+ </zeroOrMore>
223
+ </element>
224
+ </define>
154
225
  <define name="ul">
155
226
  <element name="ul">
156
227
  <attribute name="id">
@@ -1027,6 +1098,26 @@
1027
1098
  </zeroOrMore>
1028
1099
  </element>
1029
1100
  </define>
1101
+ <define name="sub">
1102
+ <element name="sub">
1103
+ <zeroOrMore>
1104
+ <choice>
1105
+ <ref name="PureTextElement"/>
1106
+ <ref name="stem"/>
1107
+ </choice>
1108
+ </zeroOrMore>
1109
+ </element>
1110
+ </define>
1111
+ <define name="sup">
1112
+ <element name="sup">
1113
+ <zeroOrMore>
1114
+ <choice>
1115
+ <ref name="PureTextElement"/>
1116
+ <ref name="stem"/>
1117
+ </choice>
1118
+ </zeroOrMore>
1119
+ </element>
1120
+ </define>
1030
1121
  <define name="pagebreak">
1031
1122
  <element name="pagebreak">
1032
1123
  <optional>
@@ -1041,6 +1132,16 @@
1041
1132
  </define>
1042
1133
  </include>
1043
1134
  <!-- end overrides -->
1135
+ <define name="image" combine="choice">
1136
+ <element name="svg">
1137
+ <oneOrMore>
1138
+ <choice>
1139
+ <text/>
1140
+ <ref name="AnyElement"/>
1141
+ </choice>
1142
+ </oneOrMore>
1143
+ </element>
1144
+ </define>
1044
1145
  <define name="MultilingualRenderingType">
1045
1146
  <choice>
1046
1147
  <value>common</value>
@@ -2216,7 +2317,18 @@
2216
2317
  <ref name="MultilingualRenderingType"/>
2217
2318
  </attribute>
2218
2319
  </optional>
2219
- <ref name="paragraph"/>
2320
+ <oneOrMore>
2321
+ <choice>
2322
+ <ref name="formula"/>
2323
+ <ref name="ul"/>
2324
+ <ref name="ol"/>
2325
+ <ref name="dl"/>
2326
+ <ref name="quote"/>
2327
+ <ref name="sourcecode"/>
2328
+ <ref name="paragraph"/>
2329
+ <ref name="figure"/>
2330
+ </choice>
2331
+ </oneOrMore>
2220
2332
  </element>
2221
2333
  </define>
2222
2334
  <define name="termsource">
@@ -2563,4 +2675,30 @@
2563
2675
  </zeroOrMore>
2564
2676
  </element>
2565
2677
  </define>
2678
+ <define name="XrefBody">
2679
+ <zeroOrMore>
2680
+ <ref name="XrefTarget"/>
2681
+ </zeroOrMore>
2682
+ <oneOrMore>
2683
+ <ref name="PureTextElement"/>
2684
+ </oneOrMore>
2685
+ </define>
2686
+ <define name="XrefTarget">
2687
+ <element name="location">
2688
+ <attribute name="target">
2689
+ <data type="string">
2690
+ <param name="pattern">\i\c*|\c+#\c+</param>
2691
+ </data>
2692
+ </attribute>
2693
+ <attribute name="connective">
2694
+ <choice>
2695
+ <value>and</value>
2696
+ <value>or</value>
2697
+ <value>from</value>
2698
+ <value>to</value>
2699
+ <value/>
2700
+ </choice>
2701
+ </attribute>
2702
+ </element>
2703
+ </define>
2566
2704
  </grammar>
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Ietf
3
- VERSION = "3.0.0".freeze
3
+ VERSION = "3.0.4".freeze
4
4
  end
5
5
  end
@@ -48,6 +48,6 @@ Gem::Specification.new do |spec|
48
48
  spec.add_development_dependency "rubocop", "~> 1.5.2"
49
49
  spec.add_development_dependency "simplecov", "~> 0.15"
50
50
  spec.add_development_dependency "timecop", "~> 0.9"
51
- spec.add_development_dependency "vcr", "~> 5.0.0"
51
+ spec.add_development_dependency "vcr", "~> 6.1.0"
52
52
  spec.add_development_dependency "webmock"
53
53
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-ietf
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-01-10 00:00:00.000000000 Z
11
+ date: 2022-03-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mathml2asciimath
@@ -184,14 +184,14 @@ dependencies:
184
184
  requirements:
185
185
  - - "~>"
186
186
  - !ruby/object:Gem::Version
187
- version: 5.0.0
187
+ version: 6.1.0
188
188
  type: :development
189
189
  prerelease: false
190
190
  version_requirements: !ruby/object:Gem::Requirement
191
191
  requirements:
192
192
  - - "~>"
193
193
  - !ruby/object:Gem::Version
194
- version: 5.0.0
194
+ version: 6.1.0
195
195
  - !ruby/object:Gem::Dependency
196
196
  name: webmock
197
197
  requirement: !ruby/object:Gem::Requirement
@@ -296,7 +296,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
296
296
  - !ruby/object:Gem::Version
297
297
  version: '0'
298
298
  requirements: []
299
- rubygems_version: 3.2.32
299
+ rubygems_version: 3.3.9
300
300
  signing_key:
301
301
  specification_version: 4
302
302
  summary: metanorma-ietf lets you write IETF documents, such as Internet-Drafts and