metanorma-standoc 1.3.1 → 1.3.2
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/Gemfile +5 -1
- data/Gemfile.lock +25 -23
- data/lib/asciidoctor/standoc/cleanup_boilerplate.rb +1 -1
- data/lib/asciidoctor/standoc/cleanup_ref.rb +3 -3
- data/lib/asciidoctor/standoc/front.rb +2 -12
- data/lib/asciidoctor/standoc/ref.rb +2 -1
- data/lib/asciidoctor/standoc/utils.rb +8 -0
- data/lib/metanorma/standoc/version.rb +1 -1
- data/spec/asciidoctor-standoc/base_spec.rb +7 -0
- data/spec/asciidoctor-standoc/refs_spec.rb +22 -4
- data/spec/asciidoctor-standoc/section_spec.rb +4 -4
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7b1329080ec2d0fd0e0a0f14ef3e59ebacf0d3a7eddb0d44510ef16966073705
|
|
4
|
+
data.tar.gz: 46051f44a1e660df4357ab06e6018d861698d12679f6002cb46f17d9b0b62684
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f044364c1ac18e56ee6c186c919d0cd332c5253a6e4cc1bb6bc09bbbf5233c74c6f42d10314c4598305d21e5450c5b29ef57d62b6662394c2137d39c965c7d35
|
|
7
|
+
data.tar.gz: f6806351c9621bfb2bfac2ae868593ce9088c4361d99285495368e3faa6550dbcaa0fa4d88fd3f19238536bd32837182470321f3b9734a33f0807d95ca2719e9
|
data/Gemfile
CHANGED
|
@@ -2,6 +2,10 @@ Encoding.default_external = Encoding::UTF_8
|
|
|
2
2
|
Encoding.default_internal = Encoding::UTF_8
|
|
3
3
|
|
|
4
4
|
source "https://rubygems.org"
|
|
5
|
+
git_source(:github) { |repo| "https://github.com/#{repo}" }
|
|
5
6
|
|
|
6
|
-
# Specify your gem's dependencies in gemspec
|
|
7
7
|
gemspec
|
|
8
|
+
|
|
9
|
+
if File.exist? 'Gemfile.devel'
|
|
10
|
+
eval File.read('Gemfile.devel'), nil, 'Gemfile.devel' # rubocop:disable Security/Eval
|
|
11
|
+
end
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
metanorma-standoc (1.3.
|
|
4
|
+
metanorma-standoc (1.3.2)
|
|
5
5
|
asciidoctor (~> 1.5.7)
|
|
6
6
|
concurrent-ruby
|
|
7
7
|
html2doc (~> 0.8.11)
|
|
@@ -18,9 +18,6 @@ GEM
|
|
|
18
18
|
specs:
|
|
19
19
|
addressable (2.7.0)
|
|
20
20
|
public_suffix (>= 2.0.2, < 5.0)
|
|
21
|
-
algoliasearch (1.26.1)
|
|
22
|
-
httpclient (~> 2.8, >= 2.8.3)
|
|
23
|
-
json (>= 1.5.1)
|
|
24
21
|
asciidoctor (1.5.8)
|
|
25
22
|
asciimath (1.0.8)
|
|
26
23
|
ast (2.4.0)
|
|
@@ -34,10 +31,12 @@ GEM
|
|
|
34
31
|
docile (1.3.2)
|
|
35
32
|
equivalent-xml (0.6.0)
|
|
36
33
|
nokogiri (>= 1.4.3)
|
|
34
|
+
faraday (0.15.4)
|
|
35
|
+
multipart-post (>= 1.2, < 3)
|
|
37
36
|
ffi (1.11.1)
|
|
38
37
|
formatador (0.2.5)
|
|
39
38
|
gb-agencies (0.0.5)
|
|
40
|
-
guard (2.15.
|
|
39
|
+
guard (2.15.1)
|
|
41
40
|
formatador (>= 0.2.4)
|
|
42
41
|
listen (>= 2.7, < 4.0)
|
|
43
42
|
lumberjack (>= 1.0.12, < 2.0)
|
|
@@ -61,11 +60,10 @@ GEM
|
|
|
61
60
|
thread_safe
|
|
62
61
|
uuidtools
|
|
63
62
|
htmlentities (4.3.4)
|
|
64
|
-
httpclient (2.8.3)
|
|
65
63
|
iev (0.2.2)
|
|
66
64
|
nokogiri
|
|
67
65
|
image_size (2.0.2)
|
|
68
|
-
isodoc (1.0.
|
|
66
|
+
isodoc (1.0.2)
|
|
69
67
|
asciimath
|
|
70
68
|
html2doc (~> 0.8.11)
|
|
71
69
|
htmlentities (~> 4.3.4)
|
|
@@ -89,10 +87,11 @@ GEM
|
|
|
89
87
|
asciidoctor
|
|
90
88
|
htmlentities
|
|
91
89
|
method_source (0.9.2)
|
|
92
|
-
mime-types (3.
|
|
90
|
+
mime-types (3.3)
|
|
93
91
|
mime-types-data (~> 3.2015)
|
|
94
|
-
mime-types-data (3.2019.
|
|
92
|
+
mime-types-data (3.2019.0904)
|
|
95
93
|
mini_portile2 (2.4.0)
|
|
94
|
+
multipart-post (2.1.1)
|
|
96
95
|
nenv (0.3.0)
|
|
97
96
|
nokogiri (1.10.4)
|
|
98
97
|
mini_portile2 (~> 2.4.0)
|
|
@@ -101,7 +100,7 @@ GEM
|
|
|
101
100
|
shellany (~> 0.0)
|
|
102
101
|
optout (0.0.2)
|
|
103
102
|
parallel (1.17.0)
|
|
104
|
-
parser (2.6.4.
|
|
103
|
+
parser (2.6.4.1)
|
|
105
104
|
ast (~> 2.4.0)
|
|
106
105
|
powerpack (0.1.2)
|
|
107
106
|
pry (0.12.2)
|
|
@@ -113,40 +112,43 @@ GEM
|
|
|
113
112
|
rb-fsevent (0.10.3)
|
|
114
113
|
rb-inotify (0.10.0)
|
|
115
114
|
ffi (~> 1.0)
|
|
116
|
-
relaton (0.5.
|
|
117
|
-
algoliasearch
|
|
115
|
+
relaton (0.5.4)
|
|
118
116
|
relaton-gb (~> 0.6.0)
|
|
119
117
|
relaton-iec (~> 0.4.0)
|
|
120
118
|
relaton-ietf (~> 0.6.0)
|
|
121
119
|
relaton-iso (~> 0.6.0)
|
|
122
120
|
relaton-itu (~> 0.3.0)
|
|
123
121
|
relaton-nist (~> 0.3.0)
|
|
124
|
-
|
|
122
|
+
relaton-ogc (~> 0.1.0)
|
|
123
|
+
relaton-bib (0.3.6)
|
|
125
124
|
addressable
|
|
126
|
-
nokogiri
|
|
127
|
-
relaton-gb (0.6.
|
|
125
|
+
nokogiri
|
|
126
|
+
relaton-gb (0.6.3)
|
|
128
127
|
cnccs (~> 0.1.1)
|
|
129
128
|
gb-agencies (~> 0.0.1)
|
|
130
129
|
relaton-iso-bib (~> 0.3.0)
|
|
131
|
-
relaton-iec (0.4.
|
|
130
|
+
relaton-iec (0.4.4)
|
|
132
131
|
addressable
|
|
133
132
|
relaton-iso-bib (~> 0.3.0)
|
|
134
|
-
relaton-ietf (0.6.
|
|
133
|
+
relaton-ietf (0.6.4)
|
|
135
134
|
relaton-bib (~> 0.3.0)
|
|
136
135
|
relaton-iev (0.1.1)
|
|
137
136
|
relaton (~> 0.5.0)
|
|
138
|
-
relaton-iso (0.6.
|
|
137
|
+
relaton-iso (0.6.5)
|
|
139
138
|
relaton-iec (~> 0.4.0)
|
|
140
139
|
relaton-iso-bib (~> 0.3.0)
|
|
141
|
-
relaton-iso-bib (0.3.
|
|
140
|
+
relaton-iso-bib (0.3.5)
|
|
142
141
|
isoics (~> 0.1.6)
|
|
143
142
|
relaton-bib (~> 0.3.0)
|
|
144
143
|
ruby_deep_clone (~> 0.8.0)
|
|
145
|
-
relaton-itu (0.3.
|
|
144
|
+
relaton-itu (0.3.3)
|
|
146
145
|
relaton-iso-bib (~> 0.3.0)
|
|
147
|
-
relaton-nist (0.3.
|
|
146
|
+
relaton-nist (0.3.4)
|
|
148
147
|
relaton-bib (~> 0.3.0)
|
|
149
148
|
rubyzip
|
|
149
|
+
relaton-ogc (0.1.0)
|
|
150
|
+
faraday
|
|
151
|
+
relaton-iso-bib (~> 0.3.0)
|
|
150
152
|
roman-numerals (0.3.0)
|
|
151
153
|
rspec (3.8.0)
|
|
152
154
|
rspec-core (~> 3.8.0)
|
|
@@ -173,7 +175,7 @@ GEM
|
|
|
173
175
|
ruby-progressbar (1.10.1)
|
|
174
176
|
ruby_deep_clone (0.8.0)
|
|
175
177
|
ruby_dep (1.5.0)
|
|
176
|
-
rubyzip (1.2.
|
|
178
|
+
rubyzip (1.2.4)
|
|
177
179
|
safe_yaml (1.0.5)
|
|
178
180
|
sassc (2.2.0)
|
|
179
181
|
ffi (~> 1.9)
|
|
@@ -192,7 +194,7 @@ GEM
|
|
|
192
194
|
unicode2latex (0.0.2)
|
|
193
195
|
uuidtools (2.1.5)
|
|
194
196
|
vcr (5.0.0)
|
|
195
|
-
webmock (3.7.
|
|
197
|
+
webmock (3.7.2)
|
|
196
198
|
addressable (>= 2.3.6)
|
|
197
199
|
crack (>= 0.3.2)
|
|
198
200
|
hashdiff (>= 0.4.0, < 2.0.0)
|
|
@@ -26,7 +26,7 @@ module Asciidoctor
|
|
|
26
26
|
|
|
27
27
|
def term_defs_boilerplate_cont(src, term, isodoc)
|
|
28
28
|
sources = isodoc.sentence_join(src.map do |s|
|
|
29
|
-
%{<eref
|
|
29
|
+
%{<eref bibitemid="#{s['bibitemid']}"/>}
|
|
30
30
|
end)
|
|
31
31
|
if src.empty? then @internal_terms_boilerplate
|
|
32
32
|
elsif term.nil? then external_terms_boilerplate(sources)
|
|
@@ -102,8 +102,9 @@ module Asciidoctor
|
|
|
102
102
|
r = xmldoc.at("//references[title = 'Bibliography'] | "\
|
|
103
103
|
"//clause[title = 'Bibliography'][.//bibitem]") or return
|
|
104
104
|
r.xpath(".//bibitem[not(ancestor::bibitem)]").each_with_index do |b, i|
|
|
105
|
-
docid = b.at("./docidentifier[@type = 'metanorma']")
|
|
106
|
-
|
|
105
|
+
next unless docid = b.at("./docidentifier[@type = 'metanorma']")
|
|
106
|
+
next unless /^\[\d+\]$/.match(docid.text)
|
|
107
|
+
docid.children = "[#{i + 1}]"
|
|
107
108
|
end
|
|
108
109
|
end
|
|
109
110
|
|
|
@@ -164,7 +165,6 @@ module Asciidoctor
|
|
|
164
165
|
def ref_dl_cleanup(xmldoc)
|
|
165
166
|
xmldoc.xpath("//clause[@bibitem = 'true']").each do |c|
|
|
166
167
|
bib = dl_bib_extract(c) or next
|
|
167
|
-
#warn bib
|
|
168
168
|
bibitemxml = RelatonBib::BibliographicItem.new(
|
|
169
169
|
RelatonBib::HashConverter::hash_to_bib(bib)).to_xml or next
|
|
170
170
|
bibitem = Nokogiri::XML(bibitemxml)
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
require "date"
|
|
2
2
|
require "nokogiri"
|
|
3
3
|
require "htmlentities"
|
|
4
|
-
require "json"
|
|
5
4
|
require "pathname"
|
|
6
5
|
require "open-uri"
|
|
7
|
-
require "pp"
|
|
8
6
|
|
|
9
7
|
module Asciidoctor
|
|
10
8
|
module Standoc
|
|
@@ -182,7 +180,7 @@ module Asciidoctor
|
|
|
182
180
|
end
|
|
183
181
|
|
|
184
182
|
def relaton_relations
|
|
185
|
-
%w(part-of)
|
|
183
|
+
%w(part-of translated-from)
|
|
186
184
|
end
|
|
187
185
|
|
|
188
186
|
def metadata_relations(node, xml)
|
|
@@ -251,14 +249,6 @@ module Asciidoctor
|
|
|
251
249
|
def metadata_series(node, xml)
|
|
252
250
|
end
|
|
253
251
|
|
|
254
|
-
def asciidoc_sub(x)
|
|
255
|
-
return nil if x.nil?
|
|
256
|
-
return "" if x.empty?
|
|
257
|
-
d = Asciidoctor::Document.new(x.lines.entries, {header_footer: false})
|
|
258
|
-
b = d.parse.blocks.first
|
|
259
|
-
b.apply_subs(b.source)
|
|
260
|
-
end
|
|
261
|
-
|
|
262
252
|
def title(node, xml)
|
|
263
253
|
title_english(node, xml)
|
|
264
254
|
title_otherlangs(node, xml)
|
|
@@ -268,7 +258,7 @@ module Asciidoctor
|
|
|
268
258
|
["en"].each do |lang|
|
|
269
259
|
at = { language: lang, format: "text/plain" }
|
|
270
260
|
xml.title **attr_code(at) do |t|
|
|
271
|
-
t << asciidoc_sub(node.attr("title") || node.attr("title-en") ||
|
|
261
|
+
t << Utils::asciidoc_sub(node.attr("title") || node.attr("title-en") ||
|
|
272
262
|
node.title)
|
|
273
263
|
end
|
|
274
264
|
end
|
|
@@ -42,7 +42,8 @@ module Asciidoctor
|
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
def docid(t, code)
|
|
45
|
-
type, code1 = /^\[\d+\]$/.match(code) ?
|
|
45
|
+
type, code1 = /^\[\d+\]$|^\(.+\)$/.match(code) ?
|
|
46
|
+
["metanorma", code.sub(/^\(/, "[").sub(/\)$/, "]")] :
|
|
46
47
|
@bibdb&.docid_type(code) || [nil, code]
|
|
47
48
|
t.docidentifier code1, **attr_code(type: type)
|
|
48
49
|
end
|
|
@@ -17,6 +17,14 @@ module Asciidoctor
|
|
|
17
17
|
node.nil? || node.id.nil? || node.id.empty? ? "_" + uuid : node.id
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
+
def asciidoc_sub(x)
|
|
21
|
+
return nil if x.nil?
|
|
22
|
+
return "" if x.empty?
|
|
23
|
+
d = Asciidoctor::Document.new(x.lines.entries, {header_footer: false})
|
|
24
|
+
b = d.parse.blocks.first
|
|
25
|
+
b.apply_subs(b.source)
|
|
26
|
+
end
|
|
27
|
+
|
|
20
28
|
def localdir(node)
|
|
21
29
|
docfile = node.attr("docfile")
|
|
22
30
|
docfile.nil? ? './' : Pathname.new(docfile).parent.to_s + '/'
|
|
@@ -96,6 +96,7 @@ RSpec.describe Asciidoctor::Standoc do
|
|
|
96
96
|
:email_2: barney@rockhead.example.com
|
|
97
97
|
:publisher: Hanna Barbera, Cartoon Network
|
|
98
98
|
:part-of: ABC
|
|
99
|
+
:translated-from: DEF
|
|
99
100
|
:keywords: a, b, c
|
|
100
101
|
INPUT
|
|
101
102
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
@@ -234,6 +235,12 @@ RSpec.describe Asciidoctor::Standoc do
|
|
|
234
235
|
<docidentifier>ABC</docidentifier>
|
|
235
236
|
</bibitem>
|
|
236
237
|
</relation>
|
|
238
|
+
<relation type="translatedFrom">
|
|
239
|
+
<bibitem>
|
|
240
|
+
<title>--</title>
|
|
241
|
+
<docidentifier>DEF</docidentifier>
|
|
242
|
+
</bibitem>
|
|
243
|
+
</relation>
|
|
237
244
|
<keyword>a</keyword>
|
|
238
245
|
<keyword>b</keyword>
|
|
239
246
|
<keyword>c</keyword>
|
|
@@ -572,18 +572,36 @@ RSpec.describe Asciidoctor::Standoc do
|
|
|
572
572
|
[bibliography]
|
|
573
573
|
== Bibliography
|
|
574
574
|
|
|
575
|
-
* [[[iso123,
|
|
575
|
+
* [[[iso123,2]]] _Standard_
|
|
576
|
+
* [[[iso124,(B)]]] _Standard_
|
|
577
|
+
* [[[iso125,1]]] _Standard_
|
|
578
|
+
* [[[iso126,(A)]]] _Standard_
|
|
576
579
|
INPUT
|
|
577
580
|
#{BLANK_HDR}
|
|
578
581
|
<sections>
|
|
579
582
|
|
|
580
|
-
</sections
|
|
581
|
-
|
|
582
|
-
<bibitem id="iso123">
|
|
583
|
+
</sections>
|
|
584
|
+
<bibliography><references id="_" obligation="informative">
|
|
585
|
+
<title>Bibliography</title><bibitem id="iso123">
|
|
583
586
|
<formattedref format="application/x-isodoc+xml">
|
|
584
587
|
<em>Standard</em>
|
|
585
588
|
</formattedref>
|
|
586
589
|
<docidentifier type="metanorma">[1]</docidentifier>
|
|
590
|
+
</bibitem><bibitem id="iso124">
|
|
591
|
+
<formattedref format="application/x-isodoc+xml">
|
|
592
|
+
<em>Standard</em>
|
|
593
|
+
</formattedref>
|
|
594
|
+
<docidentifier type="metanorma">[B]</docidentifier>
|
|
595
|
+
</bibitem><bibitem id="iso125">
|
|
596
|
+
<formattedref format="application/x-isodoc+xml">
|
|
597
|
+
<em>Standard</em>
|
|
598
|
+
</formattedref>
|
|
599
|
+
<docidentifier type="metanorma">[3]</docidentifier>
|
|
600
|
+
</bibitem><bibitem id="iso126">
|
|
601
|
+
<formattedref format="application/x-isodoc+xml">
|
|
602
|
+
<em>Standard</em>
|
|
603
|
+
</formattedref>
|
|
604
|
+
<docidentifier type="metanorma">[A]</docidentifier>
|
|
587
605
|
</bibitem>
|
|
588
606
|
</references>
|
|
589
607
|
</bibliography>
|
|
@@ -563,7 +563,7 @@ RSpec.describe Asciidoctor::Standoc do
|
|
|
563
563
|
</foreword></preface><sections>
|
|
564
564
|
<terms id="_" obligation="normative">
|
|
565
565
|
<title>Terms and definitions</title><p>For the purposes of this document, the terms and definitions
|
|
566
|
-
given in <eref
|
|
566
|
+
given in <eref bibitemid="iso1234"/> and <eref bibitemid="iso5678"/> and the following apply.</p>
|
|
567
567
|
<term id="_">
|
|
568
568
|
<preferred>Term1</preferred>
|
|
569
569
|
</term>
|
|
@@ -616,7 +616,7 @@ RSpec.describe Asciidoctor::Standoc do
|
|
|
616
616
|
<terms id="_" obligation="normative">
|
|
617
617
|
<title>Terms and definitions</title>
|
|
618
618
|
<p>For the purposes of this document,
|
|
619
|
-
the terms and definitions given in <eref
|
|
619
|
+
the terms and definitions given in <eref bibitemid="iso1234"/> and <eref bibitemid="iso5678"/> apply.</p>
|
|
620
620
|
|
|
621
621
|
|
|
622
622
|
</terms></sections>
|
|
@@ -649,7 +649,7 @@ RSpec.describe Asciidoctor::Standoc do
|
|
|
649
649
|
</foreword></preface><sections>
|
|
650
650
|
<terms id="_" obligation="normative">
|
|
651
651
|
<title>Terms and definitions</title>
|
|
652
|
-
<p>Pour les besoins du présent document, les termes et définitions de <eref
|
|
652
|
+
<p>Pour les besoins du présent document, les termes et définitions de <eref bibitemid="iso1234"/> et <eref bibitemid="iso5678"/> s'appliquent.</p>
|
|
653
653
|
|
|
654
654
|
|
|
655
655
|
</terms></sections>
|
|
@@ -681,7 +681,7 @@ RSpec.describe Asciidoctor::Standoc do
|
|
|
681
681
|
<p id="_">Foreword</p>
|
|
682
682
|
</foreword></preface><sections>
|
|
683
683
|
<terms id="_" obligation="normative">
|
|
684
|
-
<title>Terms and definitions</title><p><eref
|
|
684
|
+
<title>Terms and definitions</title><p><eref bibitemid="iso1234"/>和<eref bibitemid="iso5678"/>界定的术语和定义适用于本文件。</p>
|
|
685
685
|
|
|
686
686
|
|
|
687
687
|
|
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.3.
|
|
4
|
+
version: 1.3.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2019-09-
|
|
11
|
+
date: 2019-09-12 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: asciidoctor
|