metanorma-standoc 1.4.0 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/macos.yml +0 -7
- data/.github/workflows/ubuntu.yml +6 -11
- data/.github/workflows/windows.yml +0 -8
- data/.rubocop.yml +1 -1
- data/Rakefile +2 -0
- data/lib/asciidoctor/standoc/base.rb +28 -27
- data/lib/asciidoctor/standoc/biblio.rng +1 -1
- data/lib/asciidoctor/standoc/blocks.rb +25 -95
- data/lib/asciidoctor/standoc/blocks_notes.rb +89 -0
- data/lib/asciidoctor/standoc/cleanup.rb +10 -6
- data/lib/asciidoctor/standoc/cleanup_boilerplate.rb +11 -24
- data/lib/asciidoctor/standoc/cleanup_inline.rb +1 -1
- data/lib/asciidoctor/standoc/cleanup_ref.rb +47 -1
- data/lib/asciidoctor/standoc/cleanup_section.rb +72 -5
- data/lib/asciidoctor/standoc/cleanup_terms.rb +10 -0
- data/lib/asciidoctor/standoc/converter.rb +16 -2
- data/lib/asciidoctor/standoc/inline.rb +1 -1
- data/lib/asciidoctor/standoc/isodoc.rng +439 -6
- data/lib/asciidoctor/standoc/lists.rb +12 -12
- data/lib/asciidoctor/standoc/macros_yaml2text.rb +32 -15
- data/lib/asciidoctor/standoc/ref.rb +75 -34
- data/lib/asciidoctor/standoc/reqt.rb +11 -6
- data/lib/asciidoctor/standoc/reqt.rng +23 -0
- data/lib/asciidoctor/standoc/section.rb +27 -25
- data/lib/asciidoctor/standoc/table.rb +3 -2
- data/lib/asciidoctor/standoc/utils.rb +16 -0
- data/lib/asciidoctor/standoc/views/datamodel/model_representation.adoc.erb +1 -1
- data/lib/metanorma/standoc/processor.rb +5 -7
- data/lib/metanorma/standoc/version.rb +1 -1
- data/metanorma-standoc.gemspec +3 -2
- data/spec/asciidoctor-standoc/base_spec.rb +3 -2
- data/spec/asciidoctor-standoc/blocks_spec.rb +68 -32
- data/spec/asciidoctor-standoc/cleanup_spec.rb +1221 -17
- data/spec/asciidoctor-standoc/datamodel/attributes_table_preprocessor_spec.rb +35 -0
- data/spec/asciidoctor-standoc/inline_spec.rb +3 -3
- data/spec/asciidoctor-standoc/isobib_cache_spec.rb +4 -4
- data/spec/asciidoctor-standoc/lists_spec.rb +7 -5
- data/spec/asciidoctor-standoc/macros_spec.rb +4 -3
- data/spec/asciidoctor-standoc/refs_dl_spec.rb +8 -6
- data/spec/asciidoctor-standoc/refs_spec.rb +275 -30
- data/spec/asciidoctor-standoc/section_spec.rb +42 -38
- data/spec/asciidoctor-standoc/table_spec.rb +3 -3
- data/spec/asciidoctor-standoc/validate_spec.rb +56 -0
- data/spec/assets/{html.css → html.scss} +0 -0
- data/spec/assets/i18n.yaml +17 -2
- data/spec/assets/iso123.rxl +107 -0
- data/spec/assets/{word.css → word.scss} +0 -0
- data/spec/examples/datamodel/blank_definition_profile.adoc +4 -0
- data/spec/examples/datamodel/models/models/{Signature copy.yml → SignatureBlankDefinition.yml} +2 -2
- data/spec/fixtures/macros_datamodel/blank_definition_profile.xml +51 -0
- data/spec/metanorma/processor_spec.rb +5 -6
- data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +83 -83
- data/spec/vcr_cassettes/isobib_get_123.yml +19 -198
- data/spec/vcr_cassettes/isobib_get_123_1.yml +361 -0
- data/spec/vcr_cassettes/isobib_get_123_2001.yml +19 -19
- data/spec/vcr_cassettes/isobib_get_124.yml +21 -21
- data/spec/vcr_cassettes/rfcbib_get_rfc8341.yml +10 -10
- data/spec/vcr_cassettes/separates_iev_citations_by_top_level_clause.yml +42 -42
- metadata +32 -18
- 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
@@ -13,7 +13,7 @@ module Asciidoctor
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def ul_li(xml_ul, item)
|
16
|
-
xml_ul.li **
|
16
|
+
xml_ul.li **ul_li_attrs(item) do |xml_li|
|
17
17
|
if item.blocks?
|
18
18
|
xml_li.p(**id_attr(item)) { |t| t << item.text }
|
19
19
|
xml_li << item.content
|
@@ -23,11 +23,11 @@ module Asciidoctor
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
-
def
|
27
|
-
attr_code(id_attr(node))
|
26
|
+
def ul_attrs(node)
|
27
|
+
attr_code(id_attr(node).merge(keep_attrs(node)))
|
28
28
|
end
|
29
29
|
|
30
|
-
def
|
30
|
+
def ul_li_attrs(node)
|
31
31
|
attr_code(
|
32
32
|
uncheckedcheckbox: node.attr?("checkbox") ? !node.attr?("checked") : nil,
|
33
33
|
checkedcheckbox: node.attr?("checkbox") ? node.attr?("checked") : nil,
|
@@ -37,7 +37,7 @@ module Asciidoctor
|
|
37
37
|
def ulist(node)
|
38
38
|
return reference(node) if in_norm_ref? || in_biblio?
|
39
39
|
noko do |xml|
|
40
|
-
xml.ul **
|
40
|
+
xml.ul **ul_attrs(node) do |xml_ul|
|
41
41
|
node.items.each do |item|
|
42
42
|
ul_li(xml_ul, item)
|
43
43
|
end
|
@@ -53,14 +53,14 @@ module Asciidoctor
|
|
53
53
|
style
|
54
54
|
end
|
55
55
|
|
56
|
-
def
|
57
|
-
attr_code(id: Utils::anchor_or_uuid(node),
|
58
|
-
type: olist_style(node.style))
|
56
|
+
def ol_attrs(node)
|
57
|
+
attr_code(keep_attrs(node).merge(id: Utils::anchor_or_uuid(node),
|
58
|
+
type: olist_style(node.style)))
|
59
59
|
end
|
60
60
|
|
61
61
|
def olist(node)
|
62
62
|
noko do |xml|
|
63
|
-
xml.ol **
|
63
|
+
xml.ol **ol_attrs(node) do |xml_ol|
|
64
64
|
node.items.each { |item| li(xml_ol, item) }
|
65
65
|
end
|
66
66
|
end.join("\n")
|
@@ -86,13 +86,13 @@ module Asciidoctor
|
|
86
86
|
end
|
87
87
|
end
|
88
88
|
|
89
|
-
def
|
90
|
-
attr_code(id_attr(node))
|
89
|
+
def dl_attrs(node)
|
90
|
+
attr_code(id_attr(node).merge(keep_attrs(node)))
|
91
91
|
end
|
92
92
|
|
93
93
|
def dlist(node)
|
94
94
|
noko do |xml|
|
95
|
-
xml.dl **
|
95
|
+
xml.dl **dl_attrs(node) do |xml_dl|
|
96
96
|
node.items.each do |terms, dd|
|
97
97
|
dt(terms, xml_dl)
|
98
98
|
dd(dd, xml_dl)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'ostruct'
|
2
4
|
|
3
5
|
module Asciidoctor
|
@@ -61,7 +63,7 @@ module Asciidoctor
|
|
61
63
|
# - name: spaghetti
|
62
64
|
# desc: wheat noodles of 9mm diameter
|
63
65
|
# symbol: SPAG
|
64
|
-
# symbol_def: the situation is message like spaghetti at a kid's
|
66
|
+
# symbol_def: the situation is message like spaghetti at a kid's
|
65
67
|
#
|
66
68
|
# will produce:
|
67
69
|
# === spaghetti
|
@@ -77,19 +79,20 @@ module Asciidoctor
|
|
77
79
|
|
78
80
|
def processed_lines(document, input_lines)
|
79
81
|
result = []
|
82
|
+
current_macro_line_num = 0
|
80
83
|
loop do
|
81
84
|
line = input_lines.next
|
85
|
+
current_macro_line_num += 1
|
82
86
|
if yaml_block_match = line.match(/^\[yaml2text,(.+?),(.+?)\]/)
|
83
87
|
mark = input_lines.next
|
84
88
|
current_yaml_block = []
|
85
89
|
while (yaml_block_line = input_lines.next) != mark
|
86
90
|
current_yaml_block.push(yaml_block_line)
|
87
91
|
end
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
context_name: yaml_block_match[2]))
|
92
|
+
result.push(*read_yaml_and_parse_template(current_yaml_block,
|
93
|
+
document,
|
94
|
+
yaml_block_match,
|
95
|
+
current_macro_line_num))
|
93
96
|
else
|
94
97
|
result.push(line)
|
95
98
|
end
|
@@ -97,9 +100,23 @@ module Asciidoctor
|
|
97
100
|
result
|
98
101
|
end
|
99
102
|
|
103
|
+
def read_yaml_and_parse_template(current_yaml_block, document, yaml_block_match, current_macro_line_num)
|
104
|
+
content = nested_open_struct_from_yaml(yaml_block_match[1], document)
|
105
|
+
parse_blocks_recursively(lines: current_yaml_block,
|
106
|
+
attributes: content,
|
107
|
+
context_name: yaml_block_match[2])
|
108
|
+
rescue StandardError => exception
|
109
|
+
document
|
110
|
+
.logger
|
111
|
+
.warn("Failed to parse yaml2text block on line #{current_macro_line_num}: #{exception.message}")
|
112
|
+
[]
|
113
|
+
end
|
114
|
+
|
100
115
|
def nested_open_struct_from_yaml(file_path, document)
|
101
116
|
docfile_directory = File.dirname(document.attributes['docfile'] || '.')
|
102
|
-
yaml_file_path = document
|
117
|
+
yaml_file_path = document
|
118
|
+
.path_resolver
|
119
|
+
.system_path(file_path, docfile_directory)
|
103
120
|
content = YAML.safe_load(File.read(yaml_file_path))
|
104
121
|
# Load content as json, then parse with JSON as nested open_struct
|
105
122
|
JSON.parse(content.to_json, object_class: YamlBlockStruct)
|
@@ -112,19 +129,19 @@ module Asciidoctor
|
|
112
129
|
result = []
|
113
130
|
loop do
|
114
131
|
line = lines.next
|
115
|
-
if line.match(BLOCK_START_REGEXP)
|
132
|
+
if line.match?(BLOCK_START_REGEXP)
|
116
133
|
line.gsub!(BLOCK_START_REGEXP,
|
117
134
|
'<% \1.each&.with_index do |\2,index| %>')
|
118
135
|
end
|
119
136
|
|
120
|
-
if line.strip.match(BLOCK_END_REGEXP)
|
137
|
+
if line.strip.match?(BLOCK_END_REGEXP)
|
121
138
|
line.gsub!(BLOCK_END_REGEXP, '<% end %>')
|
122
139
|
end
|
123
140
|
line.gsub!(/{\s*if\s*([^}]+)}/, '<% if \1 %>')
|
124
141
|
line.gsub!(/{\s*?end\s*?}/, '<% end %>')
|
125
142
|
line = line
|
126
|
-
|
127
|
-
|
143
|
+
.gsub(/{(.+?[^}]*)}/, '<%= \1 %>')
|
144
|
+
.gsub(/[a-z\.]+\#/, 'index')
|
128
145
|
result.push(line)
|
129
146
|
end
|
130
147
|
result = parse_context_block(context_lines: result,
|
@@ -137,10 +154,10 @@ module Asciidoctor
|
|
137
154
|
context_items:,
|
138
155
|
context_name:)
|
139
156
|
renderer = YamlContextRenderer
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
157
|
+
.new(
|
158
|
+
context_object: context_items,
|
159
|
+
context_name: context_name
|
160
|
+
)
|
144
161
|
renderer.render(context_lines.join("\n")).split("\n")
|
145
162
|
end
|
146
163
|
end
|
@@ -37,8 +37,7 @@ module Asciidoctor
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def id_and_year(id, year)
|
40
|
-
|
41
|
-
"#{id}:#{year}"
|
40
|
+
year ? "#{id}:#{year}" : id
|
42
41
|
end
|
43
42
|
|
44
43
|
def docid(t, code)
|
@@ -58,8 +57,14 @@ module Asciidoctor
|
|
58
57
|
end
|
59
58
|
|
60
59
|
def norm_year(yr)
|
61
|
-
|
62
|
-
|
60
|
+
/^\&\#821[12];$/.match(yr) ? "--" : yr
|
61
|
+
end
|
62
|
+
|
63
|
+
def isorefrender1(t, m, yr, allp = "")
|
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])
|
63
68
|
end
|
64
69
|
|
65
70
|
def isorefmatches(xml, m)
|
@@ -67,10 +72,7 @@ module Asciidoctor
|
|
67
72
|
ref = fetch_ref xml, m[:code], yr, title: m[:text], usrlbl: m[:usrlbl]
|
68
73
|
return use_my_anchor(ref, m[:anchor]) if ref
|
69
74
|
xml.bibitem **attr_code(ref_attributes(m)) do |t|
|
70
|
-
t
|
71
|
-
docid(t, m[:usrlbl]) if m[:usrlbl]
|
72
|
-
docid(t, id_and_year(m[:code], yr))
|
73
|
-
docnumber(t, m[:code])
|
75
|
+
isorefrender1(t, m, yr)
|
74
76
|
yr and t.date **{ type: "published" } do |d|
|
75
77
|
set_date_range(d, yr)
|
76
78
|
end
|
@@ -82,61 +84,65 @@ module Asciidoctor
|
|
82
84
|
ref = fetch_ref xml, m[:code], nil, no_year: true, note: m[:fn],
|
83
85
|
title: m[:text], usrlbl: m[:usrlbl]
|
84
86
|
return use_my_anchor(ref, m[:anchor]) if ref
|
85
|
-
|
86
87
|
xml.bibitem **attr_code(ref_attributes(m)) do |t|
|
87
|
-
t
|
88
|
-
docid(t, m[:usrlbl]) if m[:usrlbl]
|
89
|
-
docid(t, id_and_year(m[:code], "--"))
|
90
|
-
docnumber(t, m[:code])
|
88
|
+
isorefrender1(t, m, "--")
|
91
89
|
t.date **{ type: "published" } do |d|
|
92
90
|
d.on "--"
|
93
91
|
end
|
94
92
|
iso_publisher(t, m[:code])
|
95
|
-
m[:fn].nil? or t.note(**plaintxt
|
93
|
+
m[:fn].nil? or t.note(**plaintxt.merge(type: "ISO DATE")) do |p|
|
94
|
+
p << "#{m[:fn]}"
|
95
|
+
end
|
96
96
|
end
|
97
97
|
end
|
98
98
|
|
99
99
|
def conditional_date(t, m, noyr)
|
100
100
|
m.names.include?("year") and !m[:year].nil? and
|
101
101
|
t.date(**{ type: "published" }) do |d|
|
102
|
-
|
103
|
-
else
|
102
|
+
noyr and d.on "--" or
|
104
103
|
set_date_range(d, norm_year(m[:year]))
|
105
|
-
end
|
106
104
|
end
|
107
105
|
end
|
108
106
|
|
109
107
|
def isorefmatches3(xml, m)
|
110
108
|
yr = norm_year(m[:year])
|
111
|
-
hasyr = m.names.include?("year") && yr != "--"
|
112
|
-
|
113
|
-
|
114
|
-
|
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]
|
115
114
|
return use_my_anchor(ref, m[:anchor]) if ref
|
116
115
|
|
117
116
|
xml.bibitem(**attr_code(ref_attributes(m))) do |t|
|
118
|
-
t
|
119
|
-
|
120
|
-
docid(t, id_and_year(m[:code], yr) + " (all parts)")
|
121
|
-
docnumber(t, m[:code])
|
122
|
-
conditional_date(t, m, noyr)
|
117
|
+
isorefrender1(t, m, yr, " (all parts)")
|
118
|
+
conditional_date(t, m, yr == "--")
|
123
119
|
iso_publisher(t, m[:code])
|
124
120
|
m.names.include?("fn") && m[:fn] and
|
125
|
-
t.note(**plaintxt) { |p| p << "
|
121
|
+
t.note(**plaintxt.merge(type: "ISO DATE")) { |p| p << "#{m[:fn]}" }
|
126
122
|
t.extent **{ type: 'part' } do |e|
|
127
123
|
e.referenceFrom "all"
|
128
124
|
end
|
129
125
|
end
|
130
126
|
end
|
131
127
|
|
132
|
-
def
|
128
|
+
def refitem_render1(m, code, t)
|
129
|
+
if code[:type] == "path"
|
130
|
+
t.uri code[:key].sub(/\.[a-zA-Z0-9]+$/, ""), **{ type: "URI" }
|
131
|
+
t.uri code[:key].sub(/\.[a-zA-Z0-9]+$/, ""), **{ type: "citation" }
|
132
|
+
end
|
133
|
+
docid(t, m[:usrlbl]) if m[:usrlbl]
|
134
|
+
docid(t, /^\d+$/.match(code[:id]) ? "[#{code[:id]}]" : code[:id])
|
135
|
+
code[:type] == "repo" and
|
136
|
+
t.docidentifier code[:key], **{ type: "repository" }
|
137
|
+
end
|
138
|
+
|
139
|
+
def refitem_render(xml, m, code)
|
133
140
|
xml.bibitem **attr_code(id: m[:anchor]) do |t|
|
134
141
|
t.formattedref **{ format: "application/x-isodoc+xml" } do |i|
|
135
142
|
i << ref_normalise_no_format(m[:text])
|
136
143
|
end
|
137
|
-
|
138
|
-
|
139
|
-
docnumber(t, m[:code]) unless /^\d+$|^\(.+\)$/.match(m[:code])
|
144
|
+
refitem_render1(m, code, t)
|
145
|
+
docnumber(t, code[:id]) unless /^\d+$|^\(.+\)$/.match(code[:id])
|
140
146
|
end
|
141
147
|
end
|
142
148
|
|
@@ -144,19 +150,54 @@ module Asciidoctor
|
|
144
150
|
"https://www.metanorma.com/author/topics/document-format/bibliography/ , "\
|
145
151
|
"https://www.metanorma.com/author/iso/topics/markup/#bibliographies".freeze
|
146
152
|
|
153
|
+
def analyse_ref_nofetch(ret)
|
154
|
+
return ret unless m = /^nofetch\((?<id>.+)\)$/.match(ret[:id])
|
155
|
+
ret[:id] = m[:id]
|
156
|
+
ret[:nofetch] = true
|
157
|
+
ret
|
158
|
+
end
|
159
|
+
|
160
|
+
def analyse_ref_repo_path(ret)
|
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
|
+
end
|
169
|
+
|
170
|
+
def analyse_ref_numeric(ret)
|
171
|
+
return ret unless /^\d+$/.match(ret[:id])
|
172
|
+
ret[:numeric] = true
|
173
|
+
ret
|
174
|
+
end
|
175
|
+
|
176
|
+
# ref id = (usrlbl)code[:-]year
|
177
|
+
# code = nofetch(code) | (repo|path):(key,code) | \[? number \]? | ident
|
178
|
+
def analyse_ref_code(code)
|
179
|
+
ret = {id: code}
|
180
|
+
return ret if code.nil? || code.empty?
|
181
|
+
ret = analyse_ref_nofetch(ret)
|
182
|
+
ret = analyse_ref_repo_path(ret)
|
183
|
+
ret = analyse_ref_numeric(ret)
|
184
|
+
ret
|
185
|
+
end
|
186
|
+
|
147
187
|
# TODO: alternative where only title is available
|
148
188
|
def refitem(xml, item, node)
|
149
189
|
unless m = NON_ISO_REF.match(item)
|
150
190
|
@log.add("AsciiDoc Input", node, "#{MALFORMED_REF}: #{item}")
|
151
191
|
return
|
152
192
|
end
|
153
|
-
|
154
|
-
|
193
|
+
code = analyse_ref_code(m[:code])
|
194
|
+
unless code[:id] && code[:numeric] || code[:nofetch]
|
195
|
+
ref = fetch_ref xml, code[:id],
|
155
196
|
m.names.include?("year") ? m[:year] : nil, title: m[:text],
|
156
197
|
usrlbl: m[:usrlbl]
|
157
198
|
return use_my_anchor(ref, m[:anchor]) if ref
|
158
199
|
end
|
159
|
-
refitem_render(xml, m)
|
200
|
+
refitem_render(xml, m, code)
|
160
201
|
end
|
161
202
|
|
162
203
|
def ref_normalise(ref)
|
@@ -6,11 +6,15 @@ require "base64"
|
|
6
6
|
module Asciidoctor
|
7
7
|
module Standoc
|
8
8
|
module Blocks
|
9
|
+
def reqt_subpart_attrs(node)
|
10
|
+
attr_code(keep_attrs(node).merge(exclude: node.option?("exclude"),
|
11
|
+
type: node.attr("type")))
|
12
|
+
end
|
13
|
+
|
9
14
|
def requirement_subpart(node)
|
10
15
|
name = node.role || node.attr("style")
|
11
16
|
noko do |xml|
|
12
|
-
xml.send name, **
|
13
|
-
type: node.attr("type")) do |o|
|
17
|
+
xml.send name, **reqt_subpart_attrs(node) do |o|
|
14
18
|
o << node.content
|
15
19
|
end
|
16
20
|
end
|
@@ -35,22 +39,23 @@ module Asciidoctor
|
|
35
39
|
end
|
36
40
|
end
|
37
41
|
|
38
|
-
def
|
39
|
-
|
42
|
+
def reqt_attrs(node)
|
43
|
+
attr_code(keep_attrs(node).merge(id_unnum_attrs(node)).merge(
|
40
44
|
id: Utils::anchor_or_uuid(node),
|
41
45
|
unnumbered: node.option?("unnumbered") ? "true" : nil,
|
46
|
+
number: node.attr("number"),
|
42
47
|
subsequence: node.attr("subsequence"),
|
43
48
|
obligation: node.attr("obligation"),
|
44
49
|
filename: node.attr("filename"),
|
45
50
|
type: node.attr("type"),
|
46
51
|
model: node.attr("model"),
|
47
|
-
|
52
|
+
))
|
48
53
|
end
|
49
54
|
|
50
55
|
def requirement(node, obligation)
|
51
56
|
classif = node.attr("classification")
|
52
57
|
noko do |xml|
|
53
|
-
xml.send obligation, **
|
58
|
+
xml.send obligation, **reqt_attrs(node) do |ex|
|
54
59
|
node.title and ex.title { |t| t << node.title }
|
55
60
|
node.attr("label") and ex.label { |l| l << node.attr("label") }
|
56
61
|
node.attr("subject") and ex.subject { |s| s << node.attr("subject") }
|
@@ -30,9 +30,22 @@
|
|
30
30
|
<data type="boolean"/>
|
31
31
|
</attribute>
|
32
32
|
</optional>
|
33
|
+
<optional>
|
34
|
+
<attribute name="number"/>
|
35
|
+
</optional>
|
33
36
|
<optional>
|
34
37
|
<attribute name="subsequence"/>
|
35
38
|
</optional>
|
39
|
+
<optional>
|
40
|
+
<attribute name="keep-with-next">
|
41
|
+
<data type="boolean"/>
|
42
|
+
</attribute>
|
43
|
+
</optional>
|
44
|
+
<optional>
|
45
|
+
<attribute name="keep-lines-together">
|
46
|
+
<data type="boolean"/>
|
47
|
+
</attribute>
|
48
|
+
</optional>
|
36
49
|
<attribute name="id">
|
37
50
|
<data type="ID"/>
|
38
51
|
</attribute>
|
@@ -141,6 +154,16 @@
|
|
141
154
|
<data type="boolean"/>
|
142
155
|
</attribute>
|
143
156
|
</optional>
|
157
|
+
<optional>
|
158
|
+
<attribute name="keep-with-next">
|
159
|
+
<data type="boolean"/>
|
160
|
+
</attribute>
|
161
|
+
</optional>
|
162
|
+
<optional>
|
163
|
+
<attribute name="keep-lines-together">
|
164
|
+
<data type="boolean"/>
|
165
|
+
</attribute>
|
166
|
+
</optional>
|
144
167
|
<oneOrMore>
|
145
168
|
<ref name="BasicBlock"/>
|
146
169
|
</oneOrMore>
|
@@ -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
|