metanorma-ietf 2.0.13 → 2.1.0

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: 618fe15c1205c409e7f57dc672f45545a408bf20dd7fdeb68577e295232bf226
4
- data.tar.gz: 42104d4c8b90df8481c5bf25d598a68e7c447d71bfa53349b4bef8194dd0e3b0
3
+ metadata.gz: 47adf288717bcbd4914d1a3d43fb8eeea4d18fbb6f9675846c9ec37a9664f142
4
+ data.tar.gz: f0486d16c7a457465cce21790e3c76cb3422b0508d5ae57a150e15bf4e1059a7
5
5
  SHA512:
6
- metadata.gz: 18a552d7d528ae211fcbad094c876c6fac60b0503687725edc13d809a3a9f2fd93aafa7a14ede31f47b7b5e9c1d6b5fa092c261f4fd6d63ca9e7eb391fcc6dea
7
- data.tar.gz: 9c58535cb308711ef79df7a58d261887cbbadbedb3fb1a0edcd0247f782b5caa9c58df24ff371ffacd4fe1381f4f4840e61a267903a33fb40ccbd633a7f249c5
6
+ metadata.gz: e22190786fb20f67dd85cc5e0bd3e831e32b5ee54c0de91d08780106a624e902c11108672469afdcf80451489fddc11472f0ee73910592c947550b3f243b4c0b
7
+ data.tar.gz: 85c7688efec6428a459a6d6f7d182c092ad68a5ed6a6e971e379fab3d6c6c46f5e77e083aa11be20d7570691505d3b61da50e217c93643451d215387e747d486
@@ -26,19 +26,9 @@ module Asciidoctor
26
26
  super
27
27
  end
28
28
 
29
- def document(node)
30
- init(node)
31
- ret1 = makexml(node)
32
- ret = ret1.to_xml(indent: 2)
33
- unless node.attr("nodoc") || !node.attr("docfile")
34
- filename = node.attr("docfile").gsub(/\.adoc/, ".xml").
35
- gsub(%r{^.*/}, "")
36
- File.open(filename, "w") { |f| f.write(ret) }
37
- rfc_converter(node).convert filename unless node.attr("nodoc")
38
- end
39
- @log.write(@localdir + @filename + ".err") unless @novalid
40
- @files_to_delete.each { |f| FileUtils.rm f }
41
- ret
29
+ def outputs(node, ret)
30
+ File.open(@filename + ".xml", "w:UTF-8") { |f| f.write(ret) }
31
+ rfc_converter(node).convert(@filename + ".xml")
42
32
  end
43
33
 
44
34
  def doctype(node)
@@ -94,7 +94,7 @@ module IsoDoc::Ietf
94
94
  end
95
95
 
96
96
  def example_label(node, div, name)
97
- n = get_anchors[node["id"]]
97
+ n = @xrefs.get[node["id"]]
98
98
  div.t **attr_code(anchor: node["id"], keepWithNext: "true") do |p|
99
99
  lbl = (n.nil? || n[:label].nil? || n[:label].empty?) ? @example_lbl :
100
100
  l10n("#{@example_lbl} #{n[:label]}")
@@ -144,7 +144,7 @@ module IsoDoc::Ietf
144
144
  def formula_parse1(node, out)
145
145
  out.t **attr_code(anchor: node["id"]) do |p|
146
146
  parse(node.at(ns("./stem")), p)
147
- lbl = anchor(node['id'], :label, false)
147
+ lbl = @xrefs.anchor(node['id'], :label, false)
148
148
  lbl.nil? or
149
149
  p << " (#{lbl})"
150
150
  end
@@ -9,11 +9,12 @@ require_relative "./cleanup"
9
9
  require_relative "./footnotes"
10
10
  require_relative "./references"
11
11
  require_relative "./section"
12
+ require_relative "./xref"
12
13
 
13
14
  module IsoDoc::Ietf
14
15
  class RfcConvert < ::IsoDoc::Convert
15
16
  def convert1(docxml, filename, dir)
16
- anchor_names docxml
17
+ @xrefs.parse docxml
17
18
  info docxml, nil
18
19
  xml = noko do |xml|
19
20
  xml.rfc **attr_code(rfc_attributes(docxml)) do |html|
@@ -30,6 +31,10 @@ module IsoDoc::Ietf
30
31
  @meta = Metadata.new(lang, script, labels)
31
32
  end
32
33
 
34
+ def xref_init(lang, script, klass, labels, options)
35
+ @xrefs = Xref.new(lang, script, klass, labels, options)
36
+ end
37
+
33
38
  def extract_delims(text)
34
39
  @openmathdelim = "$$"
35
40
  @closemathdelim = "$$"
@@ -58,7 +63,7 @@ module IsoDoc::Ietf
58
63
  result = from_xhtml(cleanup(to_xhtml(textcleanup(result)))).
59
64
  sub(/<!DOCTYPE[^>]+>\n/, "").
60
65
  sub(/(<rfc[^<]+? )lang="[^"]+"/, "\\1")
61
- File.open("#{filename}.rfc.xml", "w:UTF-8") { |f| f.write(result) }
66
+ File.open(filename, "w:UTF-8") { |f| f.write(result) }
62
67
  @files_to_delete.each { |f| FileUtils.rm_rf f }
63
68
  end
64
69
 
@@ -71,6 +76,7 @@ module IsoDoc::Ietf
71
76
  super
72
77
  @xinclude = options[:use_xinclude] == "true"
73
78
  @format = :rfc
79
+ @suffix = "rfc.xml"
74
80
  end
75
81
  end
76
82
  end
@@ -48,18 +48,5 @@ module IsoDoc::Ietf
48
48
 
49
49
  def termdocsource_parse(_node, _out)
50
50
  end
51
-
52
- def termnote_anchor_names(docxml)
53
- docxml.xpath(ns("//term[descendant::termnote]")).each do |t|
54
- c = Counter.new
55
- notes = t.xpath(ns(".//termnote"))
56
- notes.each do |n|
57
- next if n["id"].nil? || n["id"].empty?
58
- idx = notes.size == 1 ? "" : " #{c.increment(n).print}"
59
- @anchors[n["id"]] =
60
- anchor_struct(idx, n, @note_xref_lbl, "note", false)
61
- end
62
- end
63
- end
64
51
  end
65
52
  end
@@ -0,0 +1,20 @@
1
+ require "isodoc"
2
+
3
+ module IsoDoc
4
+ module Ietf
5
+ class Xref < IsoDoc::Xref
6
+ def termnote_anchor_names(docxml)
7
+ docxml.xpath(ns("//term[descendant::termnote]")).each do |t|
8
+ c = IsoDoc::XrefGen::Counter.new
9
+ notes = t.xpath(ns(".//termnote"))
10
+ notes.each do |n|
11
+ next if n["id"].nil? || n["id"].empty?
12
+ idx = notes.size == 1 ? "" : " #{c.increment(n).print}"
13
+ @anchors[n["id"]] =
14
+ anchor_struct(idx, n, @labels["note_xref"], "note", false)
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -52,10 +52,11 @@ module Metanorma
52
52
  !which("xml2rfc").nil?
53
53
  end
54
54
 
55
- def output(isodoc_node, outname, format, options={})
55
+ def output(isodoc_node, inname, outname, format, options={})
56
56
  case format
57
57
  when :rfc
58
- IsoDoc::Ietf::RfcConvert.new(options).convert(outname, isodoc_node)
58
+ outname ||= inname.sub(/\.xml$/, ".rfc.xml")
59
+ IsoDoc::Ietf::RfcConvert.new(options).convert(inname, isodoc_node, nil, outname)
59
60
  @done_rfc = true
60
61
 
61
62
  when :txt
@@ -64,9 +65,10 @@ module Metanorma
64
65
  return
65
66
  end
66
67
 
67
- rfcname = outname.sub(/\.txt$/, ".rfc.xml")
68
- output(isodoc_node, outname, :rfc, options) unless @done_rfc
68
+ rfcname = inname.sub(/\.xml$/, ".rfc.xml")
69
+ output(isodoc_node, inname, rfcname, :rfc, options) unless @done_rfc
69
70
 
71
+ outname ||= inname.sub(/\.xml$/, ".txt")
70
72
  system("xml2rfc --text #{rfcname} -o #{outname}")
71
73
 
72
74
  when :pdf
@@ -75,9 +77,10 @@ module Metanorma
75
77
  return
76
78
  end
77
79
 
78
- rfcname = outname.sub(/\.pdf$/, ".rfc.xml")
79
- output(isodoc_node, outname, :rfc, options) unless @done_rfc
80
+ rfcname = inname.sub(/\.xml$/, ".rfc.xml")
81
+ output(isodoc_node, inname, rfcname, :rfc, options) unless @done_rfc
80
82
 
83
+ outname ||= inname.sub(/\.xml$/, ".pdf")
81
84
  system("xml2rfc --pdf #{rfcname} -o #{outname}")
82
85
 
83
86
  when :html
@@ -86,9 +89,10 @@ module Metanorma
86
89
  return
87
90
  end
88
91
 
89
- rfcname = outname.sub(/\.html$/, ".rfc.xml")
90
- output(isodoc_node, outname, :rfc, options) unless @done_rfc
92
+ rfcname = inname.sub(/\.xml$/, ".rfc.xml")
93
+ output(isodoc_node, inname, rfcname, :rfc, options) unless @done_rfc
91
94
 
95
+ outname ||= inname.sub(/\.xml$/, ".html")
92
96
  system("xml2rfc --html #{rfcname} -o #{outname}")
93
97
 
94
98
  else
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Ietf
3
- VERSION = "2.0.13".freeze
3
+ VERSION = "2.1.0".freeze
4
4
  end
5
5
  end
@@ -36,7 +36,7 @@ Gem::Specification.new do |spec|
36
36
  spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
37
37
 
38
38
  spec.add_dependency "metanorma-standoc", "~> 1.4.0"
39
- spec.add_dependency "isodoc", "~> 1.0.0"
39
+ spec.add_dependency "isodoc", "~> 1.1.0"
40
40
  spec.add_dependency "mathml2asciimath"
41
41
 
42
42
  spec.add_development_dependency "byebug"
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: 2.0.13
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-06-19 00:00:00.000000000 Z
11
+ date: 2020-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: metanorma-standoc
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 1.0.0
33
+ version: 1.1.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: 1.0.0
40
+ version: 1.1.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: mathml2asciimath
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -269,6 +269,7 @@ files:
269
269
  - lib/isodoc/ietf/section.rb
270
270
  - lib/isodoc/ietf/table.rb
271
271
  - lib/isodoc/ietf/terms.rb
272
+ - lib/isodoc/ietf/xref.rb
272
273
  - lib/metanorma-ietf.rb
273
274
  - lib/metanorma/ietf.rb
274
275
  - lib/metanorma/ietf/processor.rb
@@ -281,7 +282,7 @@ homepage: https://github.com/metanorma/metanorma-ietf
281
282
  licenses:
282
283
  - BSD-2-Clause
283
284
  metadata: {}
284
- post_install_message:
285
+ post_install_message:
285
286
  rdoc_options: []
286
287
  require_paths:
287
288
  - lib
@@ -296,9 +297,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
296
297
  - !ruby/object:Gem::Version
297
298
  version: '0'
298
299
  requirements: []
299
- rubyforge_project:
300
- rubygems_version: 2.7.6
301
- signing_key:
300
+ rubygems_version: 3.0.3
301
+ signing_key:
302
302
  specification_version: 4
303
303
  summary: metanorma-ietf lets you write IETF documents, such as Internet-Drafts and
304
304
  RFCs, in AsciiDoc.