metanorma-standoc 1.4.4 → 1.5.0
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/.rubocop.yml +1 -1
- data/lib/asciidoctor/standoc/base.rb +4 -3
- data/lib/asciidoctor/standoc/cleanup_boilerplate.rb +11 -24
- data/lib/asciidoctor/standoc/cleanup_section.rb +72 -5
- data/lib/asciidoctor/standoc/cleanup_terms.rb +10 -0
- data/lib/asciidoctor/standoc/converter.rb +0 -2
- data/lib/asciidoctor/standoc/isodoc.rng +12 -6
- data/lib/asciidoctor/standoc/ref.rb +24 -25
- data/lib/asciidoctor/standoc/section.rb +27 -25
- data/lib/asciidoctor/standoc/utils.rb +16 -0
- data/lib/metanorma/standoc/version.rb +1 -1
- data/metanorma-standoc.gemspec +1 -1
- data/spec/asciidoctor-standoc/base_spec.rb +1 -0
- data/spec/asciidoctor-standoc/blocks_spec.rb +12 -5
- data/spec/asciidoctor-standoc/cleanup_spec.rb +1216 -12
- data/spec/asciidoctor-standoc/inline_spec.rb +1 -1
- data/spec/asciidoctor-standoc/refs_dl_spec.rb +4 -4
- data/spec/asciidoctor-standoc/refs_spec.rb +16 -16
- data/spec/asciidoctor-standoc/section_spec.rb +42 -38
- data/spec/assets/i18n.yaml +17 -2
- data/spec/metanorma/processor_spec.rb +1 -2
- metadata +4 -8
- data/lib/asciidoctor-yaml/i18n-en.yaml +0 -20
- data/lib/asciidoctor-yaml/i18n-fr.yaml +0 -13
- data/lib/asciidoctor-yaml/i18n-zh-Hans.yaml +0 -15
- data/lib/asciidoctor/standoc/i18n.rb +0 -39
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 76c3b117ea592275339f9ee8103f17645d9675f45635abfbc8e5333fc512af1c
|
4
|
+
data.tar.gz: a345b19a2657f356225f2087e17a7dba7bd4720389cf44487892d3f1e1bc5345
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 630d1159cc78920d3bab3e73a2577b54d00bb966b0faa15166ff1af832656ab985e55f8fa830d40a2fbec96a8cf8555880f89f0e73d749dc73540e6cd8303469
|
7
|
+
data.tar.gz: f3c46604bb69f1e34eb8b2af182e198e99a6f2cae3bce808a9547e096b1852b4868c00a8522370a52c92ad5f263ab2f7e5ee348196fffbe1084ef1c666900080
|
data/.rubocop.yml
CHANGED
@@ -111,9 +111,10 @@ module Asciidoctor
|
|
111
111
|
@log = Asciidoctor::Standoc::Log.new
|
112
112
|
init_bib_caches(node)
|
113
113
|
init_iev_caches(node)
|
114
|
-
lang = (node.attr("language") || "en")
|
115
|
-
script = (node.attr("script") || "
|
116
|
-
|
114
|
+
@lang = (node.attr("language") || "en")
|
115
|
+
@script = (node.attr("script") || "Latn")
|
116
|
+
@isodoc = isodoc(@lang, @script, node.attr("i18nyaml"))
|
117
|
+
@i18n = @isodoc.i18n
|
117
118
|
end
|
118
119
|
|
119
120
|
def default_fonts(node)
|
@@ -2,25 +2,25 @@ module Asciidoctor
|
|
2
2
|
module Standoc
|
3
3
|
module Cleanup
|
4
4
|
def external_terms_boilerplate(sources)
|
5
|
-
|
6
|
-
@external_terms_boilerplate.gsub(/%/, sources || "???"),
|
5
|
+
@i18n.l10n(
|
6
|
+
@i18n.external_terms_boilerplate.gsub(/%/, sources || "???"),
|
7
7
|
@lang, @script)
|
8
8
|
end
|
9
9
|
|
10
10
|
def internal_external_terms_boilerplate(sources)
|
11
|
-
|
12
|
-
@internal_external_terms_boilerplate.gsub(/%/, sources || "??"),
|
11
|
+
@i18n.l10n(
|
12
|
+
@i18n.internal_external_terms_boilerplate.gsub(/%/, sources || "??"),
|
13
13
|
@lang, @script)
|
14
14
|
end
|
15
15
|
|
16
16
|
def term_defs_boilerplate(div, source, term, preface, isodoc)
|
17
|
-
div.next =
|
17
|
+
a = @i18n.term_def_boilerplate and div.next = a
|
18
18
|
source.each do |s|
|
19
19
|
@anchors[s["bibitemid"]] or
|
20
20
|
@log.add("Crossreferences", nil, "term source #{s['bibitemid']} not referenced")
|
21
21
|
end
|
22
22
|
if source.empty? && term.nil?
|
23
|
-
div.next = @no_terms_boilerplate
|
23
|
+
div.next = @i18n.no_terms_boilerplate
|
24
24
|
else
|
25
25
|
div.next = term_defs_boilerplate_cont(source, term, isodoc)
|
26
26
|
end
|
@@ -30,7 +30,7 @@ module Asciidoctor
|
|
30
30
|
sources = isodoc.sentence_join(src.map do |s|
|
31
31
|
%{<eref bibitemid="#{s['bibitemid']}"/>}
|
32
32
|
end)
|
33
|
-
if src.empty? then @internal_terms_boilerplate
|
33
|
+
if src.empty? then @i18n.internal_terms_boilerplate
|
34
34
|
elsif term.nil? then external_terms_boilerplate(sources)
|
35
35
|
else
|
36
36
|
internal_external_terms_boilerplate(sources)
|
@@ -42,7 +42,7 @@ module Asciidoctor
|
|
42
42
|
["reference", "bibitem"].include? e.name
|
43
43
|
end
|
44
44
|
f.at("./title").next =
|
45
|
-
"<p>#{(refs.empty? ? @norm_empty_pref : @norm_with_refs_pref)}</p>"
|
45
|
+
"<p>#{(refs.empty? ? @i18n.norm_empty_pref : @i18n.norm_with_refs_pref)}</p>"
|
46
46
|
end
|
47
47
|
|
48
48
|
TERM_CLAUSE = "//sections/terms | "\
|
@@ -54,13 +54,9 @@ module Asciidoctor
|
|
54
54
|
x = xmldoc.dup
|
55
55
|
x.root.add_namespace(nil, self.class::XML_NAMESPACE)
|
56
56
|
xml = Nokogiri::XML(x.to_xml)
|
57
|
-
|
58
|
-
@
|
59
|
-
@
|
60
|
-
conv.i18n_init(@lang, @script)
|
61
|
-
conv.metadata_init(@lang, @script, conv.labels)
|
62
|
-
conv.info(xml, nil)
|
63
|
-
conv
|
57
|
+
@isodoc ||= isodoc(@lang, @script)
|
58
|
+
@isodoc.info(xml, nil)
|
59
|
+
@isodoc
|
64
60
|
end
|
65
61
|
|
66
62
|
def boilerplate_cleanup(xmldoc)
|
@@ -83,15 +79,6 @@ module Asciidoctor
|
|
83
79
|
preface.previous = b
|
84
80
|
end
|
85
81
|
|
86
|
-
class EmptyAttr
|
87
|
-
def attr(_x)
|
88
|
-
nil
|
89
|
-
end
|
90
|
-
def attributes
|
91
|
-
{}
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
82
|
def boilerplate_file(xmldoc)
|
96
83
|
File.join(@libdir, "boilerplate.xml")
|
97
84
|
end
|
@@ -39,6 +39,7 @@ module Asciidoctor
|
|
39
39
|
dupabstract.traverse { |n| n.remove_attribute("id") }
|
40
40
|
dupabstract.remove_attribute("language")
|
41
41
|
dupabstract.remove_attribute("script")
|
42
|
+
dupabstract&.at("./title")&.remove
|
42
43
|
bibabstract.next = dupabstract
|
43
44
|
end
|
44
45
|
end
|
@@ -105,6 +106,7 @@ module Asciidoctor
|
|
105
106
|
def sections_cleanup(x)
|
106
107
|
sections_order_cleanup(x)
|
107
108
|
sections_level_cleanup(x)
|
109
|
+
sections_names_cleanup(x)
|
108
110
|
end
|
109
111
|
|
110
112
|
def obligations_cleanup(x)
|
@@ -118,15 +120,15 @@ module Asciidoctor
|
|
118
120
|
(s = x.at("//introduction")) && s["obligation"] = "informative"
|
119
121
|
(s = x.at("//acknowledgements")) && s["obligation"] = "informative"
|
120
122
|
x.xpath("//references").each { |r| r["obligation"] = "informative" }
|
121
|
-
x.xpath("//preface//clause").each
|
123
|
+
x.xpath("//preface//clause").each do |r|
|
124
|
+
r["obligation"] = "informative"
|
125
|
+
end
|
122
126
|
end
|
123
127
|
|
124
128
|
def obligations_cleanup_norm(x)
|
125
|
-
(s = x.at("//clause[
|
126
|
-
(s = x.at("//clause[title = 'Symbols and Abbreviated Terms']")) &&
|
127
|
-
s["obligation"] = "normative"
|
129
|
+
(s = x.at("//clause[@type = 'scope']")) && s["obligation"] = "normative"
|
128
130
|
x.xpath("//terms").each { |r| r["obligation"] = "normative" }
|
129
|
-
x.xpath("//
|
131
|
+
x.xpath("//definitions").each { |r| r["obligation"] = "normative" }
|
130
132
|
end
|
131
133
|
|
132
134
|
def obligations_cleanup_inherit(x)
|
@@ -149,6 +151,71 @@ module Asciidoctor
|
|
149
151
|
ins.previous = x.remove
|
150
152
|
end
|
151
153
|
end
|
154
|
+
|
155
|
+
def get_or_make_title(node)
|
156
|
+
unless node.at("./title")
|
157
|
+
if node.children.empty?
|
158
|
+
node << "<title/>"
|
159
|
+
else
|
160
|
+
node.children.first.previous = "<title/>"
|
161
|
+
end
|
162
|
+
end
|
163
|
+
node.at("./title")
|
164
|
+
end
|
165
|
+
|
166
|
+
def replace_title(doc, xpath, text, first = false)
|
167
|
+
return unless text
|
168
|
+
doc.xpath(xpath).each_with_index do |node, i|
|
169
|
+
next if first && !i.zero?
|
170
|
+
title = get_or_make_title(node)
|
171
|
+
fn = title.xpath("./fn")
|
172
|
+
fn.each { |n| n.remove }
|
173
|
+
title.content = text
|
174
|
+
fn.each { |n| title << n }
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
def sections_names_cleanup(x)
|
179
|
+
replace_title(x, "//clause[@type = 'scope']", @i18n&.scope)
|
180
|
+
replace_title(x, "//preface//abstract", @i18n&.abstract)
|
181
|
+
replace_title(x, "//foreword", @i18n&.foreword)
|
182
|
+
replace_title(x, "//introduction", @i18n&.introduction)
|
183
|
+
replace_title(x, "//acknowledgements", @i18n&.acknowledgements)
|
184
|
+
section_names_refs_cleanup(x)
|
185
|
+
section_names_terms_cleanup(x)
|
186
|
+
end
|
187
|
+
|
188
|
+
def section_names_refs_cleanup(x)
|
189
|
+
replace_title(x, "//references[@normative = 'true']",
|
190
|
+
@i18n&.normref, true)
|
191
|
+
replace_title(x, "//references[@normative = 'false']",
|
192
|
+
@i18n&.bibliography, true)
|
193
|
+
end
|
194
|
+
|
195
|
+
NO_SYMABBR = "[.//definitions[not(@type)]]"
|
196
|
+
SYMABBR = "[.//definitions[@type = 'symbols']"\
|
197
|
+
"[@type = 'abbreviated_terms']]".freeze
|
198
|
+
SYMnoABBR = "[.//definitions[@type = 'symbols']"\
|
199
|
+
"[not(@type = 'abbreviated_terms')]]".freeze
|
200
|
+
ABBRnoSYM = "[.//definitions[not(@type = 'symbols')]"\
|
201
|
+
"[@type = 'abbreviated_terms']]".freeze
|
202
|
+
|
203
|
+
def section_names_terms_cleanup(x)
|
204
|
+
replace_title(x, "//definitions[@type = 'symbols']", @i18n&.symbols)
|
205
|
+
replace_title(x, "//definitions[@type = 'abbreviated_terms']", @i18n&.abbrev)
|
206
|
+
replace_title(x, "//definitions[not(@type)]", @i18n&.symbolsabbrev)
|
207
|
+
replace_title(x, "//terms#{SYMnoABBR} | //clause[.//terms]#{SYMnoABBR}",
|
208
|
+
@i18n&.termsdefsymbols, true)
|
209
|
+
replace_title(x, "//terms#{ABBRnoSYM} | //clause[.//terms]#{ABBRnoSYM}",
|
210
|
+
@i18n&.termsdefabbrev, true)
|
211
|
+
replace_title(x, "//terms#{SYMABBR} | //clause[.//terms]#{SYMABBR}",
|
212
|
+
@i18n&.termsdefsymbolsabbrev, true)
|
213
|
+
replace_title(x, "//terms#{NO_SYMABBR} | //clause[.//terms]#{NO_SYMABBR}",
|
214
|
+
@i18n&.termsdefsymbolsabbrev, true)
|
215
|
+
replace_title(
|
216
|
+
x, "//terms[not(.//definitions)] | //clause[.//terms][not(.//definitions)]",
|
217
|
+
@i18n&.termsdef, true)
|
218
|
+
end
|
152
219
|
end
|
153
220
|
end
|
154
221
|
end
|
@@ -76,6 +76,15 @@ module Asciidoctor
|
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
79
|
+
def termnote_example_cleanup(xmldoc)
|
80
|
+
xmldoc.xpath("//termnote[not(ancestor::term)]").each do |x|
|
81
|
+
x.name = "note"
|
82
|
+
end
|
83
|
+
xmldoc.xpath("//termexample[not(ancestor::term)]").each do |x|
|
84
|
+
x.name = "note"
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
79
88
|
def termdef_cleanup(xmldoc)
|
80
89
|
termdef_from_termbase(xmldoc)
|
81
90
|
termdef_unnest_cleanup(xmldoc)
|
@@ -83,6 +92,7 @@ module Asciidoctor
|
|
83
92
|
termdomain_cleanup(xmldoc)
|
84
93
|
termdefinition_cleanup(xmldoc)
|
85
94
|
termdomain1_cleanup(xmldoc)
|
95
|
+
termnote_example_cleanup(xmldoc)
|
86
96
|
termdef_boilerplate_cleanup(xmldoc)
|
87
97
|
termdef_subclause_cleanup(xmldoc)
|
88
98
|
term_children_cleanup(xmldoc)
|
@@ -11,7 +11,6 @@ require "asciidoctor/standoc/table"
|
|
11
11
|
require "asciidoctor/standoc/validate"
|
12
12
|
require "asciidoctor/standoc/utils"
|
13
13
|
require "asciidoctor/standoc/cleanup"
|
14
|
-
require "asciidoctor/standoc/i18n"
|
15
14
|
require "asciidoctor/standoc/reqt"
|
16
15
|
require_relative "./macros.rb"
|
17
16
|
require_relative "./log.rb"
|
@@ -48,7 +47,6 @@ module Asciidoctor
|
|
48
47
|
include ::Asciidoctor::Standoc::Section
|
49
48
|
include ::Asciidoctor::Standoc::Table
|
50
49
|
include ::Asciidoctor::Standoc::Utils
|
51
|
-
include ::Asciidoctor::Standoc::I18n
|
52
50
|
include ::Asciidoctor::Standoc::Cleanup
|
53
51
|
include ::Asciidoctor::Standoc::Validate
|
54
52
|
|
@@ -922,6 +922,9 @@
|
|
922
922
|
<optional>
|
923
923
|
<attribute name="script"/>
|
924
924
|
</optional>
|
925
|
+
<optional>
|
926
|
+
<attribute name="type"/>
|
927
|
+
</optional>
|
925
928
|
<optional>
|
926
929
|
<attribute name="obligation">
|
927
930
|
<choice>
|
@@ -961,9 +964,6 @@
|
|
961
964
|
</define>
|
962
965
|
<define name="content-subsection">
|
963
966
|
<element name="clause">
|
964
|
-
<optional>
|
965
|
-
<attribute name="type"/>
|
966
|
-
</optional>
|
967
967
|
<ref name="Content-Section"/>
|
968
968
|
</element>
|
969
969
|
</define>
|
@@ -992,6 +992,9 @@
|
|
992
992
|
</choice>
|
993
993
|
</attribute>
|
994
994
|
</optional>
|
995
|
+
<optional>
|
996
|
+
<attribute name="type"/>
|
997
|
+
</optional>
|
995
998
|
<optional>
|
996
999
|
<ref name="section-title"/>
|
997
1000
|
</optional>
|
@@ -1011,9 +1014,6 @@
|
|
1011
1014
|
</define>
|
1012
1015
|
<define name="clause">
|
1013
1016
|
<element name="clause">
|
1014
|
-
<optional>
|
1015
|
-
<attribute name="type"/>
|
1016
|
-
</optional>
|
1017
1017
|
<ref name="Clause-Section"/>
|
1018
1018
|
</element>
|
1019
1019
|
</define>
|
@@ -1042,6 +1042,9 @@
|
|
1042
1042
|
</choice>
|
1043
1043
|
</attribute>
|
1044
1044
|
</optional>
|
1045
|
+
<optional>
|
1046
|
+
<attribute name="type"/>
|
1047
|
+
</optional>
|
1045
1048
|
<optional>
|
1046
1049
|
<ref name="section-title"/>
|
1047
1050
|
</optional>
|
@@ -1180,6 +1183,9 @@
|
|
1180
1183
|
<optional>
|
1181
1184
|
<attribute name="script"/>
|
1182
1185
|
</optional>
|
1186
|
+
<optional>
|
1187
|
+
<attribute name="type"/>
|
1188
|
+
</optional>
|
1183
1189
|
<optional>
|
1184
1190
|
<attribute name="obligation">
|
1185
1191
|
<choice>
|
@@ -61,10 +61,10 @@ module Asciidoctor
|
|
61
61
|
end
|
62
62
|
|
63
63
|
def isorefrender1(t, m, yr, allp = "")
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
64
|
+
t.title(**plaintxt) { |i| i << ref_normalise(m[:text]) }
|
65
|
+
docid(t, m[:usrlbl]) if m[:usrlbl]
|
66
|
+
docid(t, id_and_year(m[:code], yr) + allp)
|
67
|
+
docnumber(t, m[:code])
|
68
68
|
end
|
69
69
|
|
70
70
|
def isorefmatches(xml, m)
|
@@ -106,15 +106,16 @@ module Asciidoctor
|
|
106
106
|
|
107
107
|
def isorefmatches3(xml, m)
|
108
108
|
yr = norm_year(m[:year])
|
109
|
-
hasyr = m.names.include?("year") && yr != "--"
|
110
|
-
|
111
|
-
|
112
|
-
|
109
|
+
#hasyr = m.names.include?("year") && yr != "--"
|
110
|
+
hasyr = !yr.nil? && yr != "--"
|
111
|
+
#noyr = m.names.include?("year") && yr == "--"
|
112
|
+
ref = fetch_ref xml, m[:code], hasyr ? yr : nil, all_parts: true,
|
113
|
+
no_year: yr == "--", text: m[:text], usrlbl: m[:usrlbl]
|
113
114
|
return use_my_anchor(ref, m[:anchor]) if ref
|
114
115
|
|
115
116
|
xml.bibitem(**attr_code(ref_attributes(m))) do |t|
|
116
117
|
isorefrender1(t, m, yr, " (all parts)")
|
117
|
-
conditional_date(t, m,
|
118
|
+
conditional_date(t, m, yr == "--")
|
118
119
|
iso_publisher(t, m[:code])
|
119
120
|
m.names.include?("fn") && m[:fn] and
|
120
121
|
t.note(**plaintxt.merge(type: "ISO DATE")) { |p| p << "#{m[:fn]}" }
|
@@ -150,32 +151,30 @@ module Asciidoctor
|
|
150
151
|
"https://www.metanorma.com/author/iso/topics/markup/#bibliographies".freeze
|
151
152
|
|
152
153
|
def analyse_ref_nofetch(ret)
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
end
|
154
|
+
return ret unless m = /^nofetch\((?<id>.+)\)$/.match(ret[:id])
|
155
|
+
ret[:id] = m[:id]
|
156
|
+
ret[:nofetch] = true
|
157
157
|
ret
|
158
158
|
end
|
159
|
-
|
159
|
+
|
160
160
|
def analyse_ref_repo_path(ret)
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
161
|
+
return ret unless m =
|
162
|
+
/^(?<type>repo|path):\((?<key>[^,]+),(?<id>.+)\)$/.match(ret[:id])
|
163
|
+
ret[:id] = m[:id]
|
164
|
+
ret[:type] = m[:type]
|
165
|
+
ret[:key] = m[:key]
|
166
|
+
ret[:nofetch] = true
|
167
|
+
ret
|
168
168
|
end
|
169
169
|
|
170
170
|
def analyse_ref_numeric(ret)
|
171
|
-
|
172
|
-
|
173
|
-
end
|
171
|
+
return ret unless /^\d+$/.match(ret[:id])
|
172
|
+
ret[:numeric] = true
|
174
173
|
ret
|
175
174
|
end
|
176
175
|
|
177
176
|
# ref id = (usrlbl)code[:-]year
|
178
|
-
# code = nofetch(code) | (repo|path):(key,code) | \[? number \]? |
|
177
|
+
# code = nofetch(code) | (repo|path):(key,code) | \[? number \]? | ident
|
179
178
|
def analyse_ref_code(code)
|
180
179
|
ret = {id: code}
|
181
180
|
return ret if code.nil? || code.empty?
|
@@ -13,9 +13,13 @@ module Asciidoctor
|
|
13
13
|
@term_def
|
14
14
|
end
|
15
15
|
|
16
|
-
def
|
17
|
-
|
16
|
+
def sectiontype1(node)
|
17
|
+
node&.attr("heading")&.downcase ||
|
18
18
|
node.title.gsub(/<[^>]+>/, "").downcase
|
19
|
+
end
|
20
|
+
|
21
|
+
def sectiontype(node, level = true)
|
22
|
+
ret = sectiontype1(node)
|
19
23
|
ret1 = sectiontype_streamline(ret)
|
20
24
|
return ret1 if "symbols and abbreviated terms" == ret1
|
21
25
|
return nil unless !level || node.level == 1
|
@@ -61,16 +65,18 @@ module Asciidoctor
|
|
61
65
|
case sectiontype(node)
|
62
66
|
when "introduction" then introduction_parse(a, xml, node)
|
63
67
|
when "foreword" then foreword_parse(a, xml, node)
|
68
|
+
when "scope" then scope_parse(a, xml, node)
|
64
69
|
when "normative references" then norm_ref_parse(a, xml, node)
|
65
70
|
when "terms and definitions"
|
66
71
|
@term_def = true
|
67
72
|
term_def_parse(a, xml, node, true)
|
68
73
|
@term_def = false
|
69
74
|
when "symbols and abbreviated terms"
|
70
|
-
symbols_parse(a, xml, node)
|
75
|
+
symbols_parse(symbols_attrs(node, a), xml, node)
|
71
76
|
when "acknowledgements"
|
72
77
|
acknowledgements_parse(a, xml, node)
|
73
|
-
when "bibliography"
|
78
|
+
when "bibliography"
|
79
|
+
bibliography_parse(a, xml, node)
|
74
80
|
else
|
75
81
|
if @term_def then term_def_subclause_parse(a, xml, node)
|
76
82
|
elsif @definitions then symbols_parse(a, xml, node)
|
@@ -106,7 +112,7 @@ module Asciidoctor
|
|
106
112
|
def preamble(node)
|
107
113
|
noko do |xml|
|
108
114
|
xml.foreword **attr_code(section_attributes(node)) do |xml_abstract|
|
109
|
-
xml_abstract.title { |t| t << (node.blocks[0].title ||
|
115
|
+
xml_abstract.title { |t| t << (node.blocks[0].title || @i18n.foreword) }
|
110
116
|
content = node.content
|
111
117
|
xml_abstract << content
|
112
118
|
end
|
@@ -119,6 +125,10 @@ module Asciidoctor
|
|
119
125
|
end
|
120
126
|
end
|
121
127
|
|
128
|
+
def scope_parse(attrs, xml, node)
|
129
|
+
clause_parse(attrs.merge(type: "scope"), xml, node)
|
130
|
+
end
|
131
|
+
|
122
132
|
def clause_parse(attrs, xml, node)
|
123
133
|
attrs["inline-header".to_sym] = node.option? "inline-header"
|
124
134
|
attrs[:bibitem] = true if node.option? "bibitem"
|
@@ -145,6 +155,15 @@ module Asciidoctor
|
|
145
155
|
@definitions = true
|
146
156
|
end
|
147
157
|
|
158
|
+
def symbols_attrs(node, a)
|
159
|
+
case sectiontype1(node)
|
160
|
+
when "symbols" then a.merge(type: "symbols")
|
161
|
+
when "abbreviated terms", "abbreviations" then a.merge(type: "abbreviated_terms")
|
162
|
+
else
|
163
|
+
a
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
148
167
|
def symbols_parse(attr, xml, node)
|
149
168
|
node.role == "nonterm" and return nonterm_symbols_parse(attr, xml, node)
|
150
169
|
xml.definitions **attr_code(attr) do |xml_section|
|
@@ -159,9 +178,6 @@ module Asciidoctor
|
|
159
178
|
end
|
160
179
|
end
|
161
180
|
|
162
|
-
SYMBOLS_TITLES = ["symbols and abbreviated terms", "symbols",
|
163
|
-
"abbreviated terms"].freeze
|
164
|
-
|
165
181
|
def nonterm_term_def_subclause_parse(attrs, xml, node)
|
166
182
|
@term_def = false
|
167
183
|
clause_parse(attrs, xml, node)
|
@@ -190,23 +206,9 @@ module Asciidoctor
|
|
190
206
|
end
|
191
207
|
end
|
192
208
|
|
193
|
-
def term_def_title(toplevel, node)
|
194
|
-
return node.title unless toplevel
|
195
|
-
sub = node.find_by(context: :section) do |s|
|
196
|
-
SYMBOLS_TITLES.include? s.title.downcase
|
197
|
-
end
|
198
|
-
return "Terms and definitions" if sub.empty?
|
199
|
-
sym = /symbol/i.match(node.title)
|
200
|
-
abbrev = /abbreviat/i.match(node.title)
|
201
|
-
sym && abbrev and return "Terms, definitions, symbols and abbreviated terms"
|
202
|
-
sym and return "Terms, definitions and symbols"
|
203
|
-
abbrev and return "Terms, definitions and abbreviated terms"
|
204
|
-
"Terms, definitions, symbols and abbreviated terms"
|
205
|
-
end
|
206
|
-
|
207
209
|
def term_def_parse(attrs, xml, node, toplevel)
|
208
210
|
xml.terms **attr_code(attrs) do |section|
|
209
|
-
section.title { |t| t <<
|
211
|
+
section.title { |t| t << node.title }
|
210
212
|
(s = node.attr("source")) && s.split(/,/).each do |s1|
|
211
213
|
section.termdocsource(nil, **attr_code(bibitemid: s1))
|
212
214
|
end
|
@@ -216,7 +218,7 @@ module Asciidoctor
|
|
216
218
|
|
217
219
|
def introduction_parse(attrs, xml, node)
|
218
220
|
xml.introduction **attr_code(attrs) do |xml_section|
|
219
|
-
xml_section.title { |t| t <<
|
221
|
+
xml_section.title { |t| t << @i18n.introduction }
|
220
222
|
content = node.content
|
221
223
|
xml_section << content
|
222
224
|
end
|
@@ -232,7 +234,7 @@ module Asciidoctor
|
|
232
234
|
|
233
235
|
def acknowledgements_parse(attrs, xml, node)
|
234
236
|
xml.acknowledgements **attr_code(attrs) do |xml_section|
|
235
|
-
xml_section.title { |t| t << node.title ||
|
237
|
+
xml_section.title { |t| t << node.title || @i18n.acknowledgements }
|
236
238
|
content = node.content
|
237
239
|
xml_section << content
|
238
240
|
end
|