asciidoctor-iso 0.7.0 → 0.7.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/Gemfile.lock +12 -10
- data/asciidoctor-iso.gemspec +1 -1
- data/lib/asciidoctor/iso/base.rb +6 -3
- data/lib/asciidoctor/iso/blocks.rb +4 -18
- data/lib/asciidoctor/iso/cleanup.rb +20 -11
- data/lib/asciidoctor/iso/cleanup_block.rb +38 -21
- data/lib/asciidoctor/iso/cleanup_ref.rb +17 -4
- data/lib/asciidoctor/iso/converter.rb +0 -1
- data/lib/asciidoctor/iso/front.rb +23 -14
- data/lib/asciidoctor/iso/html/html_iso_intro.html +0 -36
- data/lib/asciidoctor/iso/html/isodoc.css +5 -0
- data/lib/asciidoctor/iso/inline.rb +14 -2
- data/lib/asciidoctor/iso/isodoc.rng +38 -6
- data/lib/asciidoctor/iso/isostandard.rng +16 -11
- data/lib/asciidoctor/iso/lists.rb +28 -23
- data/lib/asciidoctor/iso/section.rb +4 -14
- data/lib/asciidoctor/iso/table.rb +0 -3
- data/lib/asciidoctor/iso/utils.rb +2 -0
- data/lib/asciidoctor/iso/validate.rb +2 -2
- data/lib/asciidoctor/iso/validate_section.rb +62 -4
- data/lib/asciidoctor/iso/validate_style.rb +24 -15
- data/lib/asciidoctor/iso/version.rb +1 -1
- data/spec/asciidoctor-iso/base_spec.rb +32 -6
- data/spec/asciidoctor-iso/blocks_spec.rb +10 -0
- data/spec/asciidoctor-iso/cleanup_spec.rb +26 -18
- data/spec/asciidoctor-iso/inline_spec.rb +2 -0
- data/spec/asciidoctor-iso/lists_spec.rb +1 -0
- data/spec/asciidoctor-iso/refs_spec.rb +44 -11
- data/spec/asciidoctor-iso/validate_spec.rb +1 -0
- data/spec/examples/rice.doc +2751 -2732
- data/spec/examples/rice.html +184 -205
- data/spec/examples/rice.xml +244 -212
- data/spec/spec_helper.rb +6 -3
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ff009fa5a7024c54efd53fc7e8a353559d1ab6a
|
4
|
+
data.tar.gz: 7bd27462cb448bfb0ce0947ebf60a622b9215a95
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f221438783ca673de960d8143f1aa196c8a5748d839cdb048f6ec3d6dd4fe8d0d927f137c8a03e9ac1e7dba47a642ebf77eb643a24a65c148b85c958e83a465
|
7
|
+
data.tar.gz: cd1ae57550314578b6fe0df3d7917c793f273255e248eacb78592f98dc12fb2dc15c06f05c092323230ecf67c360d736953e06fffd9e878a325055a5f23d81df
|
data/Gemfile.lock
CHANGED
@@ -1,29 +1,30 @@
|
|
1
1
|
GIT
|
2
2
|
remote: https://github.com/riboseinc/html2doc.git
|
3
|
-
revision:
|
3
|
+
revision: 9782088aac279f45a4420e977922ea141bc46a24
|
4
4
|
specs:
|
5
|
-
html2doc (0.6.
|
5
|
+
html2doc (0.6.7)
|
6
6
|
asciimath
|
7
7
|
htmlentities (~> 4.3.4)
|
8
8
|
image_size
|
9
9
|
mime-types
|
10
|
-
nokogiri
|
10
|
+
nokogiri
|
11
11
|
ruby-xslt
|
12
12
|
thread_safe
|
13
13
|
uuidtools
|
14
14
|
|
15
15
|
GIT
|
16
16
|
remote: https://github.com/riboseinc/isodoc.git
|
17
|
-
revision:
|
17
|
+
revision: b5db3572f9312f9d54ace3359d22236494584357
|
18
18
|
specs:
|
19
|
-
isodoc (0.5.
|
19
|
+
isodoc (0.5.5)
|
20
20
|
asciimath
|
21
21
|
html2doc
|
22
22
|
htmlentities (~> 4.3.4)
|
23
23
|
image_size
|
24
24
|
liquid
|
25
25
|
mime-types
|
26
|
-
nokogiri
|
26
|
+
nokogiri
|
27
|
+
roman-numerals
|
27
28
|
ruby-xslt
|
28
29
|
thread_safe
|
29
30
|
uuidtools
|
@@ -31,12 +32,12 @@ GIT
|
|
31
32
|
PATH
|
32
33
|
remote: .
|
33
34
|
specs:
|
34
|
-
asciidoctor-iso (0.
|
35
|
+
asciidoctor-iso (0.7.1)
|
35
36
|
asciidoctor (~> 1.5.6)
|
36
37
|
html2doc
|
37
38
|
htmlentities (~> 4.3.4)
|
38
39
|
isodoc
|
39
|
-
nokogiri
|
40
|
+
nokogiri
|
40
41
|
ruby-jing
|
41
42
|
thread_safe
|
42
43
|
uuidtools
|
@@ -84,7 +85,7 @@ GEM
|
|
84
85
|
mime-types-data (3.2016.0521)
|
85
86
|
mini_portile2 (2.3.0)
|
86
87
|
nenv (0.3.0)
|
87
|
-
nokogiri (1.8.
|
88
|
+
nokogiri (1.8.2)
|
88
89
|
mini_portile2 (~> 2.3.0)
|
89
90
|
notiffany (0.1.1)
|
90
91
|
nenv (~> 0.1)
|
@@ -102,6 +103,7 @@ GEM
|
|
102
103
|
rb-fsevent (0.10.3)
|
103
104
|
rb-inotify (0.9.10)
|
104
105
|
ffi (>= 0.5.0, < 2)
|
106
|
+
roman-numerals (0.3.0)
|
105
107
|
rspec (3.7.0)
|
106
108
|
rspec-core (~> 3.7.0)
|
107
109
|
rspec-expectations (~> 3.7.0)
|
@@ -115,7 +117,7 @@ GEM
|
|
115
117
|
diff-lcs (>= 1.2.0, < 2.0)
|
116
118
|
rspec-support (~> 3.7.0)
|
117
119
|
rspec-support (3.7.1)
|
118
|
-
rubocop (0.
|
120
|
+
rubocop (0.52.1)
|
119
121
|
parallel (~> 1.10)
|
120
122
|
parser (>= 2.5)
|
121
123
|
powerpack (~> 0.1)
|
data/asciidoctor-iso.gemspec
CHANGED
@@ -29,7 +29,7 @@ Gem::Specification.new do |spec|
|
|
29
29
|
|
30
30
|
spec.add_dependency "asciidoctor", "~> 1.5.6"
|
31
31
|
spec.add_dependency "htmlentities", "~> 4.3.4"
|
32
|
-
spec.add_dependency "nokogiri"
|
32
|
+
spec.add_dependency "nokogiri"
|
33
33
|
spec.add_dependency "ruby-jing"
|
34
34
|
spec.add_dependency "thread_safe"
|
35
35
|
spec.add_dependency "uuidtools"
|
data/lib/asciidoctor/iso/base.rb
CHANGED
@@ -67,12 +67,16 @@ module Asciidoctor
|
|
67
67
|
ret
|
68
68
|
end
|
69
69
|
|
70
|
-
def
|
70
|
+
def makexml1(node)
|
71
71
|
result = ["<?xml version='1.0' encoding='UTF-8'?>\n<iso-standard>"]
|
72
72
|
result << noko { |ixml| front node, ixml }
|
73
73
|
result << noko { |ixml| middle node, ixml }
|
74
74
|
result << "</iso-standard>"
|
75
|
-
|
75
|
+
textcleanup(result.flatten * "\n")
|
76
|
+
end
|
77
|
+
|
78
|
+
def makexml(node)
|
79
|
+
result = makexml1(node)
|
76
80
|
ret1 = cleanup(Nokogiri::XML(result))
|
77
81
|
ret1.root.add_namespace(nil, "http://riboseinc.com/isoxml")
|
78
82
|
validate(ret1) unless @novalid
|
@@ -134,7 +138,6 @@ module Asciidoctor
|
|
134
138
|
xml.termsource **attrs do |xml_t|
|
135
139
|
seen_xref = Nokogiri::XML.fragment(matched[:xref])
|
136
140
|
add_term_source(xml_t, seen_xref, matched)
|
137
|
-
style(node, matched[:text])
|
138
141
|
end
|
139
142
|
end.join("\n")
|
140
143
|
end
|
@@ -28,8 +28,7 @@ module Asciidoctor
|
|
28
28
|
stem_content = node.lines.join("\n")
|
29
29
|
noko do |xml|
|
30
30
|
xml.formula **id_attr(node) do |s|
|
31
|
-
|
32
|
-
style(node, stem_content)
|
31
|
+
stem_parse(stem_content, s)
|
33
32
|
end
|
34
33
|
end
|
35
34
|
end
|
@@ -59,7 +58,6 @@ module Asciidoctor
|
|
59
58
|
noko do |xml|
|
60
59
|
xml.termnote **id_attr(n) do |ex|
|
61
60
|
wrap_in_para(n, ex)
|
62
|
-
style(n, Utils::flatten_rawtext(n.content).join("\n"))
|
63
61
|
end
|
64
62
|
end.join("\n")
|
65
63
|
end
|
@@ -68,8 +66,6 @@ module Asciidoctor
|
|
68
66
|
noko do |xml|
|
69
67
|
xml.note **id_attr(n) do |c|
|
70
68
|
wrap_in_para(n, c)
|
71
|
-
text = Utils::flatten_rawtext(n.content).join("\n")
|
72
|
-
note_style(n, text)
|
73
69
|
end
|
74
70
|
end.join("\n")
|
75
71
|
end
|
@@ -85,7 +81,7 @@ module Asciidoctor
|
|
85
81
|
end
|
86
82
|
|
87
83
|
def admonition(node)
|
88
|
-
return termnote(node) if in_terms
|
84
|
+
return termnote(node) if in_terms?
|
89
85
|
return note(node) if node.attr("name") == "note"
|
90
86
|
noko do |xml|
|
91
87
|
xml.admonition **admonition_attrs(node) do |a|
|
@@ -97,22 +93,17 @@ module Asciidoctor
|
|
97
93
|
def term_example(node)
|
98
94
|
noko do |xml|
|
99
95
|
xml.termexample **id_attr(node) do |ex|
|
100
|
-
c = node.content
|
101
96
|
wrap_in_para(node, ex)
|
102
|
-
text = Utils::flatten_rawtext(c).join("\n")
|
103
|
-
termexample_style(node, text)
|
104
97
|
end
|
105
98
|
end.join("\n")
|
106
99
|
end
|
107
100
|
|
108
101
|
def example(node)
|
109
|
-
return term_example(node) if in_terms
|
102
|
+
return term_example(node) if in_terms?
|
110
103
|
noko do |xml|
|
111
104
|
xml.example **id_attr(node) do |ex|
|
112
105
|
content = node.content
|
113
106
|
ex << content
|
114
|
-
text = Utils::flatten_rawtext(content).join("\n")
|
115
|
-
termexample_style(node, text)
|
116
107
|
end
|
117
108
|
end.join("\n")
|
118
109
|
end
|
@@ -123,8 +114,6 @@ module Asciidoctor
|
|
123
114
|
xml_abstract.title { |t| t << "Foreword" }
|
124
115
|
content = node.content
|
125
116
|
xml_abstract << content
|
126
|
-
text = Utils::flatten_rawtext(content).join("\n")
|
127
|
-
foreword_style(node, text)
|
128
117
|
end
|
129
118
|
end.join("\n")
|
130
119
|
end
|
@@ -140,9 +129,7 @@ module Asciidoctor
|
|
140
129
|
end
|
141
130
|
|
142
131
|
def figure_title(node, f)
|
143
|
-
|
144
|
-
style_warning(node, "Figure should have title", nil)
|
145
|
-
else
|
132
|
+
unless node.title.nil?
|
146
133
|
f.name { |name| name << node.title }
|
147
134
|
end
|
148
135
|
end
|
@@ -163,7 +150,6 @@ module Asciidoctor
|
|
163
150
|
noko do |xml|
|
164
151
|
xml.p **attr_code(attrs) do |xml_t|
|
165
152
|
xml_t << node.content
|
166
|
-
style(node, Utils::flatten_rawtext(node).join(" "))
|
167
153
|
end
|
168
154
|
end.join("\n")
|
169
155
|
end
|
@@ -33,6 +33,7 @@ module Asciidoctor
|
|
33
33
|
element_name_cleanup(xmldoc)
|
34
34
|
footnote_renumber(xmldoc)
|
35
35
|
empty_element_cleanup(xmldoc)
|
36
|
+
mathml_cleanup(xmldoc)
|
36
37
|
bookmark_cleanup(xmldoc)
|
37
38
|
xmldoc
|
38
39
|
end
|
@@ -66,8 +67,6 @@ module Asciidoctor
|
|
66
67
|
annotations = x.elements.select { |e| e.name == "annotation" }
|
67
68
|
if callouts.size == annotations.size
|
68
69
|
link_callouts_to_annotations(callouts, annotations)
|
69
|
-
else
|
70
|
-
warn "#{x['id']}: mismatch of callouts and annotations"
|
71
70
|
end
|
72
71
|
end
|
73
72
|
end
|
@@ -124,9 +123,7 @@ module Asciidoctor
|
|
124
123
|
end
|
125
124
|
|
126
125
|
def termdef_boilerplate_cleanup(xmldoc)
|
127
|
-
xmldoc.xpath("//terms/p | //terms/ul").each
|
128
|
-
a.remove
|
129
|
-
end
|
126
|
+
xmldoc.xpath("//terms/p | //terms/ul").each(&:remove)
|
130
127
|
end
|
131
128
|
|
132
129
|
def termdef_cleanup(xmldoc)
|
@@ -138,11 +135,13 @@ module Asciidoctor
|
|
138
135
|
end
|
139
136
|
|
140
137
|
ELEMS_ALLOW_NOTES =
|
141
|
-
%w[p formula quote sourcecode example admonition ul ol dl figure]
|
138
|
+
# %w[p formula quote sourcecode example admonition ul ol dl figure]
|
139
|
+
%w[p formula ul ol dl figure].freeze
|
142
140
|
|
143
141
|
# if a note is at the end of a section, it is left alone
|
144
142
|
# if a note is followed by a non-note block,
|
145
|
-
# it is moved inside its preceding block
|
143
|
+
# it is moved inside its preceding block if it is not delimited
|
144
|
+
# (so there was no way of making that block include the note)
|
146
145
|
def note_cleanup(xmldoc)
|
147
146
|
q = "//note[following-sibling::*[not(local-name() = 'note')]]"
|
148
147
|
xmldoc.xpath(q).each do |n|
|
@@ -167,22 +166,32 @@ module Asciidoctor
|
|
167
166
|
if !/\S/.match?(x.children[0].text)
|
168
167
|
x.children[0].remove
|
169
168
|
else
|
170
|
-
x.children[0].content =
|
169
|
+
x.children[0].content = x.children[0].text.gsub(/^ /, "")
|
171
170
|
end
|
172
171
|
end
|
173
172
|
end
|
174
173
|
|
175
174
|
def bookmark_cleanup(xmldoc)
|
176
175
|
xmldoc.xpath("//li[descendant::bookmark]").each do |x|
|
177
|
-
if x&.elements
|
178
|
-
x&.elements
|
176
|
+
if x&.elements&.first&.name == "p" &&
|
177
|
+
x&.elements&.first&.elements&.first&.name == "bookmark"
|
179
178
|
if empty_text_before_first_element(x.elements[0])
|
180
|
-
x["id"] =
|
179
|
+
x["id"] = x.elements[0].elements[0].remove["id"]
|
181
180
|
strip_initial_space(x.elements[0])
|
182
181
|
end
|
183
182
|
end
|
184
183
|
end
|
185
184
|
end
|
185
|
+
|
186
|
+
def mathml_cleanup(xmldoc)
|
187
|
+
xmldoc.xpath("//stem[@type = 'MathML']").each do |x|
|
188
|
+
math = x.text.gsub(/</, "<").gsub(/>/, ">").gsub(/"/, '"').
|
189
|
+
gsub(/&/, "&").gsub(/<[^:\/]+:/, "<").gsub(/<\/[^:]+:/, "</").
|
190
|
+
gsub(/ xmlns[^>]+/, "").
|
191
|
+
gsub(/<math>/, '<math xmlns="http://www.w3.org/1998/Math/MathML">')
|
192
|
+
x.children = math
|
193
|
+
end
|
194
|
+
end
|
186
195
|
end
|
187
196
|
end
|
188
197
|
end
|
@@ -19,8 +19,8 @@ module Asciidoctor
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
+
# move Key dl after table footer
|
22
23
|
def dl_table_cleanup(xmldoc)
|
23
|
-
# move Key dl after table footer
|
24
24
|
q = "//table/following-sibling::*[1]"\
|
25
25
|
"[self::p and normalize-space() = 'Key']"
|
26
26
|
xmldoc.xpath(q).each do |s|
|
@@ -58,8 +58,8 @@ module Asciidoctor
|
|
58
58
|
header_rows_cleanup(xmldoc)
|
59
59
|
end
|
60
60
|
|
61
|
+
# move notes into table
|
61
62
|
def notes_table_cleanup(xmldoc)
|
62
|
-
# move notes into table
|
63
63
|
nomatches = false
|
64
64
|
until nomatches
|
65
65
|
q = "//table/following-sibling::*[1][self::note]"
|
@@ -71,8 +71,8 @@ module Asciidoctor
|
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
74
|
+
# include where definition list inside stem block
|
74
75
|
def formula_cleanup(x)
|
75
|
-
# include where definition list inside stem block
|
76
76
|
q = "//formula/following-sibling::*[1]"\
|
77
77
|
"[self::p and text() = 'where']"
|
78
78
|
x.xpath(q).each do |s|
|
@@ -97,8 +97,8 @@ module Asciidoctor
|
|
97
97
|
end
|
98
98
|
end
|
99
99
|
|
100
|
+
# include key definition list inside figure
|
100
101
|
def figure_dl_cleanup(xmldoc)
|
101
|
-
# include key definition list inside figure
|
102
102
|
q = "//figure/following-sibling::*"\
|
103
103
|
"[self::p and normalize-space() = 'Key']"
|
104
104
|
xmldoc.xpath(q).each do |s|
|
@@ -109,8 +109,8 @@ module Asciidoctor
|
|
109
109
|
end
|
110
110
|
end
|
111
111
|
|
112
|
+
# examples containing only figures become subfigures of figures
|
112
113
|
def subfigure_cleanup(xmldoc)
|
113
|
-
# examples containing only figures become subfigures of figures
|
114
114
|
nodes = xmldoc.xpath("//example/figure")
|
115
115
|
while !nodes.empty?
|
116
116
|
nodes[0].parent.name = "figure"
|
@@ -124,23 +124,29 @@ module Asciidoctor
|
|
124
124
|
subfigure_cleanup(xmldoc)
|
125
125
|
end
|
126
126
|
|
127
|
+
def table_footnote_renumber1(fn, i, seen)
|
128
|
+
if seen[fn.text] then outnum = seen[fn.text]
|
129
|
+
else
|
130
|
+
i += 1
|
131
|
+
outnum = i
|
132
|
+
seen[fn.text] = outnum
|
133
|
+
end
|
134
|
+
fn["reference"] = (outnum - 1 + "a".ord).chr
|
135
|
+
fn["table"] = true
|
136
|
+
[i, seen]
|
137
|
+
end
|
138
|
+
|
127
139
|
def table_footnote_renumber(xmldoc)
|
128
140
|
xmldoc.xpath("//table | //figure").each do |t|
|
129
|
-
seen
|
141
|
+
seen = {}
|
142
|
+
i = 0
|
130
143
|
t.xpath(".//fn").each do |fn|
|
131
|
-
|
132
|
-
else
|
133
|
-
i += 1
|
134
|
-
outnum = i
|
135
|
-
seen[fn.text] = outnum
|
136
|
-
end
|
137
|
-
fn["reference"] = (outnum - 1 + "a".ord).chr
|
138
|
-
fn["table"] = true
|
144
|
+
i, seen = table_footnote_renumber1(fn, i, seen)
|
139
145
|
end
|
140
146
|
end
|
141
147
|
end
|
142
148
|
|
143
|
-
def other_footnote_renumber1(fn, i, seen
|
149
|
+
def other_footnote_renumber1(fn, i, seen)
|
144
150
|
unless fn["table"]
|
145
151
|
if seen[fn.text] then outnum = seen[fn.text]
|
146
152
|
else
|
@@ -150,7 +156,7 @@ module Asciidoctor
|
|
150
156
|
end
|
151
157
|
fn["reference"] = outnum.to_s
|
152
158
|
end
|
153
|
-
[i, seen
|
159
|
+
[i, seen]
|
154
160
|
end
|
155
161
|
|
156
162
|
PRE_NORMREF_FOOTNOTES = "//foreword//fn | //introduction//fn |"\
|
@@ -168,15 +174,14 @@ module Asciidoctor
|
|
168
174
|
def other_footnote_renumber(xmldoc)
|
169
175
|
seen = {}
|
170
176
|
i = 0
|
171
|
-
outnum = 0
|
172
177
|
xmldoc.xpath(PRE_NORMREF_FOOTNOTES).each do |fn|
|
173
|
-
i, seen
|
178
|
+
i, seen = other_footnote_renumber1(fn, i, seen)
|
174
179
|
end
|
175
180
|
xmldoc.xpath(NORMREF_FOOTNOTES).each do |fn|
|
176
|
-
i, seen
|
181
|
+
i, seen = other_footnote_renumber1(fn, i, seen)
|
177
182
|
end
|
178
183
|
xmldoc.xpath(POST_NORMREF_FOOTNOTES).each do |fn|
|
179
|
-
i, seen
|
184
|
+
i, seen = other_footnote_renumber1(fn, i, seen)
|
180
185
|
end
|
181
186
|
end
|
182
187
|
|
@@ -199,14 +204,26 @@ module Asciidoctor
|
|
199
204
|
end
|
200
205
|
|
201
206
|
def obligations_cleanup(x)
|
207
|
+
obligations_cleanup_info(x)
|
208
|
+
obligations_cleanup_norm(x)
|
209
|
+
obligations_cleanup_inherit(x)
|
210
|
+
end
|
211
|
+
|
212
|
+
def obligations_cleanup_info(x)
|
202
213
|
(s = x.at("//foreword")) && s["obligation"] = "informative"
|
203
214
|
(s = x.at("//introduction")) && s["obligation"] = "informative"
|
215
|
+
x.xpath("//references").each { |r| r["obligation"] = "informative" }
|
216
|
+
end
|
217
|
+
|
218
|
+
def obligations_cleanup_norm(x)
|
204
219
|
(s = x.at("//clause[title = 'Scope']")) && s["obligation"] = "normative"
|
205
220
|
(s = x.at("//clause[title = 'Symbols and Abbreviated Terms']")) &&
|
206
221
|
s["obligation"] = "normative"
|
207
|
-
x.xpath("//references").each { |r| r["obligation"] = "informative" }
|
208
222
|
x.xpath("//terms").each { |r| r["obligation"] = "normative" }
|
209
223
|
x.xpath("//symbols-abbrevs").each { |r| r["obligation"] = "normative" }
|
224
|
+
end
|
225
|
+
|
226
|
+
def obligations_cleanup_inherit(x)
|
210
227
|
x.xpath("//annex | //clause").each do |r|
|
211
228
|
r["obligation"] = "normative" unless r["obligation"]
|
212
229
|
end
|
@@ -67,8 +67,8 @@ module Asciidoctor
|
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
|
+
# move ref before p
|
70
71
|
def ref_cleanup(xmldoc)
|
71
|
-
# move ref before p
|
72
72
|
xmldoc.xpath("//p/ref").each do |r|
|
73
73
|
parent = r.parent
|
74
74
|
parent.previous = r.remove
|
@@ -89,14 +89,27 @@ module Asciidoctor
|
|
89
89
|
ref
|
90
90
|
end
|
91
91
|
|
92
|
+
ISO_PUBLISHER_XPATH =
|
93
|
+
"./contributor[role/@type = 'publisher']/"\
|
94
|
+
"organization[abbreviation = 'ISO' or abbreviation = 'IEC' or "\
|
95
|
+
"name = 'International Organization for Standardization' or "\
|
96
|
+
"name = 'International Electrotechnical Commission']".freeze
|
97
|
+
|
98
|
+
def date_range(date)
|
99
|
+
from = date.at("./from")
|
100
|
+
to = date.at("./to")
|
101
|
+
ret = from.text
|
102
|
+
ret += "–#{to.text}" if to
|
103
|
+
ret
|
104
|
+
end
|
105
|
+
|
92
106
|
def reference_names(xmldoc)
|
93
107
|
xmldoc.xpath("//bibitem").each do |ref|
|
94
|
-
isopub = ref.at(
|
95
|
-
"organization[name = 'ISO' or name = 'IEC']")
|
108
|
+
isopub = ref.at(ISO_PUBLISHER_XPATH)
|
96
109
|
docid = ref.at("./docidentifier")
|
97
110
|
date = ref.at("./date[@type = 'published']")
|
98
111
|
reference = format_ref(docid.text, isopub)
|
99
|
-
reference += ": #{date
|
112
|
+
reference += ": #{date_range(date)}" if date && isopub
|
100
113
|
@anchors[ref["id"]] = { xref: reference }
|
101
114
|
end
|
102
115
|
end
|