asciidoctor-iso 0.7.7 → 0.7.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +10 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +31 -7
- data/README.adoc +13 -0
- data/asciidoctor-iso.gemspec +2 -1
- data/lib/asciidoctor/iso/base.rb +2 -0
- data/lib/asciidoctor/iso/biblio.rng +35 -6
- data/lib/asciidoctor/iso/cleanup.rb +10 -0
- data/lib/asciidoctor/iso/cleanup_ref.rb +4 -2
- data/lib/asciidoctor/iso/converter.rb +1 -0
- data/lib/asciidoctor/iso/front.rb +1 -1
- data/lib/asciidoctor/iso/isodoc.rng +1 -1
- data/lib/asciidoctor/iso/isostandard.rng +46 -13
- data/lib/asciidoctor/iso/lists.rb +2 -129
- data/lib/asciidoctor/iso/ref.rb +228 -0
- data/lib/asciidoctor/iso/version.rb +1 -1
- data/spec/asciidoctor-iso/cleanup_spec.rb +255 -122
- data/spec/asciidoctor-iso/refs_spec.rb +320 -90
- data/spec/examples/iso_123_.xml +45 -0
- data/spec/examples/iso_123_all_parts.xml +45 -0
- data/spec/examples/iso_123_no_year_note.xml +46 -0
- data/spec/examples/iso_124_.xml +41 -0
- data/spec/examples/iso_216_.xml +47 -0
- data/spec/examples/iso_iec_12382_.xml +48 -0
- data/spec/examples/rice.adoc +2 -0
- data/spec/examples/rice.preview.html +4 -1
- data/spec/spec_helper.rb +51 -3
- metadata +28 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e7f887c7ba13f6c2bafbef701638c9f026fc589c
|
4
|
+
data.tar.gz: a95bd92d88b3aeda761ea864ecc2517d78e8b4b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc30366819f3d74f50ca9d85c5bafa56a4652ef8f09ff1462eda57bf74f5490f0b64c9f5b4de62e6e388a1af4c5d03f3dabf9794be113f6f95ce90a0654c2a32
|
7
|
+
data.tar.gz: 0aad02af7061314221dc9e752eacd1c9779e8cbacf755b87094aa93627a104a4d52c8d83747f50385c473e994f61175095a96bad55a85feea31ba1b5746b83ed
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
@@ -5,4 +5,8 @@ gem "html2doc",
|
|
5
5
|
git: "https://github.com/riboseinc/html2doc.git"
|
6
6
|
gem "isodoc",
|
7
7
|
git: "https://github.com/riboseinc/isodoc.git"
|
8
|
+
gem "isobib",
|
9
|
+
git: "https://github.com/riboseinc/isobib.git"
|
10
|
+
gem "iso-bib-item",
|
11
|
+
git: "https://github.com/riboseinc/iso-bib-item.git"
|
8
12
|
gemspec
|
data/Gemfile.lock
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
GIT
|
2
2
|
remote: https://github.com/riboseinc/html2doc.git
|
3
|
-
revision:
|
3
|
+
revision: 6c69bb488b9adc2654276986c657b05bfa82f34d
|
4
4
|
specs:
|
5
|
-
html2doc (0.7.
|
5
|
+
html2doc (0.7.1)
|
6
6
|
asciimath
|
7
7
|
htmlentities (~> 4.3.4)
|
8
8
|
image_size
|
@@ -12,11 +12,27 @@ GIT
|
|
12
12
|
thread_safe
|
13
13
|
uuidtools
|
14
14
|
|
15
|
+
GIT
|
16
|
+
remote: https://github.com/riboseinc/iso-bib-item.git
|
17
|
+
revision: 2fa52155cca85c18bacc1997c3c693f32761061f
|
18
|
+
specs:
|
19
|
+
iso-bib-item (0.1.1)
|
20
|
+
isoics
|
21
|
+
nokogiri
|
22
|
+
|
23
|
+
GIT
|
24
|
+
remote: https://github.com/riboseinc/isobib.git
|
25
|
+
revision: 2e85f6665f5d8397a404f39b3418695b46d733ad
|
26
|
+
specs:
|
27
|
+
isobib (0.1.3)
|
28
|
+
algoliasearch
|
29
|
+
iso-bib-item
|
30
|
+
|
15
31
|
GIT
|
16
32
|
remote: https://github.com/riboseinc/isodoc.git
|
17
|
-
revision:
|
33
|
+
revision: 4a8029c3d15210df5bfa9fd80130760868a806dd
|
18
34
|
specs:
|
19
|
-
isodoc (0.
|
35
|
+
isodoc (0.6.1)
|
20
36
|
asciimath
|
21
37
|
html2doc
|
22
38
|
htmlentities (~> 4.3.4)
|
@@ -33,10 +49,11 @@ GIT
|
|
33
49
|
PATH
|
34
50
|
remote: .
|
35
51
|
specs:
|
36
|
-
asciidoctor-iso (0.7.
|
52
|
+
asciidoctor-iso (0.7.7)
|
37
53
|
asciidoctor (~> 1.5.6)
|
38
54
|
html2doc
|
39
55
|
htmlentities (~> 4.3.4)
|
56
|
+
isobib
|
40
57
|
isodoc
|
41
58
|
nokogiri
|
42
59
|
ruby-jing
|
@@ -47,13 +64,16 @@ PATH
|
|
47
64
|
GEM
|
48
65
|
remote: https://rubygems.org/
|
49
66
|
specs:
|
67
|
+
algoliasearch (1.22.0)
|
68
|
+
httpclient (~> 2.8, >= 2.8.3)
|
69
|
+
json (>= 1.5.1)
|
50
70
|
asciidoctor (1.5.7.1)
|
51
71
|
asciimath (1.0.4)
|
52
72
|
ast (2.4.0)
|
53
73
|
byebug (9.1.0)
|
54
74
|
coderay (1.1.2)
|
55
75
|
diff-lcs (1.3)
|
56
|
-
docile (1.3.
|
76
|
+
docile (1.3.1)
|
57
77
|
equivalent-xml (0.6.0)
|
58
78
|
nokogiri (>= 1.4.3)
|
59
79
|
ffi (1.9.23)
|
@@ -73,7 +93,9 @@ GEM
|
|
73
93
|
guard-compat (~> 1.1)
|
74
94
|
rspec (>= 2.99.0, < 4.0)
|
75
95
|
htmlentities (4.3.4)
|
96
|
+
httpclient (2.8.3)
|
76
97
|
image_size (2.0.0)
|
98
|
+
isoics (0.1.5)
|
77
99
|
json (2.1.0)
|
78
100
|
liquid (4.0.0)
|
79
101
|
listen (3.1.5)
|
@@ -145,7 +167,7 @@ GEM
|
|
145
167
|
thor (0.20.0)
|
146
168
|
thread_safe (0.3.6)
|
147
169
|
timecop (0.9.1)
|
148
|
-
unicode-display_width (1.3.
|
170
|
+
unicode-display_width (1.3.3)
|
149
171
|
uuidtools (2.1.5)
|
150
172
|
|
151
173
|
PLATFORMS
|
@@ -159,6 +181,8 @@ DEPENDENCIES
|
|
159
181
|
guard (~> 2.14)
|
160
182
|
guard-rspec (~> 4.7)
|
161
183
|
html2doc!
|
184
|
+
iso-bib-item!
|
185
|
+
isobib!
|
162
186
|
isodoc!
|
163
187
|
rake (~> 12.0)
|
164
188
|
rspec (~> 3.6)
|
data/README.adoc
CHANGED
@@ -501,7 +501,20 @@ small caps or strike through, though these can be marked up as CSS classes
|
|
501
501
|
through custom macros in Asciidoctor: a custom CSS stylesheet will be needed to
|
502
502
|
render them.
|
503
503
|
|
504
|
+
== Bibliography integration
|
504
505
|
|
506
|
+
Bibliographic entries for ISO standards are expected to use the standard document
|
507
|
+
identifier as the item label; e.g.
|
508
|
+
|
509
|
+
[source,asciidoctor]
|
510
|
+
--
|
511
|
+
* [[[ref1,ISO 712]]], _Cereals and cereal products -- Determination of moisture content -- Reference method_
|
512
|
+
--
|
513
|
+
|
514
|
+
By default, the `isobib` gem is used to look up the reference details for
|
515
|
+
any item label prefixed with `ISO` on the ISO web site. The full bibliographic details
|
516
|
+
of the item are screenscraped from the ISO site and inserted into the XML file
|
517
|
+
(although only the title of the reference is used in rendering).
|
505
518
|
|
506
519
|
== Document Attributes
|
507
520
|
|
data/asciidoctor-iso.gemspec
CHANGED
@@ -35,7 +35,8 @@ Gem::Specification.new do |spec|
|
|
35
35
|
spec.add_dependency "sass"
|
36
36
|
spec.add_dependency "uuidtools"
|
37
37
|
spec.add_dependency "html2doc"
|
38
|
-
spec.add_dependency "isodoc"
|
38
|
+
spec.add_dependency "isodoc", "~> 0.6.2"
|
39
|
+
spec.add_dependency "isobib", "~> 0.1.4"
|
39
40
|
|
40
41
|
spec.add_development_dependency "bundler", "~> 1.15"
|
41
42
|
spec.add_development_dependency "byebug", "~> 9.1"
|
data/lib/asciidoctor/iso/base.rb
CHANGED
@@ -82,6 +82,7 @@ module Asciidoctor
|
|
82
82
|
@novalid = node.attr("novalid")
|
83
83
|
@fontheader = default_fonts(node)
|
84
84
|
@files_to_delete = []
|
85
|
+
@bibliodb = open_cache_biblio(node)
|
85
86
|
end
|
86
87
|
|
87
88
|
def default_fonts(node)
|
@@ -115,6 +116,7 @@ module Asciidoctor
|
|
115
116
|
result << noko { |ixml| front node, ixml }
|
116
117
|
result << noko { |ixml| middle node, ixml }
|
117
118
|
result << "</iso-standard>"
|
119
|
+
save_cache_biblio(@bibliodb)
|
118
120
|
textcleanup(result.flatten * "\n")
|
119
121
|
end
|
120
122
|
|
@@ -442,9 +442,9 @@
|
|
442
442
|
<optional>
|
443
443
|
<ref name="status"/>
|
444
444
|
</optional>
|
445
|
-
<
|
445
|
+
<zeroOrMore>
|
446
446
|
<ref name="copyright"/>
|
447
|
-
</
|
447
|
+
</zeroOrMore>
|
448
448
|
<zeroOrMore>
|
449
449
|
<ref name="docrelation"/>
|
450
450
|
</zeroOrMore>
|
@@ -489,10 +489,31 @@
|
|
489
489
|
<value>issued</value>
|
490
490
|
</choice>
|
491
491
|
</attribute>
|
492
|
-
|
493
|
-
<
|
494
|
-
<
|
495
|
-
|
492
|
+
<!-- ( ( bfrom, bto? ) | date_on ) -->
|
493
|
+
<choice>
|
494
|
+
<group>
|
495
|
+
<element name="from">
|
496
|
+
<choice>
|
497
|
+
<data type="gYear"/>
|
498
|
+
<data type="date"/>
|
499
|
+
</choice>
|
500
|
+
</element>
|
501
|
+
<optional>
|
502
|
+
<element name="to">
|
503
|
+
<choice>
|
504
|
+
<data type="gYear"/>
|
505
|
+
<data type="date"/>
|
506
|
+
</choice>
|
507
|
+
</element>
|
508
|
+
</optional>
|
509
|
+
</group>
|
510
|
+
<element name="on">
|
511
|
+
<choice>
|
512
|
+
<data type="gYear"/>
|
513
|
+
<data type="date"/>
|
514
|
+
</choice>
|
515
|
+
</element>
|
516
|
+
</choice>
|
496
517
|
</element>
|
497
518
|
</define>
|
498
519
|
<define name="bfrom">
|
@@ -511,6 +532,14 @@
|
|
511
532
|
</choice>
|
512
533
|
</element>
|
513
534
|
</define>
|
535
|
+
<define name="date_on">
|
536
|
+
<element name="on">
|
537
|
+
<choice>
|
538
|
+
<data type="gYear"/>
|
539
|
+
<data type="date"/>
|
540
|
+
</choice>
|
541
|
+
</element>
|
542
|
+
</define>
|
514
543
|
<define name="docidentifier">
|
515
544
|
<element name="docidentifier">
|
516
545
|
<optional>
|
@@ -36,6 +36,7 @@ module Asciidoctor
|
|
36
36
|
footnote_renumber(xmldoc)
|
37
37
|
empty_element_cleanup(xmldoc)
|
38
38
|
mathml_cleanup(xmldoc)
|
39
|
+
script_cleanup(xmldoc)
|
39
40
|
bookmark_cleanup(xmldoc)
|
40
41
|
xmldoc
|
41
42
|
end
|
@@ -46,6 +47,15 @@ module Asciidoctor
|
|
46
47
|
referenceTo docidentifier prefix initial addition surname forename
|
47
48
|
title draft secretariat title-main title-intro title-part}.freeze
|
48
49
|
|
50
|
+
# it seems Nokogiri::XML is treating the content of <script> as cdata,
|
51
|
+
# because of its use in HTML. Bad nokogiri. Undoing that, since we use
|
52
|
+
# script as a normal tag
|
53
|
+
def script_cleanup(xmldoc)
|
54
|
+
xmldoc.xpath("//script").each do |x|
|
55
|
+
x.content = x.to_str
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
49
59
|
def empty_element_cleanup(xmldoc)
|
50
60
|
xmldoc.xpath("//" + TEXT_ELEMS.join(" | //")).each do |x|
|
51
61
|
x.remove if x.children.empty?
|
@@ -99,8 +99,10 @@ module Asciidoctor
|
|
99
99
|
def date_range(date)
|
100
100
|
from = date.at("./from")
|
101
101
|
to = date.at("./to")
|
102
|
-
|
103
|
-
|
102
|
+
on = date.at("./on")
|
103
|
+
return on.text if on
|
104
|
+
ret = "#{from.text}–"
|
105
|
+
ret += to.text if to
|
104
106
|
ret
|
105
107
|
end
|
106
108
|
|
@@ -3,6 +3,7 @@ require "asciidoctor/iso/version"
|
|
3
3
|
require "asciidoctor/iso/base"
|
4
4
|
require "asciidoctor/iso/front"
|
5
5
|
require "asciidoctor/iso/lists"
|
6
|
+
require "asciidoctor/iso/ref"
|
6
7
|
require "asciidoctor/iso/inline"
|
7
8
|
require "asciidoctor/iso/blocks"
|
8
9
|
require "asciidoctor/iso/section"
|
@@ -39,7 +39,7 @@ module Asciidoctor
|
|
39
39
|
"International Organization for Standardization"].include? orgname
|
40
40
|
org.name "International Organization for Standardization"
|
41
41
|
org.abbreviation "ISO"
|
42
|
-
elsif ["IEC",
|
42
|
+
elsif ["IEC",
|
43
43
|
"International Electrotechnical Commission"].include? orgname
|
44
44
|
org.name "International Electrotechnical Commission"
|
45
45
|
org.abbreviation "IEC"
|
@@ -72,9 +72,9 @@
|
|
72
72
|
</oneOrMore>
|
73
73
|
<ref name="formattedref"/>
|
74
74
|
</choice>
|
75
|
-
<
|
75
|
+
<zeroOrMore>
|
76
76
|
<ref name="bsource"/>
|
77
|
-
</
|
77
|
+
</zeroOrMore>
|
78
78
|
<zeroOrMore>
|
79
79
|
<ref name="docidentifier"/>
|
80
80
|
</zeroOrMore>
|
@@ -96,9 +96,9 @@
|
|
96
96
|
<zeroOrMore>
|
97
97
|
<ref name="script"/>
|
98
98
|
</zeroOrMore>
|
99
|
-
<
|
99
|
+
<zeroOrMore>
|
100
100
|
<ref name="abstract"/>
|
101
|
-
</
|
101
|
+
</zeroOrMore>
|
102
102
|
<optional>
|
103
103
|
<ref name="status"/>
|
104
104
|
</optional>
|
@@ -127,9 +127,9 @@
|
|
127
127
|
<optional>
|
128
128
|
<ref name="formattedref"/>
|
129
129
|
</optional>
|
130
|
-
<
|
130
|
+
<zeroOrMore>
|
131
131
|
<ref name="bsource"/>
|
132
|
-
</
|
132
|
+
</zeroOrMore>
|
133
133
|
<zeroOrMore>
|
134
134
|
<ref name="docidentifier"/>
|
135
135
|
</zeroOrMore>
|
@@ -151,9 +151,9 @@
|
|
151
151
|
<zeroOrMore>
|
152
152
|
<ref name="script"/>
|
153
153
|
</zeroOrMore>
|
154
|
-
<
|
154
|
+
<zeroOrMore>
|
155
155
|
<ref name="abstract"/>
|
156
|
-
</
|
156
|
+
</zeroOrMore>
|
157
157
|
<optional>
|
158
158
|
<ref name="status"/>
|
159
159
|
</optional>
|
@@ -166,12 +166,45 @@
|
|
166
166
|
<ref name="ics"/>
|
167
167
|
</zeroOrMore>
|
168
168
|
</define>
|
169
|
-
<define name="
|
170
|
-
<element name="
|
169
|
+
<define name="bdate">
|
170
|
+
<element name="date">
|
171
|
+
<attribute name="type">
|
172
|
+
<choice>
|
173
|
+
<value>published</value>
|
174
|
+
<value>accessed</value>
|
175
|
+
<value>created</value>
|
176
|
+
<value>implemented</value>
|
177
|
+
<value>obsoleted</value>
|
178
|
+
<value>confirmed</value>
|
179
|
+
<value>updated</value>
|
180
|
+
<value>issued</value>
|
181
|
+
</choice>
|
182
|
+
</attribute>
|
183
|
+
<!-- ( ( bfrom, bto? ) | date_on ) -->
|
171
184
|
<choice>
|
172
|
-
<
|
173
|
-
|
174
|
-
|
185
|
+
<group>
|
186
|
+
<element name="from">
|
187
|
+
<choice>
|
188
|
+
<data type="gYear"/>
|
189
|
+
<data type="date"/>
|
190
|
+
</choice>
|
191
|
+
</element>
|
192
|
+
<optional>
|
193
|
+
<element name="to">
|
194
|
+
<choice>
|
195
|
+
<data type="gYear"/>
|
196
|
+
<data type="date"/>
|
197
|
+
</choice>
|
198
|
+
</element>
|
199
|
+
</optional>
|
200
|
+
</group>
|
201
|
+
<element name="on">
|
202
|
+
<choice>
|
203
|
+
<data type="gYear"/>
|
204
|
+
<data type="date"/>
|
205
|
+
<value>--</value>
|
206
|
+
</choice>
|
207
|
+
</element>
|
175
208
|
</choice>
|
176
209
|
</element>
|
177
210
|
</define>
|
@@ -1,4 +1,6 @@
|
|
1
1
|
require "pp"
|
2
|
+
require "isobib"
|
3
|
+
|
2
4
|
module Asciidoctor
|
3
5
|
module ISO
|
4
6
|
module Lists
|
@@ -24,135 +26,6 @@ module Asciidoctor
|
|
24
26
|
end.join("\n")
|
25
27
|
end
|
26
28
|
|
27
|
-
def iso_publisher(t, code)
|
28
|
-
code.sub(/ .*$/, "").split(/\//).each do |abbrev|
|
29
|
-
t.contributor do |c|
|
30
|
-
c.role **{ type: "publisher" }
|
31
|
-
c.organization do |org|
|
32
|
-
organization(org, abbrev)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
def plaintxt
|
39
|
-
{ format: "text/plain" }
|
40
|
-
end
|
41
|
-
|
42
|
-
def ref_attributes(m)
|
43
|
-
{ id: m[:anchor], type: "standard" }
|
44
|
-
end
|
45
|
-
|
46
|
-
def set_date_range(date, text)
|
47
|
-
matched = /^(?<from>[0-9]+)(-+(?<to>[0-9]+))?$/.match text
|
48
|
-
return unless matched[:from]
|
49
|
-
date.from matched[:from]
|
50
|
-
date.to matched[:to] if matched[:to]
|
51
|
-
end
|
52
|
-
|
53
|
-
def isorefmatches(xml, m)
|
54
|
-
xml.bibitem **attr_code(ref_attributes(m)) do |t|
|
55
|
-
t.title(**plaintxt) { |i| i << ref_normalise(m[:text]) }
|
56
|
-
t.docidentifier m[:code]
|
57
|
-
m[:year] and t.date **{ type: "published" } do |d|
|
58
|
-
set_date_range(d, m[:year])
|
59
|
-
end
|
60
|
-
iso_publisher(t, m[:code])
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
def isorefmatches2(xml, m)
|
65
|
-
xml.bibitem **attr_code(ref_attributes(m)) do |t|
|
66
|
-
t.title(**plaintxt) { |i| i << ref_normalise(m[:text]) }
|
67
|
-
t.docidentifier m[:code]
|
68
|
-
t.date **{ type: "published" } do |d|
|
69
|
-
d.from "--"
|
70
|
-
end
|
71
|
-
iso_publisher(t, m[:code])
|
72
|
-
t.note(**plaintxt) { |p| p << "ISO DATE: #{m[:fn]}" }
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
def isorefmatches3(xml, m)
|
77
|
-
xml.bibitem **attr_code(ref_attributes(m)) do |t|
|
78
|
-
t.title(**plaintxt) { |i| i << ref_normalise(m[:text]) }
|
79
|
-
t.docidentifier "#{m[:code]}:All Parts"
|
80
|
-
if m.named_captures.has_key?("year")
|
81
|
-
t.date **{ type: "published" } { |d| set_date_range(d, m[:year]) }
|
82
|
-
end
|
83
|
-
iso_publisher(t, m[:code])
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
# TODO: alternative where only title is available
|
88
|
-
def refitem(xml, item, node)
|
89
|
-
unless m = NON_ISO_REF.match(item)
|
90
|
-
Utils::warning(node, "no anchor on reference", item)
|
91
|
-
return
|
92
|
-
end
|
93
|
-
xml.bibitem **attr_code(id: m[:anchor]) do |t|
|
94
|
-
t.formattedref **{ format: "application/x-isodoc+xml" } do |i|
|
95
|
-
i << ref_normalise_no_format(m[:text])
|
96
|
-
end
|
97
|
-
t.docidentifier(/^\d+$/.match?(m[:code]) ? "[#{m[:code]}]" : m[:code])
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
def ref_normalise(ref)
|
102
|
-
ref.
|
103
|
-
# gsub(/ — /, " -- ").
|
104
|
-
gsub(/&amp;/, "&").
|
105
|
-
gsub(%r{^<em>(.*)</em>}, "\\1")
|
106
|
-
end
|
107
|
-
|
108
|
-
def ref_normalise_no_format(ref)
|
109
|
-
ref.
|
110
|
-
# gsub(/ — /, " -- ").
|
111
|
-
gsub(/&amp;/, "&")
|
112
|
-
end
|
113
|
-
|
114
|
-
ISO_REF = %r{^<ref\sid="(?<anchor>[^"]+)">
|
115
|
-
\[(?<code>(ISO|IEC)[^0-9]*\s[0-9-]+)(:(?<year>[0-9][0-9-]+))?\]</ref>,?\s
|
116
|
-
(?<text>.*)$}xm
|
117
|
-
|
118
|
-
ISO_REF_NO_YEAR = %r{^<ref\sid="(?<anchor>[^"]+)">
|
119
|
-
\[(?<code>(ISO|IEC)[^0-9]*\s[0-9-]+):--\]</ref>,?\s?
|
120
|
-
<fn[^>]*>\s*<p>(?<fn>[^\]]+)</p>\s*</fn>,?\s?(?<text>.*)$}xm
|
121
|
-
|
122
|
-
ISO_REF_ALL_PARTS = %r{^<ref\sid="(?<anchor>[^"]+)">
|
123
|
-
\[(?<code>(ISO|IEC)[^0-9]*\s[0-9]+)(:(?<year>[0-9][0-9-]+))?\s
|
124
|
-
\(all\sparts\)\]</ref>,?\s
|
125
|
-
(?<text>.*)$}xm
|
126
|
-
|
127
|
-
NON_ISO_REF = %r{^<ref\sid="(?<anchor>[^"]+)">
|
128
|
-
\[(?<code>[^\]]+)\]</ref>,?\s
|
129
|
-
(?<text>.*)$}xm
|
130
|
-
|
131
|
-
def reference1_matches(item)
|
132
|
-
matched = ISO_REF.match item
|
133
|
-
matched2 = ISO_REF_NO_YEAR.match item
|
134
|
-
matched3 = ISO_REF_ALL_PARTS.match item
|
135
|
-
[matched, matched2, matched3]
|
136
|
-
end
|
137
|
-
|
138
|
-
def reference1(node, item, xml)
|
139
|
-
matched, matched2, matched3 = reference1_matches(item)
|
140
|
-
if matched3.nil? && matched2.nil? && matched.nil?
|
141
|
-
refitem(xml, item, node)
|
142
|
-
elsif !matched.nil? then isorefmatches(xml, matched)
|
143
|
-
elsif !matched2.nil? then isorefmatches2(xml, matched2)
|
144
|
-
elsif !matched3.nil? then isorefmatches3(xml, matched3)
|
145
|
-
end
|
146
|
-
end
|
147
|
-
|
148
|
-
def reference(node)
|
149
|
-
noko do |xml|
|
150
|
-
node.items.each do |item|
|
151
|
-
reference1(node, item.text, xml)
|
152
|
-
end
|
153
|
-
end.join("\n")
|
154
|
-
end
|
155
|
-
|
156
29
|
def olist_style(style)
|
157
30
|
return "alphabet" if style == "loweralpha"
|
158
31
|
return "roman" if style == "lowerroman"
|