metanorma-ietf 3.0.1 → 3.0.5

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: a30dfa750747253b30b4f126a42af57de34cf3dfa8aadb9fea370479318dbbca
4
- data.tar.gz: efc69ed17e66a50bf4ee3dfcabac1142602e1447a41c7b06f5551355ee5860c5
3
+ metadata.gz: 6b00b4e459d8ef6b3506ed7a090af700868e804787c10fab7dca88476fab221d
4
+ data.tar.gz: a5fcfda2549643625dc8c88a21361da23f4e2b6074be97f5261c71f607fa5057
5
5
  SHA512:
6
- metadata.gz: 889ffb5917a97616ff220dda0fb23167e13180f107cfd9adef5c395dbc35079927fdb671a4018e1c920fbecc1f2c35c8b2faca7169a2b1c6106b1d6c47dc81c1
7
- data.tar.gz: ce7908251bcc737ca78a1233d7d35d79636bd5a356ec1aa0de262659f93c06a66af7702002c1471e8be873e77f334a830ecbb7d5cad5ae569718b5fdda80d894
6
+ metadata.gz: 5d67b66aa2f1daf672ddd422d347f5e84296c5d3f56da70aefa7a33ee96f9fc09fbebfda95103082c0b3297f6bf6302ce8147394b20d89bfbbbdf55170ced303
7
+ data.tar.gz: 9946801435350a61f4590947ae3aba50d12becf4ee29724c659abc33a670c8b2bff6a9ecd803b97f3eec7136e584faf29aa605df13b269457aa5b5d13f29eba8
@@ -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"],
@@ -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 %w(IETF RFC).include?(prefix)
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)
@@ -527,7 +527,7 @@
527
527
  </define>
528
528
  <define name="LocalityType">
529
529
  <data type="string">
530
- <param name="pattern">section|clause|part|paragraph|chapter|page|whole|table|annex|figure|note|list|example|volume|issue|time|anchor|locality:[a-zA-Z0-9_]+</param>
530
+ <param name="pattern">section|clause|part|paragraph|chapter|page|title|line|whole|table|annex|figure|note|list|example|volume|issue|time|anchor|locality:[a-zA-Z0-9_]+</param>
531
531
  </data>
532
532
  </define>
533
533
  <define name="referenceFrom">
@@ -677,6 +677,9 @@
677
677
  <zeroOrMore>
678
678
  <ref name="extent"/>
679
679
  </zeroOrMore>
680
+ <optional>
681
+ <ref name="bibliographic_size"/>
682
+ </optional>
680
683
  <zeroOrMore>
681
684
  <ref name="accesslocation"/>
682
685
  </zeroOrMore>
@@ -922,9 +925,29 @@
922
925
  <text/>
923
926
  </element>
924
927
  </define>
928
+ <define name="sizevalue">
929
+ <element name="value">
930
+ <attribute name="type"/>
931
+ <text/>
932
+ </element>
933
+ </define>
934
+ <define name="bibliographic_size">
935
+ <element name="size">
936
+ <oneOrMore>
937
+ <ref name="sizevalue"/>
938
+ </oneOrMore>
939
+ </element>
940
+ </define>
925
941
  <define name="extent">
926
942
  <element name="extent">
927
- <ref name="BibItemLocality"/>
943
+ <choice>
944
+ <zeroOrMore>
945
+ <ref name="locality"/>
946
+ </zeroOrMore>
947
+ <zeroOrMore>
948
+ <ref name="localityStack"/>
949
+ </zeroOrMore>
950
+ </choice>
928
951
  </element>
929
952
  </define>
930
953
  <define name="series">
@@ -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">
@@ -152,9 +152,7 @@
152
152
  <data type="boolean"/>
153
153
  </attribute>
154
154
  </optional>
155
- <oneOrMore>
156
- <ref name="PureTextElement"/>
157
- </oneOrMore>
155
+ <ref name="XrefBody"/>
158
156
  </element>
159
157
  </define>
160
158
  <define name="erefType">
@@ -188,6 +186,42 @@
188
186
  <ref name="PureTextElement"/>
189
187
  </oneOrMore>
190
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>
191
225
  <define name="ul">
192
226
  <element name="ul">
193
227
  <attribute name="id">
@@ -1098,6 +1132,16 @@
1098
1132
  </define>
1099
1133
  </include>
1100
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>
1101
1145
  <define name="MultilingualRenderingType">
1102
1146
  <choice>
1103
1147
  <value>common</value>
@@ -2631,4 +2675,30 @@
2631
2675
  </zeroOrMore>
2632
2676
  </element>
2633
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>
2634
2704
  </grammar>
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Ietf
3
- VERSION = "3.0.1".freeze
3
+ VERSION = "3.0.5".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.1
4
+ version: 3.0.5
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-02-07 00:00:00.000000000 Z
11
+ date: 2022-04-18 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