metanorma-ietf 1.0.10 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/macos.yml +3 -2
  3. data/.github/workflows/ubuntu.yml +3 -2
  4. data/.github/workflows/windows.yml +4 -3
  5. data/README.adoc +9 -0
  6. data/lib/asciidoctor/ietf/basicdoc.rng +1045 -0
  7. data/lib/asciidoctor/ietf/biblio.rng +1142 -0
  8. data/lib/asciidoctor/ietf/blocks.rb +76 -0
  9. data/lib/asciidoctor/ietf/converter.rb +211 -0
  10. data/lib/asciidoctor/ietf/front.rb +143 -0
  11. data/lib/asciidoctor/ietf/ietf.rng +882 -0
  12. data/lib/asciidoctor/ietf/isodoc.rng +514 -0
  13. data/lib/asciidoctor/ietf/isostandard.rng +860 -0
  14. data/lib/asciidoctor/ietf/reqt.rng +171 -0
  15. data/lib/asciidoctor/ietf/validate.rb +84 -0
  16. data/lib/isodoc/ietf/blocks.rb +215 -0
  17. data/lib/isodoc/ietf/cleanup.rb +220 -0
  18. data/lib/isodoc/ietf/footnotes.rb +70 -0
  19. data/lib/isodoc/ietf/front.rb +232 -0
  20. data/lib/isodoc/ietf/inline.rb +136 -0
  21. data/lib/isodoc/ietf/metadata.rb +62 -0
  22. data/lib/isodoc/ietf/references.rb +129 -0
  23. data/lib/isodoc/ietf/reqt.rb +74 -0
  24. data/lib/isodoc/ietf/rfc_convert.rb +60 -0
  25. data/lib/isodoc/ietf/section.rb +162 -0
  26. data/lib/isodoc/ietf/table.rb +43 -0
  27. data/lib/isodoc/ietf/terms.rb +65 -0
  28. data/lib/metanorma-ietf.rb +2 -1
  29. data/lib/metanorma/ietf/processor.rb +16 -37
  30. data/lib/metanorma/ietf/version.rb +1 -1
  31. data/metanorma-ietf.gemspec +3 -3
  32. metadata +36 -36
  33. data/Gemfile.lock +0 -327
  34. data/lib/asciidoctor/rfc.rb +0 -8
  35. data/lib/asciidoctor/rfc/common/base.rb +0 -544
  36. data/lib/asciidoctor/rfc/common/front.rb +0 -120
  37. data/lib/asciidoctor/rfc/common/validate.rb +0 -31
  38. data/lib/asciidoctor/rfc/v2/base.rb +0 -380
  39. data/lib/asciidoctor/rfc/v2/blocks.rb +0 -299
  40. data/lib/asciidoctor/rfc/v2/converter.rb +0 -60
  41. data/lib/asciidoctor/rfc/v2/front.rb +0 -69
  42. data/lib/asciidoctor/rfc/v2/inline_anchor.rb +0 -111
  43. data/lib/asciidoctor/rfc/v2/lists.rb +0 -135
  44. data/lib/asciidoctor/rfc/v2/table.rb +0 -116
  45. data/lib/asciidoctor/rfc/v2/validate.rng +0 -716
  46. data/lib/asciidoctor/rfc/v3/base.rb +0 -330
  47. data/lib/asciidoctor/rfc/v3/blocks.rb +0 -246
  48. data/lib/asciidoctor/rfc/v3/converter.rb +0 -62
  49. data/lib/asciidoctor/rfc/v3/front.rb +0 -122
  50. data/lib/asciidoctor/rfc/v3/inline_anchor.rb +0 -89
  51. data/lib/asciidoctor/rfc/v3/lists.rb +0 -176
  52. data/lib/asciidoctor/rfc/v3/svg.rng +0 -9081
  53. data/lib/asciidoctor/rfc/v3/table.rb +0 -65
  54. data/lib/asciidoctor/rfc/v3/validate.rng +0 -2143
@@ -1,299 +0,0 @@
1
- require "htmlentities"
2
-
3
- module Asciidoctor
4
- module Rfc::V2
5
- module Blocks
6
- # Syntax:
7
- # [discrete]
8
- # == Section
9
- def floating_title(node)
10
- noko do |xml|
11
- xml.t do |xml_t|
12
- xml_t.spanx node.title, style: "strong"
13
- end
14
- end
15
- end
16
-
17
- def pass(node)
18
- node.content
19
- end
20
-
21
- # Syntax:
22
- # [[id]]
23
- # .Name
24
- # [align=left|center|right,alt=alt_text,type] (optional)
25
- # ....
26
- # literal
27
- # ....
28
- def literal(node)
29
- artwork_attributes = {
30
- align: node.attr("align"),
31
- type: node.attr("type"),
32
- name: node.title,
33
- alt: node.attr("alt"),
34
- }
35
-
36
- # NOTE: html escaping is performed by Nokogiri
37
- artwork_content = "\n" + node.lines.join("\n") + "\n"
38
-
39
- ret = noko do |xml|
40
- if node.parent.context != :example
41
- figure_attributes = {
42
- anchor: node.id,
43
- }
44
- xml.figure **attr_code(figure_attributes) do |xml_figure|
45
- # xml_figure.artwork artwork_content, **attr_code(artwork_attributes)
46
- xml_figure.artwork **attr_code(artwork_attributes) do |a|
47
- a.cdata artwork_content
48
- end
49
- end
50
- else
51
- # xml.artwork artwork_content, **attr_code(artwork_attributes)
52
- xml.artwork **attr_code(artwork_attributes) do |a|
53
- a.cdata artwork_content
54
- end
55
- end
56
- end
57
- ret
58
- end
59
-
60
- # stem is treated as literal, but with center alignment
61
- def stem(node)
62
- artwork_attributes = {
63
- align: node.attr("align") || "center",
64
- type: node.attr("type"),
65
- name: node.title,
66
- alt: node.attr("alt"),
67
- }
68
-
69
- # NOTE: html escaping is performed by Nokogiri
70
- artwork_content = "\n" + node.lines.join("\n") + "\n"
71
-
72
- ret = noko do |xml|
73
- if node.parent.context != :example
74
- figure_attributes = {
75
- anchor: node.id,
76
- }
77
- xml.figure **attr_code(figure_attributes) do |xml_figure|
78
- # xml_figure.artwork artwork_content, **attr_code(artwork_attributes)
79
- xml_figure.artwork **attr_code(artwork_attributes) do |a|
80
- a.cdata artwork_content
81
- end
82
- end
83
- else
84
- # xml.artwork artwork_content, **attr_code(artwork_attributes)
85
- xml.artwork **attr_code(artwork_attributes) do |a|
86
- a.cdata artwork_content
87
- end
88
- end
89
- end
90
- ret
91
- end
92
-
93
- # Syntax:
94
- # = Title
95
- # Author
96
- # :HEADER
97
- #
98
- # ABSTRACT
99
- #
100
- # NOTE: note
101
- #
102
- # [NOTE]
103
- # .Title (in preamble)
104
- # ====
105
- # Content
106
- # ====
107
- #
108
- # [NOTE] (in preamble)
109
- # [NOTE,source=name] (in body)
110
- # .Title
111
- # ====
112
- # Content
113
- # ====
114
- #
115
- # @note admonitions within preamble are notes. Elsewhere, they are comments.
116
- # UPDATE 20190517
117
- # @note admonitions within preamble are notes. Elsewhere, they are LABEL followed by text
118
- def admonition(node)
119
- result = []
120
- if node.parent.context == :preamble
121
- note_attributes = {
122
- # default title provided: title is mandatory
123
- title: (node.title.nil? ? "NOTE" : node.title),
124
- }
125
-
126
- note_contents = HTMLEntities.new.decode([paragraph1(node)].flatten.join("\n"))
127
-
128
- result << noko do |xml|
129
- xml.note **attr_code(note_attributes) do |xml_note|
130
- xml_note << note_contents
131
- end
132
- end
133
- else
134
- =begin
135
- cref_attributes = {
136
- anchor: node.id,
137
- source: node.attr("source"),
138
- }
139
-
140
- # remove all formatting: cref content is pure text
141
- cref_contents = flatten_rawtext(node)
142
- cref_contents = [cref_contents].flatten.join("\n")
143
- warn <<~WARNING_MESSAGE if node.blocks?
144
- asciidoctor: WARNING (#{node.lineno}): comment can not contain blocks of text in XML RFC:\n #{node.content}
145
- WARNING_MESSAGE
146
-
147
- result << noko do |xml|
148
- if node.parent.context !~ /table|example|paragraph|section/
149
- xml.t do |xml_t|
150
- xml_t.cref **attr_code(cref_attributes) do |xml_cref|
151
- xml_cref << cref_contents
152
- end
153
- end
154
- else
155
- xml.cref **attr_code(cref_attributes) do |xml_cref|
156
- xml_cref << cref_contents
157
- end
158
- end
159
- end
160
- end
161
- =end
162
- result << "<t>#{node.attr("name").upcase}</t>"
163
- if node.blocks?
164
- node.blocks.each do |b|
165
- result << send(b.context, b)
166
- end
167
- else
168
- result << paragraph(node)
169
- end
170
- end
171
- result
172
- end
173
-
174
- # is this a text-only example? if so, mark it up as paragraphs
175
- def text_only_example(node)
176
- seen_artwork = false
177
- node.blocks.each do |b|
178
- case b.context
179
- when :listing, :image, :literal, :stem
180
- seen_artwork = true
181
- end
182
- end
183
- !seen_artwork
184
- end
185
-
186
- # Syntax:
187
- # [[id]]
188
- # .Title
189
- # [align,alt,suppress-title]
190
- # ====
191
- # Example
192
- # ====
193
- def example(node)
194
- figure_attributes = {
195
- anchor: node.id,
196
- align: node.attr("align"),
197
- alt: node.alt,
198
- title: node.title,
199
- 'suppress-title': node.attr("suppress-title"),
200
- # TODO: is 'suppress-title' the correct attribute name?
201
- }
202
- # TODO iref
203
- seen_artwork = false
204
-
205
- if text_only_example(node)
206
- noko do |xml|
207
- node.blocks.each do |b|
208
- xml << node.content
209
- end
210
- end
211
- else
212
- noko do |xml|
213
- xml.figure **attr_code(figure_attributes) do |xml_figure|
214
- node.blocks.each do |b|
215
- case b.context
216
- when :listing, :image, :literal, :stem
217
- xml_figure << send(b.context, b).join("\n")
218
- seen_artwork = true
219
- else
220
- # we want to see the para text, not its <t> container
221
- if seen_artwork
222
- xml_figure.postamble do |postamble|
223
- postamble << Array(b.content).join("\n")
224
- end
225
- else
226
- xml_figure.preamble do |preamble|
227
- preamble << Array(b.content).join("\n")
228
- end
229
- end
230
- end
231
- end
232
- end
233
- end
234
- end
235
- end
236
-
237
- # Syntax:
238
- # .name
239
- # [source,type,src=uri] (src is mutually exclusive with listing content) (v3)
240
- # [source,type,src=uri,align,alt] (src is mutually exclusive with listing content) (v2)
241
- # ----
242
- # code
243
- # ----
244
- def listing(node)
245
- sourcecode_attributes = {
246
- align: node.attr("align"),
247
- alt: node.alt,
248
- name: node.title,
249
- type: node.attr("language"),
250
- src: node.attr("src"),
251
- }
252
-
253
- # NOTE: html escaping is performed by Nokogiri
254
- sourcecode_content =
255
- sourcecode_attributes[:src].nil? ? "\n" + node.lines.join("\n") + "\n" : ""
256
-
257
- noko do |xml|
258
- if node.parent.context != :example
259
- figure_attributes = {
260
- anchor: node.id,
261
- }
262
- xml.figure **attr_code(figure_attributes) do |xml_figure|
263
- # xml_figure.artwork sourcecode_content, **attr_code(sourcecode_attributes)
264
- xml_figure.artwork **attr_code(sourcecode_attributes) do |a|
265
- a.cdata sourcecode_content
266
- end
267
-
268
- end
269
- else
270
- # xml.artwork sourcecode_content, **attr_code(sourcecode_attributes)
271
- xml.artwork **attr_code(sourcecode_attributes) do |a|
272
- a.cdata sourcecode_content
273
- end
274
- end
275
- end
276
- end
277
-
278
- def quote(node)
279
- result = []
280
- if node.blocks?
281
- node.blocks.each do |b|
282
- result << send(b.context, b)
283
- end
284
- else
285
- result = paragraph(node)
286
- end
287
- if node.attr("citetitle") || node.attr("attribution")
288
- cite = node.attr("attribution") || ""
289
- cite += ", " if node.attr("citetitle") && node.attr("attribution")
290
- cite += (node.attr("citetitle") || "")
291
- cite = "-- " + cite
292
- result << "<t>#{cite}</t>"
293
- end
294
- result
295
- end
296
-
297
- end
298
- end
299
- end
@@ -1,60 +0,0 @@
1
- require "asciidoctor"
2
-
3
- require_relative "../common/base"
4
- require_relative "../common/front"
5
- require_relative "../common/validate"
6
- require_relative "base"
7
- require_relative "blocks"
8
- require_relative "front"
9
- require_relative "inline_anchor"
10
- require_relative "lists"
11
- require_relative "table"
12
-
13
- module Asciidoctor
14
- module Rfc::V2
15
- # A {Converter} implementation that generates RFC XML 2 output, a format used to
16
- # format RFC proposals (https://tools.ietf.org/html/rfc7749)
17
- #
18
- # Features drawn from https://github.com/miekg/mmark/wiki/Syntax and
19
- # https://github.com/riboseinc/rfc2md
20
- class Converter
21
- include ::Asciidoctor::Converter
22
- include ::Asciidoctor::Writer
23
-
24
- include ::Asciidoctor::Rfc::Common::Base
25
- include ::Asciidoctor::Rfc::Common::Front
26
- include ::Asciidoctor::Rfc::Common::Validate
27
- include ::Asciidoctor::Rfc::V2::Base
28
- include ::Asciidoctor::Rfc::V2::Blocks
29
- include ::Asciidoctor::Rfc::V2::Front
30
- include ::Asciidoctor::Rfc::V2::InlineAnchor
31
- include ::Asciidoctor::Rfc::V2::Lists
32
- include ::Asciidoctor::Rfc::V2::Table
33
-
34
- register_for "rfc2"
35
-
36
- $seen_back_matter = false
37
- $xreftext = {}
38
-
39
- def initialize(backend, opts)
40
- super
41
- Asciidoctor::Compliance.natural_xrefs = false
42
- basebackend "html"
43
- outfilesuffix ".xml"
44
- end
45
-
46
- # alias_method :pass, :content
47
- alias_method :embedded, :content
48
- alias_method :sidebar, :content
49
- alias_method :audio, :skip
50
- alias_method :colist, :skip
51
- alias_method :page_break, :skip
52
- alias_method :thematic_break, :skip
53
- alias_method :video, :skip
54
- alias_method :inline_button, :skip
55
- alias_method :inline_kbd, :skip
56
- alias_method :inline_menu, :skip
57
- alias_method :inline_image, :skip
58
- end
59
- end
60
- end
@@ -1,69 +0,0 @@
1
- module Asciidoctor
2
- module Rfc::V2
3
- module Front
4
- # Syntax:
5
- # = Title
6
- # Author
7
- # :METADATA
8
- def front(node, xml)
9
- xml.front do |xml_front|
10
- title node, xml_front
11
- author node, xml_front
12
- date node, xml_front
13
- area node, xml_front
14
- workgroup node, xml_front
15
- keyword node, xml_front
16
- end
17
- end
18
-
19
- def organization(node, suffix, xml)
20
- organization = node.attr("organization#{suffix}")
21
- organization_abbrev = node.attr("organization_abbrev#{suffix}")
22
- organization_attributes = {
23
- abbrev: organization_abbrev,
24
- }
25
- unless organization.nil?
26
- xml.organization **attr_code(organization_attributes) do |org|
27
- org << organization
28
- end
29
- end
30
- end
31
-
32
- def address(node, suffix, xml)
33
- email = node.attr("email#{suffix}")
34
- facsimile = node.attr("fax#{suffix}")
35
- phone = node.attr("phone#{suffix}")
36
- street = node.attr("street#{suffix}")
37
- uri = node.attr("uri#{suffix}")
38
-
39
- # If there is no provided elements for address, don't show it
40
- return unless [email, facsimile, phone, street, uri].any?
41
-
42
- # https://tools.ietf.org/html/rfc7749#section-2.27
43
- # Note that at least one <street> element needs to be present;
44
- # however, formatters will handle empty values just fine.
45
- street = street ? street.split("\\ ") : [""]
46
-
47
- xml.address do |xml_address|
48
- xml_address.postal do |xml_postal|
49
- city = node.attr("city#{suffix}")
50
- code = node.attr("code#{suffix}")
51
- country = node.attr("country#{suffix}")
52
- region = node.attr("region#{suffix}")
53
-
54
- street.each { |st| xml_postal.street { |s| s << st } }
55
- xml_postal.city { |c| c << city } unless city.nil?
56
- xml_postal.region { |r| r << region } unless region.nil?
57
- xml_postal.code { |c| c << code } unless code.nil?
58
- xml_postal.country { |c| c << country } unless country.nil?
59
- end
60
-
61
- xml_address.phone { |p| p << phone } unless phone.nil?
62
- xml_address.facsimile { |f| f << facsimile } unless facsimile.nil?
63
- xml_address.email { |e| e << email } unless email.nil?
64
- xml_address.uri { |u| u << uri } unless uri.nil?
65
- end
66
- end
67
- end
68
- end
69
- end
@@ -1,111 +0,0 @@
1
- module Asciidoctor
2
- module Rfc::V2
3
- module InlineAnchor
4
- def inline_anchor(node)
5
- case node.type
6
- when :xref
7
- inline_anchor_xref node
8
- when :link
9
- inline_anchor_link node
10
- when :bibref
11
- inline_anchor_bibref node
12
- when :ref
13
- inline_anchor_ref node
14
- else
15
- warn %(asciidoctor: WARNING (#{current_location(node)}): unknown anchor type: #{node.type.inspect})
16
- end
17
- end
18
-
19
- private
20
-
21
- def inline_anchor_xref(node)
22
- if node.text =~ /^\S+ (of|comma|parens|bare)\b/
23
- # <<crossreference#fragment,section (of|comma|parens|bare): text>> = relref:
24
- # render equivalent in v2
25
- matched = /(?<section>\S+)\s+(?<format>[a-z]+)(: )?(?<text>.*)$/.match node.text
26
-
27
- # fragment inserts file suffix, e.g. rfc2911#fragment becomes rfc2911.xml#fragment
28
- target = node.target.gsub(/^#/, "").gsub(/(.)(\.xml)?#.*$/, "\\1")
29
- # reftarget = target
30
- warn %(asciidoctor: WARNING (#{current_location(node)}): fragments not supported on crossreferences in v2: #{node.target} #{node.text}) if node.target =~ /.#/
31
- # reftarget = "#{target}##{node.attributes['fragment']}" unless node.attributes["path"].nil?
32
-
33
- xref_contents = ""
34
- case matched[:format]
35
- when "of"
36
- prefix = "Section #{matched[:section]} of "
37
- when "comma"
38
- suffix = ", Section #{matched[:section]}"
39
- when "parens"
40
- suffix = " (Section #{matched[:section]})"
41
- when "bare"
42
- xref_contents = matched[:section]
43
- end
44
- unless matched[:text].empty?
45
- xref_contents = if xref_contents.empty?
46
- matched[:text].to_s
47
- else
48
- "#{xref_contents}: #{matched[:text]}"
49
- end
50
- end
51
-
52
- xref_attributes = {
53
- target: target,
54
- }.reject { |_, value| value.nil? }
55
-
56
- else
57
-
58
- matched = /^format=(?<format>counter|title|none|default)(?<text>:\s*.*)?$/.match node.text
59
- xref_contents = if matched.nil?
60
- node.text
61
- else
62
- matched[:text].nil? ? "" : matched[:text].gsub(/^:\s*/, "")
63
- end
64
- matched ||= {}
65
-
66
- warn %(asciidoctor: WARNING (#{current_location(node)}): fragments not supported on crossreferences in v2: #{node.target} #{node.text}) if node.target =~ /.#/
67
- xref_attributes = {
68
- # fragment inserts file suffix, e.g. rfc2911#fragment becomes rfc2911.xml#fragment
69
- target: node.target.gsub(/^#/, "").gsub(/(.)(\.xml)?#.*$/, "\\1"),
70
- format: matched[:format],
71
- align: node.attr("align"),
72
- }
73
- end
74
-
75
- noko do |xml|
76
- xml << prefix unless prefix.nil? || prefix.empty?
77
- xml.xref xref_contents, **attr_code(xref_attributes)
78
- xml << suffix unless suffix.nil? || suffix.empty?
79
- end.join
80
- end
81
-
82
- def inline_anchor_link(node)
83
- eref_contents = node.target == node.text ? nil : node.text
84
-
85
- eref_attributes = {
86
- target: node.target,
87
- }
88
-
89
- noko do |xml|
90
- xml.eref eref_contents, **attr_code(eref_attributes)
91
- end.join
92
- end
93
-
94
- def inline_anchor_bibref(node)
95
- unless node.xreftext.nil?
96
- x = node.xreftext.gsub(/^\[(.+)\]$/, "\\1")
97
- if node.id != x
98
- $xreftext[node.id] = x
99
- end
100
- end
101
- # NOTE technically node.text should be node.reftext, but subs have already been applied to text
102
- # %(<bibanchor="#{node.id}">) # will convert to anchor attribute upstream
103
- nil
104
- end
105
-
106
- def inline_anchor_ref(node)
107
- warn %(asciidoctor: WARNING (#{current_location(node)}): anchor "#{node.id}" is not in a place where XML RFC will recognise it as an anchor attribute)
108
- end
109
- end
110
- end
111
- end