metanorma-standoc 1.3.29 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/lib/asciidoctor/standoc/base.rb +2 -25
- data/lib/asciidoctor/standoc/biblio.rng +13 -3
- data/lib/asciidoctor/standoc/blocks.rb +20 -17
- data/lib/asciidoctor/standoc/cleanup.rb +2 -0
- data/lib/asciidoctor/standoc/cleanup_block.rb +2 -2
- data/lib/asciidoctor/standoc/cleanup_section.rb +8 -125
- data/lib/asciidoctor/standoc/cleanup_terms.rb +134 -0
- data/lib/asciidoctor/standoc/datamodel/attributes_table_preprocessor.rb +57 -0
- data/lib/asciidoctor/standoc/datamodel/diagram_preprocessor.rb +102 -0
- data/lib/asciidoctor/standoc/datamodel/plantuml_renderer.rb +408 -0
- data/lib/asciidoctor/standoc/inline.rb +10 -5
- data/lib/asciidoctor/standoc/isodoc.rng +17 -1
- data/lib/asciidoctor/standoc/macros.rb +13 -8
- data/lib/asciidoctor/standoc/macros_yaml2text.rb +19 -13
- data/lib/asciidoctor/standoc/ref.rb +13 -56
- data/lib/asciidoctor/standoc/ref_sect.rb +124 -0
- data/lib/asciidoctor/standoc/section.rb +2 -46
- data/lib/asciidoctor/standoc/views/datamodel/model_representation.adoc.erb +30 -0
- data/lib/asciidoctor/standoc/views/datamodel/plantuml_representation.adoc.erb +20 -0
- data/lib/metanorma/standoc/version.rb +1 -1
- data/metanorma-standoc.gemspec +1 -1
- data/spec/asciidoctor-standoc/cleanup_spec.rb +51 -0
- data/spec/asciidoctor-standoc/datamodel/attributes_table_preprocessor_spec.rb +76 -0
- data/spec/asciidoctor-standoc/datamodel/diagram_preprocessor_spec.rb +72 -0
- data/spec/asciidoctor-standoc/inline_spec.rb +5 -1
- data/spec/asciidoctor-standoc/macros_spec.rb +50 -0
- data/spec/asciidoctor-standoc/macros_yaml2text_spec.rb +2 -1
- data/spec/asciidoctor-standoc/refs_spec.rb +0 -4
- data/spec/examples/datamodel/address_class_profile.adoc +4 -0
- data/spec/examples/datamodel/address_component_profile.adoc +4 -0
- data/spec/examples/datamodel/common_models_diagram.adoc +4 -0
- data/spec/examples/datamodel/models/models/AddressClassProfile.yml +90 -0
- data/spec/examples/datamodel/models/models/AddressComponentProfile.yml +63 -0
- data/spec/examples/datamodel/models/models/AddressComponentSpecification.yml +15 -0
- data/spec/examples/datamodel/models/models/AddressProfile.yml +36 -0
- data/spec/examples/datamodel/models/models/AttributeProfile.yml +32 -0
- data/spec/examples/datamodel/models/models/InterchangeAddressClassProfile.yml +79 -0
- data/spec/examples/datamodel/models/models/Localization copy.yml +23 -0
- data/spec/examples/datamodel/models/models/Localization.yml +23 -0
- data/spec/examples/datamodel/models/models/ProfileCompliantAddress.yml +36 -0
- data/spec/examples/datamodel/models/models/ProfileCompliantAddressComponent.yml +15 -0
- data/spec/examples/datamodel/models/models/Signature copy.yml +20 -0
- data/spec/examples/datamodel/models/models/Signature.yml +20 -0
- data/spec/examples/datamodel/models/models/TextDirectionCode copy.yml +16 -0
- data/spec/examples/datamodel/models/models/TextDirectionCode.yml +16 -0
- data/spec/examples/datamodel/models/models/Validity.yml +14 -0
- data/spec/examples/datamodel/models/models/iso19160-1/Address.yml +22 -0
- data/spec/examples/datamodel/models/models/iso19160-1/AddressComponent.yml +2 -0
- data/spec/examples/datamodel/models/style.uml.inc +37 -0
- data/spec/examples/datamodel/models/views/CommonModels.yml +9 -0
- data/spec/examples/datamodel/models/views/TopDown.yml +62 -0
- data/spec/examples/datamodel/top_down_diagram.adoc +4 -0
- data/spec/fixtures/macros_datamodel/address_class_profile.xml +149 -0
- data/spec/fixtures/macros_datamodel/address_component_profile.xml +71 -0
- data/spec/fixtures/macros_datamodel/common_models_diagram.xml +7 -0
- data/spec/fixtures/macros_datamodel/top_down_diagram.xml +7 -0
- data/spec/spec_helper.rb +13 -2
- data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +66 -66
- data/spec/vcr_cassettes/isobib_get_123.yml +36 -36
- data/spec/vcr_cassettes/isobib_get_123_2001.yml +16 -16
- data/spec/vcr_cassettes/isobib_get_124.yml +17 -17
- data/spec/vcr_cassettes/rfcbib_get_rfc8341.yml +8 -8
- data/spec/vcr_cassettes/separates_iev_citations_by_top_level_clause.yml +41 -38
- metadata +41 -4
@@ -32,12 +32,13 @@ module Asciidoctor
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def inline_anchor_xref(node)
|
35
|
-
|
36
|
-
|
37
|
-
|
35
|
+
m = /^(?<case>capital%|lowercase%)?(?<fn>fn(:\s*(?<text>.*))?)?$/.match node.text
|
36
|
+
casing = m.nil? ? nil : m[:case]&.sub(/%$/, "")
|
37
|
+
f = (m.nil? || m[:fn].nil?) ? "inline" : "footnote"
|
38
|
+
c = (!m.nil? && (!m[:fn].nil? || !m[:case].nil?)) ? m[:text] : node.text
|
38
39
|
t = node.target.gsub(/^#/, "").gsub(%r{(\.xml|\.adoc)(#.*$)}, "\\2")
|
39
40
|
noko do |xml|
|
40
|
-
xml.xref **attr_code(target: t, type: f) do |x|
|
41
|
+
xml.xref **attr_code(target: t, type: f, case: casing) do |x|
|
41
42
|
x << c
|
42
43
|
end
|
43
44
|
end.join
|
@@ -187,7 +188,11 @@ module Asciidoctor
|
|
187
188
|
return uri if /^data:/.match(uri)
|
188
189
|
types = MIME::Types.type_for(@localdir + uri)
|
189
190
|
type = types ? types.first.to_s : 'text/plain; charset="utf-8"'
|
190
|
-
|
191
|
+
# FIXME: nested uri path error(
|
192
|
+
# sources/plantuml/plantuml20200524-90467-1iqek5i.png ->
|
193
|
+
# sources/sources/plantuml/plantuml20200524-90467-1iqek5i.png)
|
194
|
+
path = File.file?(uri) ? uri : @localdir + uri
|
195
|
+
bin = File.open(path, 'rb', &:read)
|
191
196
|
data = Base64.strict_encode64(bin)
|
192
197
|
"data:#{type};base64,#{data}"
|
193
198
|
end
|
@@ -53,6 +53,14 @@
|
|
53
53
|
<optional>
|
54
54
|
<attribute name="alt"/>
|
55
55
|
</optional>
|
56
|
+
<optional>
|
57
|
+
<attribute name="case">
|
58
|
+
<choice>
|
59
|
+
<value>capital</value>
|
60
|
+
<value>lowercase</value>
|
61
|
+
</choice>
|
62
|
+
</attribute>
|
63
|
+
</optional>
|
56
64
|
<text/>
|
57
65
|
</element>
|
58
66
|
</define>
|
@@ -902,7 +910,15 @@
|
|
902
910
|
<attribute name="id">
|
903
911
|
<data type="ID"/>
|
904
912
|
</attribute>
|
905
|
-
<
|
913
|
+
<oneOrMore>
|
914
|
+
<choice>
|
915
|
+
<ref name="paragraph"/>
|
916
|
+
<ref name="ul"/>
|
917
|
+
<ref name="ol"/>
|
918
|
+
<ref name="dl"/>
|
919
|
+
<ref name="formula"/>
|
920
|
+
</choice>
|
921
|
+
</oneOrMore>
|
906
922
|
</element>
|
907
923
|
</define>
|
908
924
|
<define name="termexample">
|
@@ -1,8 +1,11 @@
|
|
1
1
|
require "asciidoctor/extensions"
|
2
2
|
require "fileutils"
|
3
3
|
require "uuidtools"
|
4
|
-
|
5
|
-
require_relative
|
4
|
+
require 'yaml'
|
5
|
+
require_relative './macros_plantuml.rb'
|
6
|
+
require_relative './datamodel/attributes_table_preprocessor.rb'
|
7
|
+
require_relative './datamodel/diagram_preprocessor.rb'
|
8
|
+
require_relative './macros_yaml2text.rb'
|
6
9
|
|
7
10
|
module Asciidoctor
|
8
11
|
module Standoc
|
@@ -97,23 +100,25 @@ module Asciidoctor
|
|
97
100
|
end
|
98
101
|
|
99
102
|
def supply_br(lines)
|
103
|
+
ignore = false
|
100
104
|
lines.each_with_index do |l, i|
|
105
|
+
/^(--+|====+|\|===|\.\.\.\.+|\*\*\*\*+|\+\+\+\++|\`\`\`\`+|____\+)$/.match(l) and
|
106
|
+
ignore = !ignore
|
101
107
|
next if l.empty? || l.match(/ \+$/)
|
108
|
+
next if /^\[.*\]$/.match(l)
|
109
|
+
next if ignore
|
102
110
|
next if i == lines.size - 1 || i < lines.size - 1 && lines[i+1].empty?
|
103
111
|
lines[i] += " +"
|
104
112
|
end
|
105
113
|
lines
|
106
114
|
end
|
107
115
|
|
108
|
-
def prevent_smart_quotes(m)
|
109
|
-
m.gsub(/'/, "'").gsub(/"/, """)
|
110
|
-
end
|
111
|
-
|
112
116
|
def process parent, reader, attrs
|
113
117
|
attrs['role'] = 'pseudocode'
|
114
|
-
lines = reader.lines.map { |m|
|
115
|
-
create_block(parent, :example, supply_br(lines),
|
118
|
+
lines = reader.lines.map { |m| init_indent(m) }
|
119
|
+
ret = create_block(parent, :example, supply_br(lines),
|
116
120
|
attrs, content_model: :compound)
|
121
|
+
ret
|
117
122
|
end
|
118
123
|
end
|
119
124
|
|
@@ -44,8 +44,8 @@ module Asciidoctor
|
|
44
44
|
end
|
45
45
|
|
46
46
|
class Yaml2TextPreprocessor < Asciidoctor::Extensions::Preprocessor
|
47
|
-
BLOCK_START_REGEXP = /\{(.+?)\.\*,(.+),(.+)\}
|
48
|
-
BLOCK_END_REGEXP = /\A\{[A-Z]+\}\z
|
47
|
+
BLOCK_START_REGEXP = /\{(.+?)\.\*,(.+),(.+)\}/
|
48
|
+
BLOCK_END_REGEXP = /\A\{[A-Z]+\}\z/
|
49
49
|
# search document for block `yaml2text`
|
50
50
|
# after that take template from block and read file into this template
|
51
51
|
# example:
|
@@ -107,35 +107,41 @@ module Asciidoctor
|
|
107
107
|
|
108
108
|
def parse_blocks_recursively(lines:,
|
109
109
|
attributes:,
|
110
|
-
context_name
|
111
|
-
parent_context: nil)
|
110
|
+
context_name:)
|
112
111
|
lines = lines.to_enum
|
113
112
|
result = []
|
114
113
|
loop do
|
115
114
|
line = lines.next
|
116
115
|
if line.match(BLOCK_START_REGEXP)
|
117
|
-
line.gsub!(BLOCK_START_REGEXP,
|
116
|
+
line.gsub!(BLOCK_START_REGEXP,
|
117
|
+
'<% \1.each&.with_index do |\2,index| %>')
|
118
118
|
end
|
119
119
|
|
120
|
-
if line.match(BLOCK_END_REGEXP)
|
120
|
+
if line.strip.match(BLOCK_END_REGEXP)
|
121
121
|
line.gsub!(BLOCK_END_REGEXP, '<% end %>')
|
122
122
|
end
|
123
|
-
line
|
123
|
+
line.gsub!(/{\s*if\s*([^}]+)}/, '<% if \1 %>')
|
124
|
+
line.gsub!(/{\s*?end\s*?}/, '<% end %>')
|
125
|
+
line = line
|
126
|
+
.gsub(/{(.+?[^}]*)}/, '<%= \1 %>')
|
127
|
+
.gsub(/[a-z\.]+\#/, 'index')
|
124
128
|
result.push(line)
|
125
129
|
end
|
126
130
|
result = parse_context_block(context_lines: result,
|
127
131
|
context_items: attributes,
|
128
|
-
context_name: context_name
|
129
|
-
parent_context: parent_context)
|
132
|
+
context_name: context_name)
|
130
133
|
result
|
131
134
|
end
|
132
135
|
|
133
136
|
def parse_context_block(context_lines:,
|
134
137
|
context_items:,
|
135
|
-
context_name
|
136
|
-
|
137
|
-
|
138
|
-
|
138
|
+
context_name:)
|
139
|
+
renderer = YamlContextRenderer
|
140
|
+
.new(
|
141
|
+
context_object: context_items,
|
142
|
+
context_name: context_name
|
143
|
+
)
|
144
|
+
renderer.render(context_lines.join("\n")).split("\n")
|
139
145
|
end
|
140
146
|
end
|
141
147
|
end
|
@@ -46,7 +46,15 @@ module Asciidoctor
|
|
46
46
|
["metanorma", mn_code(code)] :
|
47
47
|
@bibdb&.docid_type(code) || [nil, code]
|
48
48
|
code1.sub!(/^nofetch\((.+)\)$/, "\\1")
|
49
|
-
t.docidentifier
|
49
|
+
t.docidentifier **attr_code(type: type) do |d|
|
50
|
+
d << code1
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def docnumber(t, code)
|
55
|
+
t.docnumber do |d|
|
56
|
+
d << HTMLEntities.new.decode(code).sub(/^[^\d]*/, "")
|
57
|
+
end
|
50
58
|
end
|
51
59
|
|
52
60
|
def norm_year(yr)
|
@@ -62,7 +70,7 @@ module Asciidoctor
|
|
62
70
|
t.title(**plaintxt) { |i| i << ref_normalise(m[:text]) }
|
63
71
|
docid(t, m[:usrlbl]) if m[:usrlbl]
|
64
72
|
docid(t, id_and_year(m[:code], yr))
|
65
|
-
t
|
73
|
+
docnumber(t, m[:code])
|
66
74
|
yr and t.date **{ type: "published" } do |d|
|
67
75
|
set_date_range(d, yr)
|
68
76
|
end
|
@@ -79,7 +87,7 @@ module Asciidoctor
|
|
79
87
|
t.title(**plaintxt) { |i| i << ref_normalise(m[:text]) }
|
80
88
|
docid(t, m[:usrlbl]) if m[:usrlbl]
|
81
89
|
docid(t, id_and_year(m[:code], "--"))
|
82
|
-
t
|
90
|
+
docnumber(t, m[:code])
|
83
91
|
t.date **{ type: "published" } do |d|
|
84
92
|
d.on "--"
|
85
93
|
end
|
@@ -110,7 +118,7 @@ module Asciidoctor
|
|
110
118
|
t.title(**plaintxt) { |i| i << ref_normalise(m[:text]) }
|
111
119
|
docid(t, m[:usrlbl]) if m[:usrlbl]
|
112
120
|
docid(t, id_and_year(m[:code], yr) + " (all parts)")
|
113
|
-
t
|
121
|
+
docnumber(t, m[:code])
|
114
122
|
conditional_date(t, m, noyr)
|
115
123
|
iso_publisher(t, m[:code])
|
116
124
|
m.names.include?("fn") && m[:fn] and
|
@@ -121,20 +129,6 @@ module Asciidoctor
|
|
121
129
|
end
|
122
130
|
end
|
123
131
|
|
124
|
-
def fetch_ref(xml, code, year, **opts)
|
125
|
-
return nil if opts[:no_year]
|
126
|
-
code = code.sub(/^\([^)]+\)/, "")
|
127
|
-
hit = @bibdb&.fetch(code, year, opts)
|
128
|
-
return nil if hit.nil?
|
129
|
-
xml.parent.add_child(smart_render_xml(hit, code, opts[:title],
|
130
|
-
opts[:usrlbl]))
|
131
|
-
xml
|
132
|
-
rescue RelatonBib::RequestError
|
133
|
-
@log.add("Bibliography", nil, "Could not retrieve #{code}: "\
|
134
|
-
"no access to online site")
|
135
|
-
nil
|
136
|
-
end
|
137
|
-
|
138
132
|
def refitem_render(xml, m)
|
139
133
|
xml.bibitem **attr_code(id: m[:anchor]) do |t|
|
140
134
|
t.formattedref **{ format: "application/x-isodoc+xml" } do |i|
|
@@ -142,7 +136,7 @@ module Asciidoctor
|
|
142
136
|
end
|
143
137
|
docid(t, m[:usrlbl]) if m[:usrlbl]
|
144
138
|
docid(t, /^\d+$/.match(m[:code]) ? "[#{m[:code]}]" : m[:code])
|
145
|
-
t
|
139
|
+
docnumber(t, m[:code]) unless /^\d+$|^\(.+\)$/.match(m[:code])
|
146
140
|
end
|
147
141
|
end
|
148
142
|
|
@@ -214,46 +208,9 @@ module Asciidoctor
|
|
214
208
|
end.join
|
215
209
|
end
|
216
210
|
|
217
|
-
def global_ievcache_name
|
218
|
-
"#{Dir.home}/.iev/cache"
|
219
|
-
end
|
220
|
-
|
221
|
-
def local_ievcache_name(cachename)
|
222
|
-
return nil if cachename.nil?
|
223
|
-
cachename += "_iev" unless cachename.empty?
|
224
|
-
cachename = "iev" if cachename.empty?
|
225
|
-
"#{cachename}/cache"
|
226
|
-
end
|
227
|
-
|
228
211
|
def mn_code(code)
|
229
212
|
code.sub(/^\(/, "[").sub(/\).*$/, "]").sub(/^nofetch\((.+)\)$/, "\\1")
|
230
213
|
end
|
231
|
-
|
232
|
-
def emend_biblio(xml, code, title, usrlbl)
|
233
|
-
unless xml.at("/bibitem/docidentifier[not(@type = 'DOI')][text()]")
|
234
|
-
@log.add("Bibliography", nil,
|
235
|
-
"ERROR: No document identifier retrieved for #{code}")
|
236
|
-
xml.root << "<docidentifier>#{code}</docidentifier>"
|
237
|
-
end
|
238
|
-
unless xml.at("/bibitem/title[text()]")
|
239
|
-
@log.add("Bibliography", nil,
|
240
|
-
"ERROR: No title retrieved for #{code}")
|
241
|
-
xml.root << "<title>#{title || "(MISSING TITLE)"}</title>"
|
242
|
-
end
|
243
|
-
usrlbl and xml.at("/bibitem/docidentifier").next =
|
244
|
-
"<docidentifier type='metanorma'>#{mn_code(usrlbl)}</docidentifier>"
|
245
|
-
end
|
246
|
-
|
247
|
-
def smart_render_xml(x, code, title, usrlbl)
|
248
|
-
xstr = x.to_xml if x.respond_to? :to_xml
|
249
|
-
xml = Nokogiri::XML(xstr)
|
250
|
-
emend_biblio(xml, code, title, usrlbl)
|
251
|
-
xml.xpath("//date").each { |d| Utils::endash_date(d) }
|
252
|
-
xml.traverse do |n|
|
253
|
-
n.text? and n.replace(Utils::smartformat(n.text))
|
254
|
-
end
|
255
|
-
xml.to_xml.sub(/<\?[^>]+>/, "")
|
256
|
-
end
|
257
214
|
end
|
258
215
|
end
|
259
216
|
end
|
@@ -0,0 +1,124 @@
|
|
1
|
+
module Asciidoctor
|
2
|
+
module Standoc
|
3
|
+
module Section
|
4
|
+
def in_biblio?
|
5
|
+
@biblio
|
6
|
+
end
|
7
|
+
|
8
|
+
def in_norm_ref?
|
9
|
+
@norm_ref
|
10
|
+
end
|
11
|
+
|
12
|
+
def bibliography_parse(attrs, xml, node)
|
13
|
+
node.option? "bibitem" and return bibitem_parse(attrs, xml, node)
|
14
|
+
node.attr("style") == "bibliography" or
|
15
|
+
@log.add("AsciiDoc Input", node, "Section not marked up as [bibliography]!")
|
16
|
+
@biblio = true
|
17
|
+
xml.references **attr_code(attrs.merge(normative: false)) do |xml_section|
|
18
|
+
title = node.level == 1 ? "Bibliography" : node.title
|
19
|
+
xml_section.title { |t| t << title }
|
20
|
+
xml_section << node.content
|
21
|
+
end
|
22
|
+
@biblio = false
|
23
|
+
end
|
24
|
+
|
25
|
+
def bibitem_parse(attrs, xml, node)
|
26
|
+
norm_ref = @norm_ref
|
27
|
+
biblio = @biblio
|
28
|
+
@biblio = false
|
29
|
+
@norm_ref = false
|
30
|
+
clause_parse(attrs, xml, node)
|
31
|
+
@biblio = biblio
|
32
|
+
@norm_ref = norm_ref
|
33
|
+
end
|
34
|
+
|
35
|
+
def norm_ref_parse(attrs, xml, node)
|
36
|
+
node.option? "bibitem" and return bibitem_parse(attrs, xml, node)
|
37
|
+
node.attr("style") == "bibliography" or
|
38
|
+
@log.add("AsciiDoc Input", node, "Section not marked up as [bibliography]!")
|
39
|
+
@norm_ref = true
|
40
|
+
xml.references **attr_code(attrs.merge(normative: true)) do |xml_section|
|
41
|
+
xml_section.title { |t| t << "Normative References" }
|
42
|
+
xml_section << node.content
|
43
|
+
end
|
44
|
+
@norm_ref = false
|
45
|
+
end
|
46
|
+
|
47
|
+
def global_ievcache_name
|
48
|
+
"#{Dir.home}/.iev/cache"
|
49
|
+
end
|
50
|
+
|
51
|
+
def local_ievcache_name(cachename)
|
52
|
+
return nil if cachename.nil?
|
53
|
+
cachename += "_iev" unless cachename.empty?
|
54
|
+
cachename = "iev" if cachename.empty?
|
55
|
+
"#{cachename}/cache"
|
56
|
+
end
|
57
|
+
|
58
|
+
def fetch_ref(xml, code, year, **opts)
|
59
|
+
return nil if opts[:no_year]
|
60
|
+
code = code.sub(/^\([^)]+\)/, "")
|
61
|
+
hit = @bibdb&.fetch(code, year, opts)
|
62
|
+
return nil if hit.nil?
|
63
|
+
xml.parent.add_child(smart_render_xml(hit, code, opts[:title],
|
64
|
+
opts[:usrlbl]))
|
65
|
+
xml
|
66
|
+
rescue RelatonBib::RequestError
|
67
|
+
@log.add("Bibliography", nil, "Could not retrieve #{code}: "\
|
68
|
+
"no access to online site")
|
69
|
+
nil
|
70
|
+
end
|
71
|
+
|
72
|
+
def emend_biblio(xml, code, title, usrlbl)
|
73
|
+
unless xml.at("/bibitem/docidentifier[not(@type = 'DOI')][text()]")
|
74
|
+
@log.add("Bibliography", nil,
|
75
|
+
"ERROR: No document identifier retrieved for #{code}")
|
76
|
+
xml.root << "<docidentifier>#{code}</docidentifier>"
|
77
|
+
end
|
78
|
+
unless xml.at("/bibitem/title[text()]")
|
79
|
+
@log.add("Bibliography", nil,
|
80
|
+
"ERROR: No title retrieved for #{code}")
|
81
|
+
xml.root << "<title>#{title || "(MISSING TITLE)"}</title>"
|
82
|
+
end
|
83
|
+
usrlbl and xml.at("/bibitem/docidentifier").next =
|
84
|
+
"<docidentifier type='metanorma'>#{mn_code(usrlbl)}</docidentifier>"
|
85
|
+
end
|
86
|
+
|
87
|
+
def smart_render_xml(x, code, title, usrlbl)
|
88
|
+
xstr = x.to_xml if x.respond_to? :to_xml
|
89
|
+
xml = Nokogiri::XML(xstr)
|
90
|
+
emend_biblio(xml, code, title, usrlbl)
|
91
|
+
xml.xpath("//date").each { |d| Utils::endash_date(d) }
|
92
|
+
xml.traverse do |n|
|
93
|
+
n.text? and n.replace(Utils::smartformat(n.text))
|
94
|
+
end
|
95
|
+
xml.to_xml.sub(/<\?[^>]+>/, "")
|
96
|
+
end
|
97
|
+
|
98
|
+
def init_bib_caches(node)
|
99
|
+
return if @no_isobib
|
100
|
+
global = !@no_isobib_cache && !node.attr("local-cache-only")
|
101
|
+
local = node.attr("local-cache") || node.attr("local-cache-only")
|
102
|
+
local = nil if @no_isobib_cache
|
103
|
+
@bibdb = Relaton::DbCache.init_bib_caches(
|
104
|
+
local_cache: local,
|
105
|
+
flush_caches: node.attr("flush-caches"),
|
106
|
+
global_cache: global)
|
107
|
+
end
|
108
|
+
|
109
|
+
def init_iev_caches(node)
|
110
|
+
unless (@no_isobib_cache || @no_isobib)
|
111
|
+
node.attr("local-cache-only") or
|
112
|
+
@iev_globalname = global_ievcache_name
|
113
|
+
@iev_localname = local_ievcache_name(node.attr("local-cache") ||
|
114
|
+
node.attr("local-cache-only"))
|
115
|
+
if node.attr("flush-caches")
|
116
|
+
FileUtils.rm_f @iev_globalname unless @iev_globalname.nil?
|
117
|
+
FileUtils.rm_f @iev_localname unless @iev_localname.nil?
|
118
|
+
end
|
119
|
+
end
|
120
|
+
#@iev = Iev::Db.new(globalname, localname) unless @no_isobib
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require "htmlentities"
|
2
2
|
require "uri"
|
3
|
+
require_relative "ref_sect"
|
3
4
|
|
4
5
|
module Asciidoctor
|
5
6
|
module Standoc
|
@@ -8,18 +9,10 @@ module Asciidoctor
|
|
8
9
|
@term_def = false
|
9
10
|
@norm_ref = false
|
10
11
|
|
11
|
-
def in_biblio?
|
12
|
-
@biblio
|
13
|
-
end
|
14
|
-
|
15
12
|
def in_terms?
|
16
13
|
@term_def
|
17
14
|
end
|
18
15
|
|
19
|
-
def in_norm_ref?
|
20
|
-
@norm_ref
|
21
|
-
end
|
22
|
-
|
23
16
|
def sectiontype(node, level = true)
|
24
17
|
ret = node&.attr("heading")&.downcase ||
|
25
18
|
node.title.gsub(/<[^>]+>/, "").downcase
|
@@ -41,9 +34,7 @@ module Asciidoctor
|
|
41
34
|
"terms, definitions and abbreviated terms"
|
42
35
|
"terms and definitions"
|
43
36
|
when "symbols and abbreviated terms",
|
44
|
-
"symbols",
|
45
|
-
"abbreviated terms",
|
46
|
-
"abbreviations"
|
37
|
+
"symbols", "abbreviated terms", "abbreviations"
|
47
38
|
"symbols and abbreviated terms"
|
48
39
|
else
|
49
40
|
ret
|
@@ -148,19 +139,6 @@ module Asciidoctor
|
|
148
139
|
end
|
149
140
|
end
|
150
141
|
|
151
|
-
def bibliography_parse(attrs, xml, node)
|
152
|
-
node.option? "bibitem" and return bibitem_parse(attrs, xml, node)
|
153
|
-
node.attr("style") == "bibliography" or
|
154
|
-
@log.add("AsciiDoc Input", node, "Section not marked up as [bibliography]!")
|
155
|
-
@biblio = true
|
156
|
-
xml.references **attr_code(attrs.merge(normative: false)) do |xml_section|
|
157
|
-
title = node.level == 1 ? "Bibliography" : node.title
|
158
|
-
xml_section.title { |t| t << title }
|
159
|
-
xml_section << node.content
|
160
|
-
end
|
161
|
-
@biblio = false
|
162
|
-
end
|
163
|
-
|
164
142
|
def nonterm_symbols_parse(attrs, xml, node)
|
165
143
|
@definitions = false
|
166
144
|
clause_parse(attrs, xml, node)
|
@@ -236,28 +214,6 @@ module Asciidoctor
|
|
236
214
|
end
|
237
215
|
end
|
238
216
|
|
239
|
-
def bibitem_parse(attrs, xml, node)
|
240
|
-
norm_ref = @norm_ref
|
241
|
-
biblio = @biblio
|
242
|
-
@biblio = false
|
243
|
-
@norm_ref = false
|
244
|
-
clause_parse(attrs, xml, node)
|
245
|
-
@biblio = biblio
|
246
|
-
@norm_ref = norm_ref
|
247
|
-
end
|
248
|
-
|
249
|
-
def norm_ref_parse(attrs, xml, node)
|
250
|
-
node.option? "bibitem" and return bibitem_parse(attrs, xml, node)
|
251
|
-
node.attr("style") == "bibliography" or
|
252
|
-
@log.add("AsciiDoc Input", node, "Section not marked up as [bibliography]!")
|
253
|
-
@norm_ref = true
|
254
|
-
xml.references **attr_code(attrs.merge(normative: true)) do |xml_section|
|
255
|
-
xml_section.title { |t| t << "Normative References" }
|
256
|
-
xml_section << node.content
|
257
|
-
end
|
258
|
-
@norm_ref = false
|
259
|
-
end
|
260
|
-
|
261
217
|
def introduction_parse(attrs, xml, node)
|
262
218
|
xml.introduction **attr_code(attrs) do |xml_section|
|
263
219
|
xml_section.title { |t| t << "Introduction" }
|