metanorma-standoc 1.9.0 → 1.9.1
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.
- checksums.yaml +4 -4
- data/lib/asciidoctor/standoc/base.rb +28 -35
- data/lib/asciidoctor/standoc/blocks.rb +7 -6
- data/lib/asciidoctor/standoc/blocks_notes.rb +20 -14
- data/lib/asciidoctor/standoc/cleanup.rb +32 -78
- data/lib/asciidoctor/standoc/cleanup_block.rb +44 -84
- data/lib/asciidoctor/standoc/cleanup_boilerplate.rb +9 -7
- data/lib/asciidoctor/standoc/cleanup_footnotes.rb +1 -0
- data/lib/asciidoctor/standoc/cleanup_image.rb +71 -0
- data/lib/asciidoctor/standoc/cleanup_maths.rb +36 -27
- data/lib/asciidoctor/standoc/cleanup_ref.rb +21 -13
- data/lib/asciidoctor/standoc/cleanup_ref_dl.rb +1 -1
- data/lib/asciidoctor/standoc/cleanup_reqt.rb +47 -0
- data/lib/asciidoctor/standoc/cleanup_section.rb +5 -0
- data/lib/asciidoctor/standoc/front.rb +35 -18
- data/lib/asciidoctor/standoc/front_contributor.rb +5 -5
- data/lib/asciidoctor/standoc/lists.rb +4 -2
- data/lib/asciidoctor/standoc/ref.rb +87 -112
- data/lib/asciidoctor/standoc/ref_date_id.rb +62 -0
- data/lib/asciidoctor/standoc/utils.rb +32 -6
- data/lib/asciidoctor/standoc/validate.rb +12 -12
- data/lib/metanorma/standoc/version.rb +1 -1
- data/metanorma-standoc.gemspec +1 -1
- data/spec/asciidoctor/base_spec.rb +60 -7
- data/spec/asciidoctor/cleanup_spec.rb +2 -6
- data/spec/asciidoctor/refs_spec.rb +1 -1
- data/spec/spec_helper.rb +11 -9
- metadata +9 -6
@@ -1,5 +1,5 @@
|
|
1
1
|
require "asciidoctor/standoc/utils"
|
2
|
-
require_relative "./validate_section
|
2
|
+
require_relative "./validate_section"
|
3
3
|
require "nokogiri"
|
4
4
|
require "jing"
|
5
5
|
require "iev"
|
@@ -14,6 +14,7 @@ module Asciidoctor
|
|
14
14
|
def init_iev
|
15
15
|
return nil if @no_isobib
|
16
16
|
return @iev if @iev
|
17
|
+
|
17
18
|
@iev = Iev::Db.new(@iev_globalname, @iev_localname) unless @no_isobib
|
18
19
|
@iev
|
19
20
|
end
|
@@ -44,14 +45,14 @@ module Asciidoctor
|
|
44
45
|
found = false
|
45
46
|
doc.xpath("//references[@normative = 'true']/bibitem").each do |b|
|
46
47
|
next unless docid = b.at("./docidentifier[@type = 'metanorma']")
|
47
|
-
next unless
|
48
|
-
|
48
|
+
next unless /^\[\d+\]$/.match?(docid.text)
|
49
|
+
|
50
|
+
@log.add("Bibliography", b,
|
51
|
+
"Numeric reference in normative references")
|
49
52
|
found = true
|
50
53
|
end
|
51
|
-
|
52
|
-
|
53
|
-
abort("Numeric reference in normative references")
|
54
|
-
end
|
54
|
+
found and
|
55
|
+
clean_abort("Numeric reference in normative references", doc.to_xml)
|
55
56
|
end
|
56
57
|
|
57
58
|
def repeat_id_validate1(ids, x)
|
@@ -72,8 +73,7 @@ module Asciidoctor
|
|
72
73
|
ids = repeat_id_validate1(ids, x)
|
73
74
|
end
|
74
75
|
rescue StandardError => e
|
75
|
-
|
76
|
-
abort(e.message)
|
76
|
+
clean_abort(e.message, doc.to_xml)
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
@@ -90,8 +90,7 @@ module Asciidoctor
|
|
90
90
|
e[:message])
|
91
91
|
end
|
92
92
|
rescue Jing::Error => e
|
93
|
-
|
94
|
-
abort "Jing failed with error: #{e}"
|
93
|
+
clean_abort("Jing failed with error: #{e}", doc.to_xml)
|
95
94
|
ensure
|
96
95
|
f.close!
|
97
96
|
end
|
@@ -104,7 +103,8 @@ module Asciidoctor
|
|
104
103
|
def formattedstr_strip(doc)
|
105
104
|
doc.xpath("//*[@format] | //stem | //bibdata//description | "\
|
106
105
|
"//formattedref | //bibdata//note | //bibdata/abstract | "\
|
107
|
-
"//bibitem/abstract | //bibitem/note | //misc-container")
|
106
|
+
"//bibitem/abstract | //bibitem/note | //misc-container")
|
107
|
+
.each do |n|
|
108
108
|
n.elements.each do |e|
|
109
109
|
e.traverse do |e1|
|
110
110
|
e1.element? and e1.each { |k, _v| e1.delete(k) }
|
data/metanorma-standoc.gemspec
CHANGED
@@ -30,7 +30,7 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.add_dependency "iev", "~> 0.2.1"
|
31
31
|
spec.add_dependency "isodoc", "~> 1.6.0"
|
32
32
|
spec.add_dependency "metanorma-plugin-datastruct"
|
33
|
-
spec.add_dependency "metanorma-plugin-lutaml"
|
33
|
+
spec.add_dependency "metanorma-plugin-lutaml"
|
34
34
|
spec.add_dependency "ruby-jing"
|
35
35
|
# relaton-cli not just relaton, to avoid circular reference in metanorma
|
36
36
|
spec.add_dependency "asciimath2unitsml", "~> 0.3.0"
|
@@ -240,6 +240,7 @@ OUTPUT
|
|
240
240
|
:pub-uri: http://www.example.com
|
241
241
|
:isbn: ISBN-13
|
242
242
|
:isbn10: ISBN-10
|
243
|
+
:classification: a:b, c
|
243
244
|
INPUT
|
244
245
|
<?xml version="1.0" encoding="UTF-8"?>
|
245
246
|
<standard-document xmlns="https://www.metanorma.org/ns/standoc" type="semantic" version="#{Metanorma::Standoc::VERSION}">
|
@@ -361,18 +362,51 @@ OUTPUT
|
|
361
362
|
<role type="publisher"/>
|
362
363
|
<organization>
|
363
364
|
<name>Hanna Barbera</name>
|
365
|
+
<address>
|
366
|
+
<formattedAddress>
|
367
|
+
1 Infinity Loop
|
368
|
+
<br/>
|
369
|
+
California
|
370
|
+
</formattedAddress>
|
371
|
+
</address>
|
372
|
+
<phone>3333333</phone>
|
373
|
+
<phone type='fax'>4444444</phone>
|
374
|
+
<email>x@example.com</email>
|
375
|
+
<uri>http://www.example.com</uri>
|
364
376
|
</organization>
|
365
377
|
</contributor>
|
366
378
|
<contributor>
|
367
379
|
<role type="publisher"/>
|
368
380
|
<organization>
|
369
381
|
<name>Cartoon Network</name>
|
382
|
+
<address>
|
383
|
+
<formattedAddress>
|
384
|
+
1 Infinity Loop
|
385
|
+
<br/>
|
386
|
+
California
|
387
|
+
</formattedAddress>
|
388
|
+
</address>
|
389
|
+
<phone>3333333</phone>
|
390
|
+
<phone type='fax'>4444444</phone>
|
391
|
+
<email>x@example.com</email>
|
392
|
+
<uri>http://www.example.com</uri>
|
370
393
|
</organization>
|
371
394
|
</contributor>
|
372
395
|
<contributor>
|
373
396
|
<role type="publisher"/>
|
374
397
|
<organization>
|
375
398
|
<name>Ribose, Inc.</name>
|
399
|
+
<address>
|
400
|
+
<formattedAddress>
|
401
|
+
1 Infinity Loop
|
402
|
+
<br/>
|
403
|
+
California
|
404
|
+
</formattedAddress>
|
405
|
+
</address>
|
406
|
+
<phone>3333333</phone>
|
407
|
+
<phone type='fax'>4444444</phone>
|
408
|
+
<email>x@example.com</email>
|
409
|
+
<uri>http://www.example.com</uri>
|
376
410
|
</organization>
|
377
411
|
</contributor>
|
378
412
|
<edition>2</edition>
|
@@ -392,6 +426,17 @@ OUTPUT
|
|
392
426
|
<owner>
|
393
427
|
<organization>
|
394
428
|
<name>Ribose, Inc.</name>
|
429
|
+
<address>
|
430
|
+
<formattedAddress>
|
431
|
+
1 Infinity Loop
|
432
|
+
<br/>
|
433
|
+
California
|
434
|
+
</formattedAddress>
|
435
|
+
</address>
|
436
|
+
<phone>3333333</phone>
|
437
|
+
<phone type='fax'>4444444</phone>
|
438
|
+
<email>x@example.com</email>
|
439
|
+
<uri>http://www.example.com</uri>
|
395
440
|
</organization>
|
396
441
|
</owner>
|
397
442
|
</copyright>
|
@@ -400,6 +445,17 @@ OUTPUT
|
|
400
445
|
<owner>
|
401
446
|
<organization>
|
402
447
|
<name>Hanna Barbera</name>
|
448
|
+
<address>
|
449
|
+
<formattedAddress>
|
450
|
+
1 Infinity Loop
|
451
|
+
<br/>
|
452
|
+
California
|
453
|
+
</formattedAddress>
|
454
|
+
</address>
|
455
|
+
<phone>3333333</phone>
|
456
|
+
<phone type='fax'>4444444</phone>
|
457
|
+
<email>x@example.com</email>
|
458
|
+
<uri>http://www.example.com</uri>
|
403
459
|
</organization>
|
404
460
|
</owner>
|
405
461
|
</copyright>
|
@@ -421,6 +477,8 @@ OUTPUT
|
|
421
477
|
<docidentifier>JKL MNO</docidentifier>
|
422
478
|
</bibitem>
|
423
479
|
</relation>
|
480
|
+
<classification type='a'>b</classification>
|
481
|
+
<classification type='default'>c</classification>
|
424
482
|
<keyword>a</keyword>
|
425
483
|
<keyword>b</keyword>
|
426
484
|
<keyword>c</keyword>
|
@@ -469,6 +527,7 @@ OUTPUT
|
|
469
527
|
:relaton-uri: F
|
470
528
|
:title-eo: Dokumenttitolo
|
471
529
|
:doctype: This is a DocType
|
530
|
+
:docsubtype: This is a DocSubType
|
472
531
|
:subdivision: Subdivision
|
473
532
|
:subdivision-abbr: SD
|
474
533
|
|
@@ -567,6 +626,7 @@ OUTPUT
|
|
567
626
|
</copyright>
|
568
627
|
<ext>
|
569
628
|
<doctype>this-is-a-doctype</doctype>
|
629
|
+
<subdoctype>This is a DocSubType</subdoctype>
|
570
630
|
</ext>
|
571
631
|
</bibdata>
|
572
632
|
<preface>
|
@@ -625,13 +685,6 @@ OUTPUT
|
|
625
685
|
<name>International Standards Organization</name>
|
626
686
|
<subdivision>Subdivision</subdivision>
|
627
687
|
<abbreviation>SD</abbreviation>
|
628
|
-
<address>
|
629
|
-
<formattedAddress>1 Infinity Loop <br/>California</formattedAddress>
|
630
|
-
</address>
|
631
|
-
<phone>3333333</phone>
|
632
|
-
<phone type='fax'>4444444</phone>
|
633
|
-
<email>x@example.com</email>
|
634
|
-
<uri>http://www.example.com</uri>
|
635
688
|
</organization>
|
636
689
|
</contributor>
|
637
690
|
<contributor>
|
@@ -44,9 +44,7 @@ RSpec.describe Asciidoctor::Standoc do
|
|
44
44
|
</svgmap>
|
45
45
|
<figure id='ref1'>
|
46
46
|
<name>SVG title</name>
|
47
|
-
|
48
|
-
<!-- Generator: Adobe Illustrator 25.0.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
49
|
-
<svg xmlns='http://www.w3.org/2000/svg' version='1.1' id='Layer_1' x='0px' y='0px' viewbox='0 0 595.28 841.89' style='enable-background:new 0 0 595.28 841.89;' xml:space='preserve' xmlns:xlink='http://www.w3.org/1999/xlink'>
|
47
|
+
<svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' id='Layer_1_000000001' x='0px' y='0px' viewBox='0 0 595.28 841.89' style='enable-background:new 0 0 595.28 841.89;' xml:space='preserve'>
|
50
48
|
<style/>
|
51
49
|
<image/>
|
52
50
|
<a xlink:href='#ref1'>
|
@@ -62,9 +60,7 @@ RSpec.describe Asciidoctor::Standoc do
|
|
62
60
|
</figure>
|
63
61
|
<svgmap>
|
64
62
|
<figure id='ref2' unnumbered='true' number='8' subsequence='A' keep-with-next='true' keep-lines-together='true'>
|
65
|
-
|
66
|
-
<!-- Generator: Adobe Illustrator 25.0.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
67
|
-
<svg xmlns='http://www.w3.org/2000/svg' version='1.1' id='Layer_1' x='0px' y='0px' viewbox='0 0 595.28 841.89' style='enable-background:new 0 0 595.28 841.89;' xml:space='preserve' xmlns:xlink='http://www.w3.org/1999/xlink'>
|
63
|
+
<svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' id='Layer_1_000000002' x='0px' y='0px' viewBox='0 0 595.28 841.89' style='enable-background:new 0 0 595.28 841.89;' xml:space='preserve'>
|
68
64
|
<style/>
|
69
65
|
<image/>
|
70
66
|
<a xlink:href='#ref1'>
|
@@ -3,7 +3,7 @@ require "relaton_iso"
|
|
3
3
|
require "relaton_ietf"
|
4
4
|
|
5
5
|
RSpec.describe Asciidoctor::Standoc do
|
6
|
-
|
6
|
+
it "processes simple ISO reference" do
|
7
7
|
expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp( <<~"OUTPUT")
|
8
8
|
#{ASCIIDOC_BLANK_HDR}
|
9
9
|
[bibliography]
|
data/spec/spec_helper.rb
CHANGED
@@ -25,7 +25,8 @@ require "metanorma/standoc"
|
|
25
25
|
require "rexml/document"
|
26
26
|
require "byebug"
|
27
27
|
|
28
|
-
Dir[File.expand_path("./support/**/**/*.rb", __dir__)]
|
28
|
+
Dir[File.expand_path("./support/**/**/*.rb", __dir__)]
|
29
|
+
.sort.each { |f| require f }
|
29
30
|
|
30
31
|
RSpec.configure do |config|
|
31
32
|
# Enable flags like --only-failures and --next-failure
|
@@ -47,19 +48,20 @@ RSpec.configure do |config|
|
|
47
48
|
end
|
48
49
|
end
|
49
50
|
|
50
|
-
def strip_guid(
|
51
|
-
|
51
|
+
def strip_guid(xml)
|
52
|
+
xml.gsub(%r{ id="_[^"]+"}, ' id="_"')
|
53
|
+
.gsub(%r{ target="_[^"]+"}, ' target="_"')
|
52
54
|
end
|
53
55
|
|
54
56
|
def strip_src(xml)
|
55
57
|
xml.gsub(/\ssrc="[^"]+"/, ' src="_"')
|
56
58
|
end
|
57
59
|
|
58
|
-
def xmlpp(
|
60
|
+
def xmlpp(xml)
|
59
61
|
s = ""
|
60
62
|
f = REXML::Formatters::Pretty.new(2)
|
61
63
|
f.compact = true
|
62
|
-
f.write(REXML::Document.new(
|
64
|
+
f.write(REXML::Document.new(xml), s)
|
63
65
|
s
|
64
66
|
end
|
65
67
|
|
@@ -181,7 +183,7 @@ BLANK_METANORMA_HDR = <<~"HDR".freeze
|
|
181
183
|
</bibdata>
|
182
184
|
HDR
|
183
185
|
|
184
|
-
HTML_HDR = <<~
|
186
|
+
HTML_HDR = <<~HDR.freeze
|
185
187
|
<html xmlns:epub="http://www.idpf.org/2007/ops">
|
186
188
|
<head>
|
187
189
|
<title>test</title>
|
@@ -196,9 +198,9 @@ HTML_HDR = <<~END.freeze
|
|
196
198
|
</div>
|
197
199
|
<br/>
|
198
200
|
<div class="main-section">
|
199
|
-
|
201
|
+
HDR
|
200
202
|
|
201
|
-
WORD_HDR = <<~
|
203
|
+
WORD_HDR = <<~HDR.freeze
|
202
204
|
<html xmlns:epub="http://www.idpf.org/2007/ops">
|
203
205
|
<head>
|
204
206
|
<title>test</title>
|
@@ -213,7 +215,7 @@ WORD_HDR = <<~END.freeze
|
|
213
215
|
</div>
|
214
216
|
<br clear="all" class="section"/>
|
215
217
|
<div class="WordSection3">
|
216
|
-
|
218
|
+
HDR
|
217
219
|
|
218
220
|
def examples_path(path)
|
219
221
|
File.join(File.expand_path("./examples", __dir__), path)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metanorma-standoc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.9.
|
4
|
+
version: 1.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-04-
|
11
|
+
date: 2021-04-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciidoctor
|
@@ -70,16 +70,16 @@ dependencies:
|
|
70
70
|
name: metanorma-plugin-lutaml
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0
|
75
|
+
version: '0'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - "
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 0
|
82
|
+
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: ruby-jing
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -410,10 +410,12 @@ files:
|
|
410
410
|
- lib/asciidoctor/standoc/cleanup_block.rb
|
411
411
|
- lib/asciidoctor/standoc/cleanup_boilerplate.rb
|
412
412
|
- lib/asciidoctor/standoc/cleanup_footnotes.rb
|
413
|
+
- lib/asciidoctor/standoc/cleanup_image.rb
|
413
414
|
- lib/asciidoctor/standoc/cleanup_inline.rb
|
414
415
|
- lib/asciidoctor/standoc/cleanup_maths.rb
|
415
416
|
- lib/asciidoctor/standoc/cleanup_ref.rb
|
416
417
|
- lib/asciidoctor/standoc/cleanup_ref_dl.rb
|
418
|
+
- lib/asciidoctor/standoc/cleanup_reqt.rb
|
417
419
|
- lib/asciidoctor/standoc/cleanup_section.rb
|
418
420
|
- lib/asciidoctor/standoc/cleanup_terms.rb
|
419
421
|
- lib/asciidoctor/standoc/converter.rb
|
@@ -429,6 +431,7 @@ files:
|
|
429
431
|
- lib/asciidoctor/standoc/macros_plantuml.rb
|
430
432
|
- lib/asciidoctor/standoc/macros_terms.rb
|
431
433
|
- lib/asciidoctor/standoc/ref.rb
|
434
|
+
- lib/asciidoctor/standoc/ref_date_id.rb
|
432
435
|
- lib/asciidoctor/standoc/ref_sect.rb
|
433
436
|
- lib/asciidoctor/standoc/reqt.rb
|
434
437
|
- lib/asciidoctor/standoc/reqt.rng
|