metanorma-standoc 1.6.1 → 1.7.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/rake.yml +66 -0
- data/README.adoc +1 -3
- data/lib/asciidoctor/standoc/base.rb +8 -16
- data/lib/asciidoctor/standoc/basicdoc.rng +50 -3
- data/lib/asciidoctor/standoc/cleanup.rb +52 -4
- data/lib/asciidoctor/standoc/cleanup_block.rb +41 -4
- data/lib/asciidoctor/standoc/cleanup_boilerplate.rb +47 -20
- data/lib/asciidoctor/standoc/cleanup_footnotes.rb +14 -0
- data/lib/asciidoctor/standoc/cleanup_inline.rb +9 -3
- data/lib/asciidoctor/standoc/cleanup_ref.rb +17 -24
- data/lib/asciidoctor/standoc/cleanup_terms.rb +4 -6
- data/lib/asciidoctor/standoc/converter.rb +71 -1
- data/lib/asciidoctor/standoc/front.rb +6 -0
- data/lib/asciidoctor/standoc/front_contributor.rb +8 -4
- data/lib/asciidoctor/standoc/inline.rb +6 -5
- data/lib/asciidoctor/standoc/isodoc.rng +36 -43
- data/lib/asciidoctor/standoc/lists.rb +4 -2
- data/lib/asciidoctor/standoc/macros.rb +55 -59
- data/lib/asciidoctor/standoc/macros_terms.rb +82 -0
- data/lib/asciidoctor/standoc/ref.rb +19 -25
- data/lib/asciidoctor/standoc/ref_sect.rb +4 -3
- data/lib/asciidoctor/standoc/section.rb +21 -20
- data/lib/asciidoctor/standoc/table.rb +12 -0
- data/lib/asciidoctor/standoc/term_lookup_cleanup.rb +86 -0
- data/lib/asciidoctor/standoc/utils.rb +2 -0
- data/lib/metanorma/standoc/version.rb +1 -1
- data/metanorma-standoc.gemspec +5 -3
- data/spec/asciidoctor-standoc/base_spec.rb +14 -4
- data/spec/asciidoctor-standoc/blocks_spec.rb +14 -9
- data/spec/asciidoctor-standoc/cleanup_sections_spec.rb +1519 -0
- data/spec/asciidoctor-standoc/cleanup_spec.rb +416 -1554
- data/spec/asciidoctor-standoc/converter_spec.rb +8 -0
- data/spec/asciidoctor-standoc/inline_spec.rb +2 -5
- data/spec/asciidoctor-standoc/isobib_cache_spec.rb +16 -9
- data/spec/asciidoctor-standoc/lists_spec.rb +10 -1
- data/spec/asciidoctor-standoc/macros_lutaml_spec.rb +80 -0
- data/spec/asciidoctor-standoc/macros_plantuml_spec.rb +307 -0
- data/spec/asciidoctor-standoc/macros_spec.rb +408 -169
- data/spec/asciidoctor-standoc/refs_dl_spec.rb +6 -6
- data/spec/asciidoctor-standoc/refs_spec.rb +112 -65
- data/spec/asciidoctor-standoc/section_spec.rb +17 -12
- data/spec/asciidoctor-standoc/table_spec.rb +86 -0
- data/spec/asciidoctor-standoc/validate_spec.rb +26 -0
- data/spec/fixtures/diagram_definitions.lutaml +22 -0
- data/spec/fixtures/test.exp +121 -0
- data/spec/spec_helper.rb +33 -0
- data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +59 -243
- data/spec/vcr_cassettes/isobib_get_123.yml +12 -12
- data/spec/vcr_cassettes/isobib_get_123_1.yml +27 -119
- data/spec/vcr_cassettes/isobib_get_123_1_fr.yml +35 -35
- data/spec/vcr_cassettes/isobib_get_123_2001.yml +14 -60
- data/spec/vcr_cassettes/isobib_get_124.yml +11 -57
- data/spec/vcr_cassettes/rfcbib_get_rfc8341.yml +8 -8
- data/spec/vcr_cassettes/separates_iev_citations_by_top_level_clause.yml +281 -157
- metadata +45 -11
- data/.github/workflows/macos.yml +0 -41
- data/.github/workflows/ubuntu.yml +0 -45
- data/.github/workflows/windows.yml +0 -43
@@ -55,7 +55,7 @@ module Asciidoctor
|
|
55
55
|
|
56
56
|
def ol_attrs(node)
|
57
57
|
attr_code(keep_attrs(node).merge(id: Utils::anchor_or_uuid(node),
|
58
|
-
|
58
|
+
type: olist_style(node.style)))
|
59
59
|
end
|
60
60
|
|
61
61
|
def olist(node)
|
@@ -87,7 +87,9 @@ module Asciidoctor
|
|
87
87
|
end
|
88
88
|
|
89
89
|
def dl_attrs(node)
|
90
|
-
attr_code(
|
90
|
+
attr_code(keep_attrs(node).
|
91
|
+
merge(id: Utils::anchor_or_uuid(node),
|
92
|
+
key: node.option?("key") ? "true" : nil))
|
91
93
|
end
|
92
94
|
|
93
95
|
def dlist(node)
|
@@ -3,87 +3,57 @@ require "fileutils"
|
|
3
3
|
require "uuidtools"
|
4
4
|
require "yaml"
|
5
5
|
require_relative "./macros_plantuml.rb"
|
6
|
+
require_relative "./macros_terms.rb"
|
6
7
|
require_relative "./datamodel/attributes_table_preprocessor.rb"
|
7
8
|
require_relative "./datamodel/diagram_preprocessor.rb"
|
8
9
|
require "metanorma-plugin-datastruct"
|
10
|
+
require "metanorma-plugin-lutaml"
|
9
11
|
|
10
12
|
module Asciidoctor
|
11
13
|
module Standoc
|
12
|
-
class
|
14
|
+
class InheritInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
13
15
|
use_dsl
|
14
|
-
named :
|
16
|
+
named :inherit
|
15
17
|
parse_content_as :text
|
16
18
|
using_format :short
|
17
19
|
|
18
20
|
def process(parent, _target, attrs)
|
19
21
|
out = Asciidoctor::Inline.new(parent, :quoted, attrs["text"]).convert
|
20
|
-
%{<
|
22
|
+
%{<inherit>#{out}</inherit>}
|
21
23
|
end
|
22
24
|
end
|
23
25
|
|
24
|
-
class
|
26
|
+
class IndexXrefInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
25
27
|
use_dsl
|
26
|
-
named :
|
27
|
-
parse_content_as :text
|
28
|
-
using_format :short
|
28
|
+
named :index
|
29
29
|
|
30
|
-
def
|
31
|
-
|
32
|
-
|
30
|
+
def preprocess_attrs(attrs)
|
31
|
+
return unless attrs.size > 1 && attrs.size < 5
|
32
|
+
ret = { primary: attrs[1], target: attrs[attrs.size] }
|
33
|
+
ret[:secondary] = attrs[2] if attrs.size > 2
|
34
|
+
ret[:tertiary] = attrs[3] if attrs.size > 3
|
35
|
+
ret
|
33
36
|
end
|
34
|
-
end
|
35
|
-
|
36
|
-
class DomainTermInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
37
|
-
use_dsl
|
38
|
-
named :domain
|
39
|
-
parse_content_as :text
|
40
|
-
using_format :short
|
41
37
|
|
42
|
-
def process(
|
43
|
-
|
44
|
-
|
38
|
+
def process(_parent, target, attr)
|
39
|
+
args = preprocess_attrs(attr) or return
|
40
|
+
ret = "<index-xref also='#{target == 'also'}'><primary>#{args[:primary]}</primary>"
|
41
|
+
ret += "<secondary>#{args[:secondary]}</secondary>" if args[:secondary]
|
42
|
+
ret += "<tertiary>#{args[:tertiary]}</tertiary>" if args[:tertiary]
|
43
|
+
ret + "<target>#{args[:target]}</target></index-xref>"
|
45
44
|
end
|
46
45
|
end
|
47
46
|
|
48
|
-
class
|
47
|
+
class IndexRangeInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
49
48
|
use_dsl
|
50
|
-
named
|
49
|
+
named "index-range".to_sym
|
51
50
|
parse_content_as :text
|
52
|
-
using_format :short
|
53
|
-
|
54
|
-
def process(parent, _target, attrs)
|
55
|
-
out = Asciidoctor::Inline.new(parent, :quoted, attrs["text"]).convert
|
56
|
-
%{<inherit>#{out}</inherit>}
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
class ConceptInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
61
|
-
use_dsl
|
62
|
-
named :concept
|
63
|
-
name_positional_attributes "id", "word", "term"
|
64
|
-
# match %r{concept:(?<target>[^\[]*)\[(?<content>|.*?[^\\])\]$}
|
65
|
-
match /\{\{(?<content>|.*?[^\\])\}\}/
|
66
|
-
using_format :short
|
67
|
-
|
68
|
-
# deal with locality attrs and their disruption of positional attrs
|
69
|
-
def preprocess_attrs(attrs)
|
70
|
-
attrs.delete("term") if attrs["term"] && !attrs["word"]
|
71
|
-
attrs.delete(3) if attrs[3] == attrs["term"]
|
72
|
-
a = attrs.keys.reject { |k| k.is_a?(String) || [1, 2].include?(k) }
|
73
|
-
attrs["word"] ||= attrs[a[0]] if !a.empty?
|
74
|
-
attrs["term"] ||= attrs[a[1]] if a.length > 1
|
75
|
-
attrs
|
76
|
-
end
|
77
51
|
|
78
|
-
def process(parent,
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
text = [localities, attr["word"]].reject{ |k| k.nil? || k.empty? }.
|
84
|
-
join(",")
|
85
|
-
out = Asciidoctor::Inline.new(parent, :quoted, text).convert
|
86
|
-
%{<concept key="#{attr['id']}" term="#{attr['term']}">#{out}</concept>}
|
52
|
+
def process(parent, target, attr)
|
53
|
+
text = attr["text"]
|
54
|
+
text = "((#{text}))" unless /^\(\(.+\)\)$/.match(text)
|
55
|
+
out = parent.sub_macros(text)
|
56
|
+
out.sub(/<index>/, "<index to='#{target}'>")
|
87
57
|
end
|
88
58
|
end
|
89
59
|
|
@@ -134,7 +104,7 @@ module Asciidoctor
|
|
134
104
|
if (attributes.size == 1) && attributes.key?("text")
|
135
105
|
rt = attributes["text"]
|
136
106
|
elsif (attributes.size == 2) && attributes.key?(1) &&
|
137
|
-
|
107
|
+
attributes.key?("rpbegin")
|
138
108
|
# for example, html5ruby:楽聖少女[がくせいしょうじょ]
|
139
109
|
rt = attributes[1] || ""
|
140
110
|
else
|
@@ -157,7 +127,7 @@ module Asciidoctor
|
|
157
127
|
attrs["name"] = "todo"
|
158
128
|
attrs["caption"] = "TODO"
|
159
129
|
create_block parent, :admonition, reader.lines, attrs,
|
160
|
-
|
130
|
+
content_model: :compound
|
161
131
|
end
|
162
132
|
end
|
163
133
|
|
@@ -170,7 +140,7 @@ module Asciidoctor
|
|
170
140
|
para.set_attr("caption", "TODO")
|
171
141
|
para.lines[0].sub!(/^TODO: /, "")
|
172
142
|
todo = Block.new parent, :admonition, attributes: para.attributes,
|
173
|
-
|
143
|
+
source: para.lines, content_model: :compound
|
174
144
|
parent.blocks[parent.blocks.index(para)] = todo
|
175
145
|
end
|
176
146
|
end
|
@@ -186,5 +156,31 @@ module Asciidoctor
|
|
186
156
|
%{<autonumber type=#{target}>#{out}</autonumber>}
|
187
157
|
end
|
188
158
|
end
|
159
|
+
|
160
|
+
class VariantInlineMacro < Extensions::InlineMacroProcessor
|
161
|
+
use_dsl
|
162
|
+
named :lang
|
163
|
+
parse_content_as :text
|
164
|
+
|
165
|
+
def process(parent, target, attrs)
|
166
|
+
/^(?<lang>[^-]*)(-(?<script>.*))?$/ =~ target
|
167
|
+
out = Asciidoctor::Inline.new(parent, :quoted, attrs["text"]).convert
|
168
|
+
script ?
|
169
|
+
%{<variant lang=#{lang} script=#{script}>#{out}</variant>} :
|
170
|
+
%{<variant lang=#{lang}>#{out}</variant>}
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
class FootnoteBlockInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
175
|
+
use_dsl
|
176
|
+
named :footnoteblock
|
177
|
+
parse_content_as :text
|
178
|
+
using_format :short
|
179
|
+
|
180
|
+
def process(parent, _target, attrs)
|
181
|
+
out = Asciidoctor::Inline.new(parent, :quoted, attrs["text"]).convert
|
182
|
+
%{<footnoteblock>#{out}</footnoteblock>}
|
183
|
+
end
|
184
|
+
end
|
189
185
|
end
|
190
186
|
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
module Asciidoctor
|
2
|
+
module Standoc
|
3
|
+
class AltTermInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
4
|
+
use_dsl
|
5
|
+
named :alt
|
6
|
+
parse_content_as :text
|
7
|
+
using_format :short
|
8
|
+
|
9
|
+
def process(parent, _target, attrs)
|
10
|
+
out = Asciidoctor::Inline.new(parent, :quoted, attrs["text"]).convert
|
11
|
+
%{<admitted>#{out}</admitted>}
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class DeprecatedTermInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
16
|
+
use_dsl
|
17
|
+
named :deprecated
|
18
|
+
parse_content_as :text
|
19
|
+
using_format :short
|
20
|
+
|
21
|
+
def process(parent, _target, attrs)
|
22
|
+
out = Asciidoctor::Inline.new(parent, :quoted, attrs["text"]).convert
|
23
|
+
%{<deprecates>#{out}</deprecates>}
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
class DomainTermInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
28
|
+
use_dsl
|
29
|
+
named :domain
|
30
|
+
parse_content_as :text
|
31
|
+
using_format :short
|
32
|
+
|
33
|
+
def process(parent, _target, attrs)
|
34
|
+
out = Asciidoctor::Inline.new(parent, :quoted, attrs["text"]).convert
|
35
|
+
%{<domain>#{out}</domain>}
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# Macro to transform `term[X,Y]` into em, termxref xml
|
40
|
+
class TermRefInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
41
|
+
use_dsl
|
42
|
+
named :term
|
43
|
+
name_positional_attributes 'name', 'termxref'
|
44
|
+
using_format :short
|
45
|
+
|
46
|
+
def process(_parent, _target, attrs)
|
47
|
+
termref = attrs['termxref'] || attrs['name']
|
48
|
+
"<em>#{attrs['name']}</em> (<termxref>#{termref}</termxref>)"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
class ConceptInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
53
|
+
use_dsl
|
54
|
+
named :concept
|
55
|
+
name_positional_attributes "id", "word", "term"
|
56
|
+
# match %r{concept:(?<target>[^\[]*)\[(?<content>|.*?[^\\])\]$}
|
57
|
+
match /\{\{(?<content>|.*?[^\\])\}\}/
|
58
|
+
using_format :short
|
59
|
+
|
60
|
+
# deal with locality attrs and their disruption of positional attrs
|
61
|
+
def preprocess_attrs(attrs)
|
62
|
+
attrs.delete("term") if attrs["term"] && !attrs["word"]
|
63
|
+
attrs.delete(3) if attrs[3] == attrs["term"]
|
64
|
+
a = attrs.keys.reject { |k| k.is_a?(String) || [1, 2].include?(k) }
|
65
|
+
attrs["word"] ||= attrs[a[0]] if !a.empty?
|
66
|
+
attrs["term"] ||= attrs[a[1]] if a.length > 1
|
67
|
+
attrs
|
68
|
+
end
|
69
|
+
|
70
|
+
def process(parent, _target, attr)
|
71
|
+
attr = preprocess_attrs(attr)
|
72
|
+
localities = attr.keys.reject { |k| %w(id word term).include? k }.
|
73
|
+
reject { |k| k.is_a? Numeric }.
|
74
|
+
map { |k| "#{k}=#{attr[k]}" }.join(",")
|
75
|
+
text = [localities, attr["word"]].reject{ |k| k.nil? || k.empty? }.
|
76
|
+
join(",")
|
77
|
+
out = Asciidoctor::Inline.new(parent, :quoted, text).convert
|
78
|
+
%{<concept key="#{attr['id']}" term="#{attr['term']}">#{out}</concept>}
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Asciidoctor
|
2
2
|
module Standoc
|
3
|
-
module
|
3
|
+
module Refs
|
4
4
|
def iso_publisher(t, code)
|
5
5
|
code.sub(/ .*$/, "").split(/\//).each do |abbrev|
|
6
6
|
t.contributor do |c|
|
@@ -56,7 +56,9 @@ module Asciidoctor
|
|
56
56
|
end
|
57
57
|
|
58
58
|
def norm_year(yr)
|
59
|
-
/^\&\#821[12];$/.match(yr)
|
59
|
+
/^\&\#821[12];$/.match(yr) and return "--"
|
60
|
+
/^\d\d\d\d-\d\d\d\d$/.match(yr) and return yr
|
61
|
+
yr&.sub(/(?<=[0-9])-.*$/, "")
|
60
62
|
end
|
61
63
|
|
62
64
|
def isorefrender1(t, m, yr, allp = "")
|
@@ -68,8 +70,7 @@ module Asciidoctor
|
|
68
70
|
|
69
71
|
def isorefmatches(xml, m)
|
70
72
|
yr = norm_year(m[:year])
|
71
|
-
ref = fetch_ref xml, m[:code], yr, title: m[:text], usrlbl: m[:usrlbl],
|
72
|
-
lang: (@lang || :all)
|
73
|
+
ref = fetch_ref xml, m[:code], yr, title: m[:text], usrlbl: m[:usrlbl], lang: (@lang || :all)
|
73
74
|
return use_my_anchor(ref, m[:anchor]) if ref
|
74
75
|
xml.bibitem **attr_code(ref_attributes(m)) do |t|
|
75
76
|
isorefrender1(t, m, yr)
|
@@ -94,7 +95,7 @@ module Asciidoctor
|
|
94
95
|
d.on "--"
|
95
96
|
end
|
96
97
|
iso_publisher(t, m[:code])
|
97
|
-
m[:fn].nil? or t.note(**plaintxt.merge(type: "
|
98
|
+
m[:fn].nil? or t.note(**plaintxt.merge(type: "Unpublished-Status")) do |p|
|
98
99
|
p << "#{m[:fn]}"
|
99
100
|
end
|
100
101
|
end
|
@@ -103,8 +104,7 @@ module Asciidoctor
|
|
103
104
|
def conditional_date(t, m, noyr)
|
104
105
|
m.names.include?("year") and !m[:year].nil? and
|
105
106
|
t.date(**{ type: "published" }) do |d|
|
106
|
-
noyr and d.on "--" or
|
107
|
-
set_date_range(d, norm_year(m[:year]))
|
107
|
+
noyr and d.on "--" or set_date_range(d, norm_year(m[:year]))
|
108
108
|
end
|
109
109
|
end
|
110
110
|
|
@@ -112,8 +112,7 @@ module Asciidoctor
|
|
112
112
|
yr = norm_year(m[:year])
|
113
113
|
hasyr = !yr.nil? && yr != "--"
|
114
114
|
ref = fetch_ref xml, m[:code], hasyr ? yr : nil, all_parts: true,
|
115
|
-
no_year: yr == "--", text: m[:text], usrlbl: m[:usrlbl],
|
116
|
-
lang: (@lang || :all)
|
115
|
+
no_year: yr == "--", text: m[:text], usrlbl: m[:usrlbl], lang: (@lang || :all)
|
117
116
|
return use_my_anchor(ref, m[:anchor]) if ref
|
118
117
|
isorefmatches3_1(xml, m, yr, hasyr, ref)
|
119
118
|
end
|
@@ -124,7 +123,7 @@ module Asciidoctor
|
|
124
123
|
conditional_date(t, m, yr == "--")
|
125
124
|
iso_publisher(t, m[:code])
|
126
125
|
m.names.include?("fn") && m[:fn] and
|
127
|
-
t.note(**plaintxt.merge(type: "
|
126
|
+
t.note(**plaintxt.merge(type: "Unpublished-Status")) { |p| p << "#{m[:fn]}" }
|
128
127
|
t.extent **{ type: 'part' } do |e|
|
129
128
|
e.referenceFrom "all"
|
130
129
|
end
|
@@ -138,8 +137,7 @@ module Asciidoctor
|
|
138
137
|
end
|
139
138
|
docid(t, m[:usrlbl]) if m[:usrlbl]
|
140
139
|
docid(t, /^\d+$/.match(code[:id]) ? "[#{code[:id]}]" : code[:id])
|
141
|
-
code[:type] == "repo" and
|
142
|
-
t.docidentifier code[:key], **{ type: "repository" }
|
140
|
+
code[:type] == "repo" and t.docidentifier code[:key], **{ type: "repository" }
|
143
141
|
end
|
144
142
|
|
145
143
|
def refitem_render(xml, m, code)
|
@@ -153,9 +151,8 @@ module Asciidoctor
|
|
153
151
|
end
|
154
152
|
|
155
153
|
MALFORMED_REF = "no anchor on reference, markup may be malformed: see "\
|
156
|
-
"https://www.metanorma.com/author/topics/document-format/"\
|
157
|
-
"
|
158
|
-
"#bibliographies".freeze
|
154
|
+
"https://www.metanorma.com/author/topics/document-format/bibliography/ , "\
|
155
|
+
"https://www.metanorma.com/author/iso/topics/markup/#bibliographies".freeze
|
159
156
|
|
160
157
|
def analyse_ref_nofetch(ret)
|
161
158
|
return ret unless m = /^nofetch\((?<id>.+)\)$/.match(ret[:id])
|
@@ -163,9 +160,9 @@ module Asciidoctor
|
|
163
160
|
end
|
164
161
|
|
165
162
|
def analyse_ref_repo_path(ret)
|
166
|
-
return ret unless m =
|
167
|
-
|
168
|
-
ret.merge(id:
|
163
|
+
return ret unless m = /^(?<type>repo|path):\((?<key>[^,]+),?(?<id>.*)\)$/.match(ret[:id])
|
164
|
+
id = m[:id].empty? ? m[:key].sub(%r{^[^/]+/}, "") : m[:id]
|
165
|
+
ret.merge(id: id, type: m[:type], key: m[:key], nofetch: true)
|
169
166
|
end
|
170
167
|
|
171
168
|
def analyse_ref_numeric(ret)
|
@@ -191,8 +188,7 @@ module Asciidoctor
|
|
191
188
|
def refitem1(xml, item, m)
|
192
189
|
code = analyse_ref_code(m[:code])
|
193
190
|
unless code[:id] && code[:numeric] || code[:nofetch]
|
194
|
-
ref = fetch_ref xml, code[:id],
|
195
|
-
m.names.include?("year") ? m[:year] : nil, title: m[:text],
|
191
|
+
ref = fetch_ref xml, code[:id], m.names.include?("year") ? m[:year] : nil, title: m[:text],
|
196
192
|
usrlbl: m[:usrlbl], lang: (@lang || :all)
|
197
193
|
return use_my_anchor(ref, m[:anchor]) if ref
|
198
194
|
end
|
@@ -209,8 +205,7 @@ module Asciidoctor
|
|
209
205
|
|
210
206
|
ISO_REF = %r{^<ref\sid="(?<anchor>[^"]+)">
|
211
207
|
\[(?<usrlbl>\([^)]+\))?(?<code>(ISO|IEC)[^0-9]*\s[0-9-]+|IEV)
|
212
|
-
(:(?<year>[0-9][0-9-]+))?\]</ref>,?\s*
|
213
|
-
(?<text>.*)$}xm
|
208
|
+
(:(?<year>[0-9][0-9-]+))?\]</ref>,?\s*(?<text>.*)$}xm
|
214
209
|
|
215
210
|
ISO_REF_NO_YEAR = %r{^<ref\sid="(?<anchor>[^"]+)">
|
216
211
|
\[(?<usrlbl>\([^)]+\))?(?<code>(ISO|IEC)[^0-9]*\s[0-9-]+):
|
@@ -225,7 +220,7 @@ module Asciidoctor
|
|
225
220
|
|
226
221
|
NON_ISO_REF = %r{^<ref\sid="(?<anchor>[^"]+)">
|
227
222
|
\[(?<usrlbl>\([^)]+\))?(?<code>[^\]]+?)
|
228
|
-
([:-](?<year>(19|20)[0-9][0-9]))?\]</ref>,?\s*(?<text>.*)$}xm
|
223
|
+
([:-](?<year>(19|20)[0-9][0-9][0-9-]*))?\]</ref>,?\s*(?<text>.*)$}xm
|
229
224
|
|
230
225
|
def reference1_matches(item)
|
231
226
|
matched = ISO_REF.match item
|
@@ -236,8 +231,7 @@ module Asciidoctor
|
|
236
231
|
|
237
232
|
def reference1(node, item, xml)
|
238
233
|
matched, matched2, matched3 = reference1_matches(item)
|
239
|
-
if matched3.nil? && matched2.nil? && matched.nil?
|
240
|
-
refitem(xml, item, node)
|
234
|
+
if matched3.nil? && matched2.nil? && matched.nil? then refitem(xml, item, node)
|
241
235
|
elsif !matched.nil? then isorefmatches(xml, matched)
|
242
236
|
elsif !matched2.nil? then isorefmatches2(xml, matched2)
|
243
237
|
elsif !matched3.nil? then isorefmatches3(xml, matched3)
|
@@ -21,8 +21,8 @@ module Asciidoctor
|
|
21
21
|
@log.add("AsciiDoc Input", node, "Section not marked up as [bibliography]!")
|
22
22
|
@biblio = true
|
23
23
|
xml.references **attr_code(attrs.merge(normative: false)) do |xml_section|
|
24
|
-
title = node.level == 1 ? "Bibliography" : node.title
|
25
|
-
xml_section.title { |t| t << title }
|
24
|
+
#title = node.level == 1 ? "Bibliography" : node.title
|
25
|
+
xml_section.title { |t| t << node.title }
|
26
26
|
xml_section << node.content
|
27
27
|
end
|
28
28
|
@biblio = false
|
@@ -44,7 +44,8 @@ module Asciidoctor
|
|
44
44
|
@log.add("AsciiDoc Input", node, "Section not marked up as [bibliography]!")
|
45
45
|
@norm_ref = true
|
46
46
|
xml.references **attr_code(attrs.merge(normative: true)) do |xml_section|
|
47
|
-
xml_section.title { |t| t << "Normative References" }
|
47
|
+
#xml_section.title { |t| t << "Normative References" }
|
48
|
+
xml_section.title { |t| t << node.title }
|
48
49
|
xml_section << node.content
|
49
50
|
end
|
50
51
|
@norm_ref = false
|
@@ -14,8 +14,7 @@ module Asciidoctor
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def sectiontype1(node)
|
17
|
-
node&.attr("heading")&.downcase ||
|
18
|
-
node.title.gsub(/<[^>]+>/, "").downcase
|
17
|
+
node&.attr("heading")&.downcase || node.title.gsub(/<[^>]+>/, "").downcase
|
19
18
|
end
|
20
19
|
|
21
20
|
def sectiontype(node, level = true)
|
@@ -47,15 +46,12 @@ module Asciidoctor
|
|
47
46
|
|
48
47
|
def section_attributes(node)
|
49
48
|
ret = { id: Utils::anchor_or_uuid(node),
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
preface: (
|
57
|
-
(node.role == "preface" || node.attr("style") == "preface") ?
|
58
|
-
true : nil) }
|
49
|
+
language: node.attributes["language"],
|
50
|
+
script: node.attributes["script"],
|
51
|
+
annex: ( ((node.attr("style") == "appendix" || node.role == "appendix") &&
|
52
|
+
node.level == 1) ? true : nil),
|
53
|
+
preface: (
|
54
|
+
(node.role == "preface" || node.attr("style") == "preface") ? true : nil) }
|
59
55
|
return ret unless node.attributes["change"]
|
60
56
|
ret.merge(change: node.attributes["change"],
|
61
57
|
path: node.attributes["path"],
|
@@ -105,9 +101,9 @@ module Asciidoctor
|
|
105
101
|
|
106
102
|
def set_obligation(attrs, node)
|
107
103
|
attrs[:obligation] = node.attributes.has_key?("obligation") ?
|
108
|
-
|
109
|
-
|
110
|
-
|
104
|
+
node.attr("obligation") :
|
105
|
+
node.parent.attributes.has_key?("obligation") ?
|
106
|
+
node.parent.attr("obligation") : "normative"
|
111
107
|
end
|
112
108
|
|
113
109
|
def preamble(node)
|
@@ -187,18 +183,23 @@ module Asciidoctor
|
|
187
183
|
@term_def = defs
|
188
184
|
end
|
189
185
|
|
186
|
+
def terms_boilerplate_parse(attrs, xml, node)
|
187
|
+
defs = @term_def
|
188
|
+
@term_def = false
|
189
|
+
clause_parse(attrs.merge(type: "boilerplate"), xml, node)
|
190
|
+
@term_def = defs
|
191
|
+
end
|
192
|
+
|
190
193
|
# subclause contains subclauses
|
191
194
|
def term_def_subclause_parse(attrs, xml, node)
|
192
|
-
node.role == "nonterm" and
|
193
|
-
|
195
|
+
node.role == "nonterm" and return nonterm_term_def_subclause_parse(attrs, xml, node)
|
196
|
+
node.role == "boilerplate" and return terms_boilerplate_parse(attrs, xml, node)
|
194
197
|
st = sectiontype(node, false)
|
195
198
|
return symbols_parse(attrs, xml, node) if @definitions
|
196
199
|
sub = node.find_by(context: :section) { |s| s.level == node.level + 1 }
|
197
200
|
sub.empty? || (return term_def_parse(attrs, xml, node, false))
|
198
|
-
st == "symbols and abbreviated terms" and
|
199
|
-
|
200
|
-
st == "terms and definitions" and
|
201
|
-
return clause_parse(attrs, xml, node)
|
201
|
+
st == "symbols and abbreviated terms" and (return symbols_parse(attrs, xml, node))
|
202
|
+
st == "terms and definitions" and return clause_parse(attrs, xml, node)
|
202
203
|
term_def_subclause_parse1(attrs, xml, node)
|
203
204
|
end
|
204
205
|
|