metanorma-standoc 1.0.7 → 1.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +212 -0
  3. data/lib/asciidoctor/standoc/base.rb +7 -6
  4. data/lib/asciidoctor/standoc/biblio.rng +42 -3
  5. data/lib/asciidoctor/standoc/cleanup.rb +1 -1
  6. data/lib/asciidoctor/standoc/cleanup_footnotes.rb +1 -1
  7. data/lib/asciidoctor/standoc/front.rb +10 -0
  8. data/lib/asciidoctor/standoc/inline.rb +1 -0
  9. data/lib/asciidoctor/standoc/macros.rb +3 -1
  10. data/lib/asciidoctor/standoc/ref.rb +3 -4
  11. data/lib/asciidoctor/standoc/utils.rb +13 -1
  12. data/lib/metanorma/standoc/processor.rb +2 -2
  13. data/lib/metanorma/standoc/version.rb +1 -1
  14. data/metanorma-standoc.gemspec +4 -4
  15. data/spec/asciidoctor-standoc/base_spec.rb +17 -5
  16. data/spec/asciidoctor-standoc/cleanup_spec.rb +151 -113
  17. data/spec/asciidoctor-standoc/inline_spec.rb +10 -2
  18. data/spec/asciidoctor-standoc/isobib_cache_spec.rb +167 -129
  19. data/spec/asciidoctor-standoc/macros_spec.rb +1 -1
  20. data/spec/asciidoctor-standoc/refs_spec.rb +283 -215
  21. data/spec/asciidoctor-standoc/validate_spec.rb +10 -9
  22. data/spec/examples/iso_123_.xml +1 -0
  23. data/spec/examples/iso_123_all_parts.xml +1 -0
  24. data/spec/examples/iso_123_no_year_note.xml +1 -0
  25. data/spec/examples/iso_124_.xml +1 -0
  26. data/spec/examples/iso_216_.xml +2 -1
  27. data/spec/examples/iso_iec_12382_.xml +2 -1
  28. data/spec/metanorma/processor_spec.rb +5 -5
  29. data/spec/spec_helper.rb +7 -0
  30. data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +879 -0
  31. data/spec/vcr_cassettes/isobib_get_123.yml +667 -0
  32. data/spec/vcr_cassettes/isobib_get_124.yml +1201 -0
  33. data/spec/vcr_cassettes/rfcbib_get_rfc8341.yml +129 -0
  34. data/spec/vcr_cassettes/separates_iev_citations_by_top_level_clause.yml +424 -0
  35. metadata +34 -28
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 56d1dfa7cef4ffc384854d78494c559fb24c426dd31d2429ad11de246e858b92
4
- data.tar.gz: 3069d3e34e8ae8663655073ae67666964312b169bd42a056538d748f2dc8dae0
3
+ metadata.gz: 224cd7ca429d40a2ab00d82a364e88799f10fe25ab5590a71a80302140dbbc92
4
+ data.tar.gz: 51e3067befe646bf8bf072f1b28ea98bd9ffdee0c402e4447eb285df39197cd7
5
5
  SHA512:
6
- metadata.gz: 59cb8b7330a1605369d6216014bfceff8e60345985853a9c424be9bb99105b176e4ec5f3af9131d159f4616c7d2d93a2bfb4e7692b5028dc04bcbaeb2e6db5bf
7
- data.tar.gz: b8cc513d452db412d7c86ebb9dd66c12e2c12be64ccdce84a70958ed6e1ce03f9b44226bbe378c14ef506af0dbfffed1562ca91b69a82ae646ad1d7dd84364b7
6
+ metadata.gz: 76fd5c9ba4a47de3cbaca82fbf8fa355dc8b3e00b10fe50cc6482e675e7c49288b85f849d74df33fddb433eddee4554cbeeac6c473119920620bdd956143b4e4
7
+ data.tar.gz: 62eefb42214c569b86eaec612a2769c7141686a78e4c2c7c6a62cec6dd819e75db6d856703dedd1b327c90e5ebd2878f74e21ac81af62627a40f417300af4b53
data/Gemfile.lock ADDED
@@ -0,0 +1,212 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ metanorma-standoc (1.0.8)
5
+ asciidoctor (~> 1.5.7)
6
+ iev (~> 0.2.0)
7
+ isodoc (~> 0.9.0)
8
+ relaton (~> 0.3.0)
9
+ ruby-jing
10
+ sterile
11
+
12
+ GEM
13
+ remote: https://rubygems.org/
14
+ specs:
15
+ addressable (2.5.2)
16
+ public_suffix (>= 2.0.2, < 4.0)
17
+ algoliasearch (1.23.2)
18
+ httpclient (~> 2.8, >= 2.8.3)
19
+ json (>= 1.5.1)
20
+ asciidoctor (1.5.7.1)
21
+ asciimath (1.0.6)
22
+ ast (2.4.0)
23
+ byebug (10.0.2)
24
+ cnccs (0.1.3)
25
+ coderay (1.1.2)
26
+ crack (0.4.3)
27
+ safe_yaml (~> 1.0.0)
28
+ diff-lcs (1.3)
29
+ docile (1.3.1)
30
+ equivalent-xml (0.6.0)
31
+ nokogiri (>= 1.4.3)
32
+ ffi (1.9.25)
33
+ formatador (0.2.5)
34
+ gb-agencies (0.0.3)
35
+ gbbib (0.4.1)
36
+ cnccs (~> 0.1.1)
37
+ gb-agencies (~> 0.0.1)
38
+ iso-bib-item (~> 0.4.2)
39
+ guard (2.14.2)
40
+ formatador (>= 0.2.4)
41
+ listen (>= 2.7, < 4.0)
42
+ lumberjack (>= 1.0.12, < 2.0)
43
+ nenv (~> 0.1)
44
+ notiffany (~> 0.0)
45
+ pry (>= 0.9.12)
46
+ shellany (~> 0.0)
47
+ thor (>= 0.18.1)
48
+ guard-compat (1.2.1)
49
+ guard-rspec (4.7.3)
50
+ guard (~> 2.1)
51
+ guard-compat (~> 1.1)
52
+ rspec (>= 2.99.0, < 4.0)
53
+ hashdiff (0.3.7)
54
+ html2doc (0.8.5)
55
+ asciimath
56
+ htmlentities (~> 4.3.4)
57
+ image_size
58
+ mime-types
59
+ nokogiri
60
+ ruby-xslt
61
+ thread_safe
62
+ uuidtools
63
+ htmlentities (4.3.4)
64
+ httpclient (2.8.3)
65
+ iecbib (0.2.1)
66
+ addressable
67
+ iso-bib-item (~> 0.4.2)
68
+ ietfbib (0.4.3)
69
+ iso-bib-item (~> 0.4.2)
70
+ iev (0.2.0)
71
+ nokogiri
72
+ image_size (2.0.0)
73
+ iso-bib-item (0.4.2)
74
+ isoics (~> 0.1.6)
75
+ nokogiri (~> 1.8.4)
76
+ ruby_deep_clone (~> 0.8.0)
77
+ isobib (0.4.1)
78
+ algoliasearch
79
+ iecbib (~> 0.2.1)
80
+ iso-bib-item (~> 0.4.2)
81
+ isodoc (0.9.5)
82
+ asciimath
83
+ html2doc (~> 0.8.1)
84
+ htmlentities (~> 4.3.4)
85
+ liquid
86
+ metanorma (~> 0.2.7)
87
+ nokogiri
88
+ rake (~> 12.0)
89
+ roman-numerals
90
+ ruby-xslt
91
+ sassc (~> 1.12.1)
92
+ thread_safe
93
+ uuidtools
94
+ isoics (0.1.7)
95
+ jaro_winkler (1.5.1)
96
+ json (2.1.0)
97
+ liquid (4.0.1)
98
+ listen (3.1.5)
99
+ rb-fsevent (~> 0.9, >= 0.9.4)
100
+ rb-inotify (~> 0.9, >= 0.9.7)
101
+ ruby_dep (~> 1.2)
102
+ lumberjack (1.0.13)
103
+ metanorma (0.2.11)
104
+ method_source (0.9.0)
105
+ mime-types (3.2.2)
106
+ mime-types-data (~> 3.2015)
107
+ mime-types-data (3.2018.0812)
108
+ mini_portile2 (2.3.0)
109
+ nenv (0.3.0)
110
+ nokogiri (1.8.5)
111
+ mini_portile2 (~> 2.3.0)
112
+ notiffany (0.1.1)
113
+ nenv (~> 0.1)
114
+ shellany (~> 0.0)
115
+ optout (0.0.2)
116
+ parallel (1.12.1)
117
+ parser (2.5.1.2)
118
+ ast (~> 2.4.0)
119
+ powerpack (0.1.2)
120
+ pry (0.11.3)
121
+ coderay (~> 1.1.0)
122
+ method_source (~> 0.9.0)
123
+ public_suffix (3.0.3)
124
+ rainbow (3.0.0)
125
+ rake (12.3.1)
126
+ rb-fsevent (0.10.3)
127
+ rb-inotify (0.9.10)
128
+ ffi (>= 0.5.0, < 2)
129
+ relaton (0.3.0)
130
+ algoliasearch
131
+ gbbib (~> 0.4.0)
132
+ iecbib (~> 0.2.0)
133
+ ietfbib (~> 0.4.2)
134
+ iso-bib-item (~> 0.4.2)
135
+ isobib (~> 0.4.0)
136
+ roman-numerals (0.3.0)
137
+ rspec (3.8.0)
138
+ rspec-core (~> 3.8.0)
139
+ rspec-expectations (~> 3.8.0)
140
+ rspec-mocks (~> 3.8.0)
141
+ rspec-core (3.8.0)
142
+ rspec-support (~> 3.8.0)
143
+ rspec-expectations (3.8.2)
144
+ diff-lcs (>= 1.2.0, < 2.0)
145
+ rspec-support (~> 3.8.0)
146
+ rspec-mocks (3.8.0)
147
+ diff-lcs (>= 1.2.0, < 2.0)
148
+ rspec-support (~> 3.8.0)
149
+ rspec-support (3.8.0)
150
+ rubocop (0.60.0)
151
+ jaro_winkler (~> 1.5.1)
152
+ parallel (~> 1.10)
153
+ parser (>= 2.5, != 2.5.1.1)
154
+ powerpack (~> 0.1)
155
+ rainbow (>= 2.2.2, < 4.0)
156
+ ruby-progressbar (~> 1.7)
157
+ unicode-display_width (~> 1.4.0)
158
+ ruby-jing (0.0.1)
159
+ optout (>= 0.0.2)
160
+ ruby-progressbar (1.10.0)
161
+ ruby-xslt (0.9.10)
162
+ ruby_deep_clone (0.8.0)
163
+ ruby_dep (1.5.0)
164
+ safe_yaml (1.0.4)
165
+ sass (3.6.0)
166
+ sass-listen (~> 4.0.0)
167
+ sass-listen (4.0.0)
168
+ rb-fsevent (~> 0.9, >= 0.9.4)
169
+ rb-inotify (~> 0.9, >= 0.9.7)
170
+ sassc (1.12.1)
171
+ ffi (~> 1.9.6)
172
+ sass (>= 3.3.0)
173
+ shellany (0.0.1)
174
+ simplecov (0.16.1)
175
+ docile (~> 1.1)
176
+ json (>= 1.8, < 3)
177
+ simplecov-html (~> 0.10.0)
178
+ simplecov-html (0.10.2)
179
+ sterile (1.0.13)
180
+ nokogiri
181
+ thor (0.20.0)
182
+ thread_safe (0.3.6)
183
+ timecop (0.9.1)
184
+ unicode-display_width (1.4.0)
185
+ uuidtools (2.1.5)
186
+ vcr (4.0.0)
187
+ webmock (3.4.2)
188
+ addressable (>= 2.3.6)
189
+ crack (>= 0.3.2)
190
+ hashdiff
191
+
192
+ PLATFORMS
193
+ ruby
194
+
195
+ DEPENDENCIES
196
+ bundler (~> 1.15)
197
+ byebug
198
+ equivalent-xml (~> 0.6)
199
+ guard (~> 2.14)
200
+ guard-rspec (~> 4.7)
201
+ metanorma (~> 0.2.6)
202
+ metanorma-standoc!
203
+ rake (~> 12.0)
204
+ rspec (~> 3.6)
205
+ rubocop (~> 0.50)
206
+ simplecov (~> 0.15)
207
+ timecop (~> 0.9)
208
+ vcr
209
+ webmock
210
+
211
+ BUNDLED WITH
212
+ 1.16.6
@@ -8,6 +8,7 @@ require "pp"
8
8
  require "sass"
9
9
  require "isodoc"
10
10
  require "relaton"
11
+ require "fileutils"
11
12
 
12
13
  module Asciidoctor
13
14
  module Standoc
@@ -74,7 +75,7 @@ module Asciidoctor
74
75
  end
75
76
 
76
77
  def init(node)
77
- @fn_number = 0
78
+ @fn_number ||= 0
78
79
  @draft = false
79
80
  @refids = Set.new
80
81
  @anchors = {}
@@ -98,8 +99,8 @@ module Asciidoctor
98
99
  localname = bibliocache_name(false) if node.attr("local-cache") ||
99
100
  node.attr("local-cache-only")
100
101
  if node.attr("flush-caches")
101
- system("rm -f #{globalname}") unless globalname.nil?
102
- system("rm -f #{localname}") unless localname.nil?
102
+ FileUtils.rm_f globalname unless globalname.nil?
103
+ FileUtils.rm_f localname unless localname.nil?
103
104
  end
104
105
  end
105
106
  @bibdb = Relaton::Db.new(globalname, localname) unless @no_isobib
@@ -111,8 +112,8 @@ module Asciidoctor
111
112
  localname = ievcache_name(false) if node.attr("local-cache") ||
112
113
  node.attr("local-cache-only")
113
114
  if node.attr("flush-caches")
114
- system("rm -f #{globalname}") unless globalname.nil?
115
- system("rm -f #{localname}") unless localname.nil?
115
+ FileUtils.rm_f globalname unless globalname.nil?
116
+ FileUtils.rm_f localname unless localname.nil?
116
117
  end
117
118
  end
118
119
  @iev = Iev::Db.new(globalname, localname) unless @no_isobib
@@ -137,7 +138,7 @@ module Asciidoctor
137
138
  html_converter(node).convert(@filename + ".xml")
138
139
  doc_converter(node).convert(@filename + ".xml")
139
140
  end
140
- @files_to_delete.each { |f| system "rm #{f}" }
141
+ @files_to_delete.each { |f| FileUtils.rm f }
141
142
  ret
142
143
  end
143
144
 
@@ -259,6 +259,9 @@
259
259
  </define>
260
260
  <define name="uri">
261
261
  <element name="uri">
262
+ <optional>
263
+ <attribute name="type"/>
264
+ </optional>
262
265
  <data type="anyURI"/>
263
266
  </element>
264
267
  </define>
@@ -411,6 +414,20 @@
411
414
  <ref name="BibliographicItem"/>
412
415
  </element>
413
416
  </define>
417
+ <define name="relaton_collection">
418
+ <element name="relaton-collection">
419
+ <optional>
420
+ <attribute name="type"/>
421
+ </optional>
422
+ <ref name="btitle"/>
423
+ <zeroOrMore>
424
+ <ref name="contributor"/>
425
+ </zeroOrMore>
426
+ <zeroOrMore>
427
+ <ref name="docrelation"/>
428
+ </zeroOrMore>
429
+ </element>
430
+ </define>
414
431
  <define name="BibItemType" combine="choice">
415
432
  <choice>
416
433
  <value>article</value>
@@ -444,6 +461,9 @@
444
461
  <ref name="BibItemType"/>
445
462
  </attribute>
446
463
  </optional>
464
+ <optional>
465
+ <ref name="fetched"/>
466
+ </optional>
447
467
  <choice>
448
468
  <oneOrMore>
449
469
  <ref name="btitle"/>
@@ -523,6 +543,14 @@
523
543
  <ref name="FormattedString"/>
524
544
  </element>
525
545
  </define>
546
+ <define name="fetched">
547
+ <element name="fetched">
548
+ <choice>
549
+ <data type="dateTime"/>
550
+ <data type="date"/>
551
+ </choice>
552
+ </element>
553
+ </define>
526
554
  <define name="validity">
527
555
  <element name="validity">
528
556
  <optional>
@@ -538,17 +566,26 @@
538
566
  </define>
539
567
  <define name="validityBegins">
540
568
  <element name="validityBegins">
541
- <data type="dateTime"/>
569
+ <choice>
570
+ <data type="dateTime"/>
571
+ <data type="date"/>
572
+ </choice>
542
573
  </element>
543
574
  </define>
544
575
  <define name="validityEnds">
545
576
  <element name="validityEnds">
546
- <data type="dateTime"/>
577
+ <choice>
578
+ <data type="dateTime"/>
579
+ <data type="date"/>
580
+ </choice>
547
581
  </element>
548
582
  </define>
549
583
  <define name="validityRevision">
550
584
  <element name="revision">
551
- <data type="dateTime"/>
585
+ <choice>
586
+ <data type="dateTime"/>
587
+ <data type="date"/>
588
+ </choice>
552
589
  </element>
553
590
  </define>
554
591
  <define name="TypedTitleString">
@@ -733,6 +770,7 @@
733
770
  <element name="from">
734
771
  <choice>
735
772
  <data type="dateTime"/>
773
+ <data type="date"/>
736
774
  <data type="gYear"/>
737
775
  </choice>
738
776
  </element>
@@ -741,6 +779,7 @@
741
779
  <element name="to">
742
780
  <choice>
743
781
  <data type="dateTime"/>
782
+ <data type="date"/>
744
783
  <data type="gYear"/>
745
784
  </choice>
746
785
  </element>
@@ -34,7 +34,7 @@ module Asciidoctor
34
34
  para_cleanup(xmldoc)
35
35
  callout_cleanup(xmldoc)
36
36
  element_name_cleanup(xmldoc)
37
- footnote_renumber(xmldoc)
37
+ footnote_cleanup(xmldoc)
38
38
  empty_element_cleanup(xmldoc)
39
39
  mathml_cleanup(xmldoc)
40
40
  script_cleanup(xmldoc)
@@ -66,7 +66,7 @@ module Asciidoctor
66
66
  end
67
67
  end
68
68
 
69
- def footnote_renumber(xmldoc)
69
+ def footnote_cleanup(xmldoc)
70
70
  table_footnote_renumber(xmldoc)
71
71
  other_footnote_renumber(xmldoc)
72
72
  xmldoc.xpath("//fn").each do |fn|
@@ -95,8 +95,18 @@ module Asciidoctor
95
95
  end
96
96
  end
97
97
 
98
+ def metadata_source(node, xml)
99
+ node.attr("uri") && xml.source(node.attr("uri"))
100
+ node.attr("xml-uri") && xml.source(node.attr("xml-uri"), type: "xml")
101
+ node.attr("html-uri") && xml.source(node.attr("html-uri"), type: "html")
102
+ node.attr("pdf-uri") && xml.source(node.attr("pdf-uri"), type: "pdf")
103
+ node.attr("doc-uri") && xml.source(node.attr("doc-uri"), type: "doc")
104
+ node.attr("relaton-uri") && xml.source(node.attr("relaton-uri"), type: "relaton")
105
+ end
106
+
98
107
  def metadata(node, xml)
99
108
  title node, xml
109
+ metadata_source(node, xml)
100
110
  metadata_id(node, xml)
101
111
  metadata_author(node, xml)
102
112
  metadata_publisher(node, xml)
@@ -68,6 +68,7 @@ module Asciidoctor
68
68
  end
69
69
 
70
70
  def inline_footnote(node)
71
+ @fn_number ||= 0
71
72
  noko do |xml|
72
73
  @fn_number += 1
73
74
  xml.fn **{ reference: @fn_number } do |fn|
@@ -1,4 +1,6 @@
1
1
  require "asciidoctor/extensions"
2
+ require "fileutils"
3
+
2
4
  module Asciidoctor
3
5
  module Standoc
4
6
  class AltTermInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
@@ -58,7 +60,7 @@ module Asciidoctor
58
60
  src = "@startuml\n#{src}\n@enduml\n"
59
61
  /^@startuml (?<filename>[^\n]+)\n/ =~ src
60
62
  filename ||= parent.document.reader.lineno
61
- system "mkdir -p plantuml"
63
+ FileUtils.mkdir_p "plantuml"
62
64
  File.open("plantuml/#{filename}.pml", "w") { |f| f.write src }
63
65
  system "plantuml plantuml/#{filename}.pml"
64
66
  filename
@@ -1,5 +1,3 @@
1
- require "pp"
2
-
3
1
  module Asciidoctor
4
2
  module Standoc
5
3
  module Lists
@@ -88,7 +86,8 @@ module Asciidoctor
88
86
  def isorefmatches3(xml, m)
89
87
  hasyr = m.names.include?("year") && m[:year] != "--"
90
88
  noyr = m.names.include?("year") && m[:year] == "--"
91
- ref = fetch_ref xml, m[:code], hasyr ? m[:year] : nil, all_parts: true, no_year: noyr
89
+ ref = fetch_ref xml, m[:code], hasyr ? m[:year] : nil,
90
+ all_parts: true, no_year: noyr
92
91
  return use_my_anchor(ref, m[:anchor]) if ref
93
92
  xml.bibitem(**attr_code(ref_attributes(m))) do |t|
94
93
  t.title(**plaintxt) { |i| i << ref_normalise(m[:text]) }
@@ -104,7 +103,7 @@ module Asciidoctor
104
103
  return nil if opts[:no_year]
105
104
  hit = @bibdb&.fetch(code, year, opts)
106
105
  return nil if hit.nil?
107
- xml.parent.add_child(hit.to_xml)
106
+ xml.parent.add_child(Utils::smart_render_xml(hit))
108
107
  xml
109
108
  rescue Algolia::AlgoliaProtocolError
110
109
  nil # Render reference without an Internet connection.