metanorma-standoc 1.9.4 → 1.10.3
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 +1 -1
- data/.rubocop.yml +1 -1
- data/lib/asciidoctor/standoc/base.rb +0 -1
- data/lib/asciidoctor/standoc/blocks.rb +1 -1
- data/lib/asciidoctor/standoc/cleanup.rb +61 -2
- data/lib/asciidoctor/standoc/cleanup_block.rb +0 -1
- data/lib/asciidoctor/standoc/cleanup_boilerplate.rb +2 -2
- data/lib/asciidoctor/standoc/cleanup_footnotes.rb +0 -1
- data/lib/asciidoctor/standoc/cleanup_inline.rb +117 -77
- data/lib/asciidoctor/standoc/cleanup_maths.rb +0 -1
- data/lib/asciidoctor/standoc/cleanup_ref.rb +7 -0
- data/lib/asciidoctor/standoc/cleanup_section.rb +0 -1
- data/lib/asciidoctor/standoc/cleanup_terms.rb +19 -18
- data/lib/asciidoctor/standoc/converter.rb +3 -0
- data/lib/asciidoctor/standoc/datamodel/diagram_preprocessor.rb +22 -21
- data/lib/asciidoctor/standoc/front.rb +0 -1
- data/lib/asciidoctor/standoc/front_contributor.rb +0 -1
- data/lib/asciidoctor/standoc/inline.rb +20 -17
- data/lib/asciidoctor/standoc/isodoc.rng +56 -8
- data/lib/asciidoctor/standoc/macros.rb +25 -5
- data/lib/asciidoctor/standoc/macros_plantuml.rb +21 -23
- data/lib/asciidoctor/standoc/macros_terms.rb +60 -23
- data/lib/asciidoctor/standoc/ref.rb +60 -56
- data/lib/asciidoctor/standoc/section.rb +19 -12
- data/lib/asciidoctor/standoc/term_lookup_cleanup.rb +69 -30
- data/lib/asciidoctor/standoc/terms.rb +1 -1
- data/lib/asciidoctor/standoc/utils.rb +0 -1
- data/lib/asciidoctor/standoc/validate.rb +22 -8
- data/lib/isodoc/html/html_titlepage.html +81 -0
- data/lib/isodoc/html/htmlstyle.css +983 -0
- data/lib/isodoc/html/htmlstyle.scss +714 -0
- data/lib/isodoc/html/scripts.html +71 -0
- data/lib/metanorma/standoc/processor.rb +16 -7
- data/lib/metanorma/standoc/version.rb +1 -1
- data/metanorma-standoc.gemspec +3 -3
- data/spec/asciidoctor/blocks_spec.rb +8 -8
- data/spec/asciidoctor/cleanup_sections_spec.rb +899 -864
- data/spec/asciidoctor/cleanup_spec.rb +85 -20
- data/spec/asciidoctor/isobib_cache_spec.rb +4 -6
- data/spec/asciidoctor/lists_spec.rb +147 -135
- data/spec/asciidoctor/macros_json2text_spec.rb +1 -1
- data/spec/asciidoctor/macros_plantuml_spec.rb +165 -104
- data/spec/asciidoctor/macros_spec.rb +813 -168
- data/spec/asciidoctor/refs_spec.rb +12 -12
- data/spec/asciidoctor/validate_spec.rb +76 -20
- data/spec/support/shared_examples/structured_data_2_text_preprocessor.rb +34 -34
- data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +50 -50
- data/spec/vcr_cassettes/isobib_get_123.yml +13 -13
- data/spec/vcr_cassettes/isobib_get_123_1.yml +26 -26
- data/spec/vcr_cassettes/isobib_get_123_1_fr.yml +34 -34
- data/spec/vcr_cassettes/isobib_get_123_2001.yml +14 -14
- data/spec/vcr_cassettes/isobib_get_124.yml +11 -11
- data/spec/vcr_cassettes/rfcbib_get_rfc8341.yml +14 -14
- data/spec/vcr_cassettes/separates_iev_citations_by_top_level_clause.yml +51 -61
- metadata +11 -7
@@ -4,18 +4,17 @@ module Asciidoctor
|
|
4
4
|
# https://stackoverflow.com/questions/2108727/which-in-ruby-checking-if-program-exists-in-path-from-ruby
|
5
5
|
def self.plantuml_installed?
|
6
6
|
cmd = "plantuml"
|
7
|
-
exts = ENV[
|
8
|
-
ENV[
|
7
|
+
exts = ENV["PATHEXT"] ? ENV["PATHEXT"].split(";") : [""]
|
8
|
+
ENV["PATH"].split(File::PATH_SEPARATOR).each do |path|
|
9
9
|
exts.each do |ext|
|
10
10
|
exe = File.join(path, "#{cmd}#{ext}")
|
11
11
|
return exe if File.executable?(exe) && !File.directory?(exe)
|
12
12
|
end
|
13
13
|
end
|
14
14
|
raise "PlantUML not installed"
|
15
|
-
nil
|
16
15
|
end
|
17
16
|
|
18
|
-
def self.run
|
17
|
+
def self.run(umlfile, outfile)
|
19
18
|
system "plantuml #{umlfile.path}" or (warn $? and return false)
|
20
19
|
i = 0
|
21
20
|
until !Gem.win_platform? || File.exist?(outfile) || i == 15
|
@@ -29,9 +28,9 @@ module Asciidoctor
|
|
29
28
|
# sleep need for windows because dot works in separate process and
|
30
29
|
# plantuml process may finish earlier then dot, as result png file
|
31
30
|
# maybe not created yet after plantuml finish
|
32
|
-
def self.generate_file
|
31
|
+
def self.generate_file(parent, reader)
|
33
32
|
localdir = Metanorma::Utils::localdir(parent.document)
|
34
|
-
imagesdir = parent.document.attr(
|
33
|
+
imagesdir = parent.document.attr("imagesdir")
|
35
34
|
umlfile, outfile = save_plantuml parent, reader, localdir
|
36
35
|
run(umlfile, outfile) or raise "No image output from PlantUML (#{umlfile}, #{outfile})!"
|
37
36
|
umlfile.unlink
|
@@ -40,7 +39,7 @@ module Asciidoctor
|
|
40
39
|
File.writable?(localdir) or raise "Destination path #{path} not writable for PlantUML!"
|
41
40
|
path.mkpath
|
42
41
|
File.writable?(path) or raise "Destination path #{path} not writable for PlantUML!"
|
43
|
-
#File.exist?(path) or raise "Destination path #{path} already exists for PlantUML!"
|
42
|
+
# File.exist?(path) or raise "Destination path #{path} already exists for PlantUML!"
|
44
43
|
|
45
44
|
# Warning: metanorma/metanorma-standoc#187
|
46
45
|
# Windows Ruby 2.4 will crash if a Tempfile is "mv"ed.
|
@@ -51,21 +50,21 @@ module Asciidoctor
|
|
51
50
|
imagesdir ? filename : File.join(path, filename)
|
52
51
|
end
|
53
52
|
|
54
|
-
def self.save_plantuml
|
53
|
+
def self.save_plantuml(_parent, reader, _localdir)
|
55
54
|
src = reader.source
|
56
55
|
reader.lines.first.sub(/\s+$/, "").match /^@startuml($| )/ or
|
57
56
|
src = "@startuml\n#{src}\n@enduml\n"
|
58
57
|
/^@startuml (?<fn>[^\n]+)\n/ =~ src
|
59
|
-
Tempfile.open(["plantuml", ".pml"], :
|
58
|
+
Tempfile.open(["plantuml", ".pml"], encoding: "utf-8") do |f|
|
60
59
|
f.write(src)
|
61
60
|
[f, File.join(File.dirname(f.path),
|
62
|
-
|
61
|
+
"#{fn || File.basename(f.path, '.pml')}.png")]
|
63
62
|
end
|
64
63
|
end
|
65
64
|
|
66
|
-
def self.generate_attrs
|
67
|
-
|
68
|
-
inject({}) do |memo, key|
|
65
|
+
def self.generate_attrs(attrs)
|
66
|
+
%w(id align float title role width height alt)
|
67
|
+
.inject({}) do |memo, key|
|
69
68
|
memo[key] = attrs[key] if attrs.has_key? key
|
70
69
|
memo
|
71
70
|
end
|
@@ -81,19 +80,18 @@ module Asciidoctor
|
|
81
80
|
def abort(parent, reader, attrs, msg)
|
82
81
|
warn msg
|
83
82
|
attrs["language"] = "plantuml"
|
84
|
-
create_listing_block parent, reader.source,
|
83
|
+
create_listing_block parent, reader.source,
|
84
|
+
(attrs.reject { |k, _v| k == 1 })
|
85
85
|
end
|
86
86
|
|
87
87
|
def process(parent, reader, attrs)
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
abort(parent, reader, attrs, e.message)
|
96
|
-
end
|
88
|
+
PlantUMLBlockMacroBackend.plantuml_installed?
|
89
|
+
filename = PlantUMLBlockMacroBackend.generate_file(parent, reader)
|
90
|
+
through_attrs = PlantUMLBlockMacroBackend.generate_attrs attrs
|
91
|
+
through_attrs["target"] = filename
|
92
|
+
create_image_block parent, through_attrs
|
93
|
+
rescue StandardError => e
|
94
|
+
abort(parent, reader, attrs, e.message)
|
97
95
|
end
|
98
96
|
end
|
99
97
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require "csv"
|
2
|
+
|
1
3
|
module Asciidoctor
|
2
4
|
module Standoc
|
3
5
|
class AltTermInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
@@ -36,46 +38,81 @@ module Asciidoctor
|
|
36
38
|
end
|
37
39
|
end
|
38
40
|
|
39
|
-
# Macro to transform `term[X,Y]` into em, termxref xml
|
40
41
|
class TermRefInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
41
42
|
use_dsl
|
42
43
|
named :term
|
43
|
-
name_positional_attributes
|
44
|
+
name_positional_attributes "name", "termxref"
|
45
|
+
using_format :short
|
46
|
+
|
47
|
+
def process(_parent, _target, attrs)
|
48
|
+
termref = attrs["termxref"] || attrs["name"]
|
49
|
+
"<concept type='term'><termxref>#{attrs['name']}</termxref>"\
|
50
|
+
"<renderterm>#{termref}</renderterm><xrefrender/></concept>"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
class SymbolRefInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
55
|
+
use_dsl
|
56
|
+
named :symbol
|
57
|
+
name_positional_attributes "name", "termxref"
|
44
58
|
using_format :short
|
45
59
|
|
46
60
|
def process(_parent, _target, attrs)
|
47
|
-
termref = attrs[
|
48
|
-
"<
|
61
|
+
termref = attrs["termxref"] || attrs["name"]
|
62
|
+
"<concept type='symbol'><termxref>#{attrs['name']}</termxref>"\
|
63
|
+
"<renderterm>#{termref}</renderterm><xrefrender/></concept>"
|
49
64
|
end
|
50
65
|
end
|
51
66
|
|
67
|
+
# Possibilities:
|
68
|
+
# {{<<id>>, term}}
|
69
|
+
# {{<<id>>, term, text}}
|
70
|
+
# {{<<termbase:id>>, term}}
|
71
|
+
# {{<<termbase:id>>, term, text}}
|
72
|
+
# {{term}} equivalent to term:[term]
|
73
|
+
# {{term, text}} equivalent to term:[term, text]
|
74
|
+
# text may optionally be followed by crossreference-rendering, options=""
|
52
75
|
class ConceptInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
53
76
|
use_dsl
|
54
77
|
named :concept
|
55
|
-
name_positional_attributes "id", "word", "term"
|
56
|
-
# match %r{concept:(?<target>[^\[]*)\[(?<content>|.*?[^\\])\]$}
|
57
78
|
match /\{\{(?<content>|.*?[^\\])\}\}/
|
58
79
|
using_format :short
|
59
80
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
81
|
+
def preprocess_attrs(target)
|
82
|
+
m = /^(?<id><<.+?>>)?(?<rest>.*)$/.match(target)
|
83
|
+
ret = { id: m[:id]&.sub(/^<</, "")&.sub(/>>$/, "") }
|
84
|
+
if m2 = /^(?<rest>.*?)(?<opt>,option=.+)$/.match(m[:rest].sub(/^,/, ""))
|
85
|
+
ret[:opt] = CSV.parse_line(m2[:opt].sub(/^,option=/, "")
|
86
|
+
.sub(/^"(.+)"$/, "\\1").sub(/^'(.+)'$/, "\\1"))
|
87
|
+
attrs = CSV.parse_line(m2[:rest]) || []
|
88
|
+
else
|
89
|
+
attrs = CSV.parse_line(m[:rest].sub(/^,/, "")) || []
|
90
|
+
end
|
91
|
+
ret.merge(term: attrs[0], word: attrs[1] || attrs[0],
|
92
|
+
xrefrender: attrs[2])
|
93
|
+
end
|
94
|
+
|
95
|
+
def generate_attrs(opts)
|
96
|
+
ret = ""
|
97
|
+
opts.include?("noital") and ret += " ital='false'"
|
98
|
+
opts.include?("noref") and ret += " ref='false'"
|
99
|
+
opts.include?("ital") and ret += " ital='true'"
|
100
|
+
opts.include?("ref") and ret += " ref='true'"
|
101
|
+
ret
|
68
102
|
end
|
69
103
|
|
70
|
-
def process(parent,
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
104
|
+
def process(parent, target, _attrs)
|
105
|
+
attrs = preprocess_attrs(target)
|
106
|
+
termout = Asciidoctor::Inline.new(parent, :quoted, attrs[:term]).convert
|
107
|
+
wordout = Asciidoctor::Inline.new(parent, :quoted, attrs[:word]).convert
|
108
|
+
xrefout = Asciidoctor::Inline.new(parent, :quoted,
|
109
|
+
attrs[:xrefrender]).convert
|
110
|
+
optout = generate_attrs(attrs[:opt] || [])
|
111
|
+
attrs[:id] and return "<concept#{optout} key='#{attrs[:id]}'><refterm>"\
|
112
|
+
"#{termout}</refterm><renderterm>#{wordout}</renderterm>"\
|
113
|
+
"<xrefrender>#{xrefout}</xrefrender></concept>"
|
114
|
+
"<concept#{optout}><termxref>#{termout}</termxref><renderterm>"\
|
115
|
+
"#{wordout}</renderterm><xrefrender>#{xrefout}</xrefrender></concept>"
|
79
116
|
end
|
80
117
|
end
|
81
118
|
end
|
@@ -4,7 +4,7 @@ module Asciidoctor
|
|
4
4
|
module Standoc
|
5
5
|
module Refs
|
6
6
|
def iso_publisher(bib, code)
|
7
|
-
code.sub(/ .*$/, "").split(
|
7
|
+
code.sub(/ .*$/, "").split("/").each do |abbrev|
|
8
8
|
bib.contributor do |c|
|
9
9
|
c.role **{ type: "publisher" }
|
10
10
|
c.organization do |org|
|
@@ -18,75 +18,78 @@ module Asciidoctor
|
|
18
18
|
{ format: "text/plain" }
|
19
19
|
end
|
20
20
|
|
21
|
-
def ref_attributes(
|
22
|
-
{ id:
|
21
|
+
def ref_attributes(match)
|
22
|
+
{ id: match[:anchor], type: "standard" }
|
23
23
|
end
|
24
24
|
|
25
|
-
def isorefrender1(bib,
|
26
|
-
bib.title(**plaintxt) { |i| i << ref_normalise(
|
27
|
-
docid(bib,
|
28
|
-
docid(bib, id_and_year(
|
29
|
-
docnumber(bib,
|
25
|
+
def isorefrender1(bib, match, yr, allp = "")
|
26
|
+
bib.title(**plaintxt) { |i| i << ref_normalise(match[:text]) }
|
27
|
+
docid(bib, match[:usrlbl]) if match[:usrlbl]
|
28
|
+
docid(bib, id_and_year(match[:code], yr) + allp)
|
29
|
+
docnumber(bib, match[:code])
|
30
30
|
end
|
31
31
|
|
32
|
-
def isorefmatches(xml,
|
33
|
-
yr = norm_year(
|
34
|
-
ref = fetch_ref xml,
|
35
|
-
|
36
|
-
|
32
|
+
def isorefmatches(xml, match)
|
33
|
+
yr = norm_year(match[:year])
|
34
|
+
ref = fetch_ref xml, match[:code], yr,
|
35
|
+
title: match[:text], usrlbl: match[:usrlbl],
|
36
|
+
lang: (@lang || :all)
|
37
|
+
return use_my_anchor(ref, match[:anchor]) if ref
|
37
38
|
|
38
|
-
xml.bibitem **attr_code(ref_attributes(
|
39
|
-
isorefrender1(t,
|
39
|
+
xml.bibitem **attr_code(ref_attributes(match)) do |t|
|
40
|
+
isorefrender1(t, match, yr)
|
40
41
|
yr and t.date **{ type: "published" } do |d|
|
41
42
|
set_date_range(d, yr)
|
42
43
|
end
|
43
|
-
iso_publisher(t,
|
44
|
+
iso_publisher(t, match[:code])
|
44
45
|
end
|
45
46
|
end
|
46
47
|
|
47
|
-
def isorefmatches2(xml,
|
48
|
-
ref = fetch_ref xml,
|
49
|
-
|
50
|
-
|
48
|
+
def isorefmatches2(xml, match)
|
49
|
+
ref = fetch_ref xml, match[:code], nil,
|
50
|
+
no_year: true, note: match[:fn],
|
51
|
+
title: match[:text], usrlbl: match[:usrlbl],
|
52
|
+
lang: (@lang || :all)
|
53
|
+
return use_my_anchor(ref, match[:anchor]) if ref
|
51
54
|
|
52
|
-
isorefmatches2_1(xml,
|
55
|
+
isorefmatches2_1(xml, match)
|
53
56
|
end
|
54
57
|
|
55
|
-
def isorefmatches2_1(xml,
|
56
|
-
xml.bibitem **attr_code(ref_attributes(
|
57
|
-
isorefrender1(t,
|
58
|
+
def isorefmatches2_1(xml, match)
|
59
|
+
xml.bibitem **attr_code(ref_attributes(match)) do |t|
|
60
|
+
isorefrender1(t, match, "--")
|
58
61
|
t.date **{ type: "published" } do |d|
|
59
62
|
d.on "--"
|
60
63
|
end
|
61
|
-
iso_publisher(t,
|
62
|
-
unless
|
64
|
+
iso_publisher(t, match[:code])
|
65
|
+
unless match[:fn].nil?
|
63
66
|
t.note(**plaintxt.merge(type: "Unpublished-Status")) do |p|
|
64
|
-
|
67
|
+
p << (match[:fn]).to_s
|
65
68
|
end
|
66
69
|
end
|
67
70
|
end
|
68
71
|
end
|
69
72
|
|
70
|
-
def isorefmatches3(xml,
|
71
|
-
yr = norm_year(
|
73
|
+
def isorefmatches3(xml, match)
|
74
|
+
yr = norm_year(match[:year])
|
72
75
|
hasyr = !yr.nil? && yr != "--"
|
73
|
-
ref = fetch_ref(xml,
|
74
|
-
all_parts: true,
|
75
|
-
|
76
|
+
ref = fetch_ref(xml, match[:code], hasyr ? yr : nil,
|
77
|
+
all_parts: true, no_year: yr == "--",
|
78
|
+
text: match[:text], usrlbl: match[:usrlbl],
|
76
79
|
lang: (@lang || :all))
|
77
|
-
return use_my_anchor(ref,
|
80
|
+
return use_my_anchor(ref, match[:anchor]) if ref
|
78
81
|
|
79
|
-
isorefmatches3_1(xml,
|
82
|
+
isorefmatches3_1(xml, match, yr, hasyr, ref)
|
80
83
|
end
|
81
84
|
|
82
|
-
def isorefmatches3_1(xml,
|
83
|
-
xml.bibitem(**attr_code(ref_attributes(
|
84
|
-
isorefrender1(t,
|
85
|
-
conditional_date(t,
|
86
|
-
iso_publisher(t,
|
87
|
-
if
|
85
|
+
def isorefmatches3_1(xml, match, yr, _hasyr, _ref)
|
86
|
+
xml.bibitem(**attr_code(ref_attributes(match))) do |t|
|
87
|
+
isorefrender1(t, match, yr, " (all parts)")
|
88
|
+
conditional_date(t, match, yr == "--")
|
89
|
+
iso_publisher(t, match[:code])
|
90
|
+
if match.names.include?("fn") && match[:fn]
|
88
91
|
t.note(**plaintxt.merge(type: "Unpublished-Status")) do |p|
|
89
|
-
p << (
|
92
|
+
p << (match[:fn]).to_s
|
90
93
|
end
|
91
94
|
end
|
92
95
|
t.extent **{ type: "part" } do |e|
|
@@ -95,23 +98,23 @@ module Asciidoctor
|
|
95
98
|
end
|
96
99
|
end
|
97
100
|
|
98
|
-
def refitem_render1(
|
101
|
+
def refitem_render1(match, code, bib)
|
99
102
|
if code[:type] == "path"
|
100
103
|
bib.uri code[:key].sub(/\.[a-zA-Z0-9]+$/, ""), **{ type: "URI" }
|
101
104
|
bib.uri code[:key].sub(/\.[a-zA-Z0-9]+$/, ""), **{ type: "citation" }
|
102
105
|
end
|
103
|
-
docid(bib,
|
106
|
+
docid(bib, match[:usrlbl]) if match[:usrlbl]
|
104
107
|
docid(bib, /^\d+$/.match?(code[:id]) ? "[#{code[:id]}]" : code[:id])
|
105
108
|
code[:type] == "repo" and
|
106
109
|
bib.docidentifier code[:key], **{ type: "repository" }
|
107
110
|
end
|
108
111
|
|
109
|
-
def refitem_render(xml,
|
110
|
-
xml.bibitem **attr_code(id:
|
112
|
+
def refitem_render(xml, match, code)
|
113
|
+
xml.bibitem **attr_code(id: match[:anchor]) do |t|
|
111
114
|
t.formattedref **{ format: "application/x-isodoc+xml" } do |i|
|
112
|
-
i << ref_normalise_no_format(
|
115
|
+
i << ref_normalise_no_format(match[:text])
|
113
116
|
end
|
114
|
-
refitem_render1(
|
117
|
+
refitem_render1(match, code, t)
|
115
118
|
docnumber(t, code[:id]) unless /^\d+$|^\(.+\)$/.match?(code[:id])
|
116
119
|
end
|
117
120
|
end
|
@@ -128,7 +131,7 @@ module Asciidoctor
|
|
128
131
|
|
129
132
|
def analyse_ref_repo_path(ret)
|
130
133
|
return ret unless m =
|
131
|
-
|
134
|
+
/^(?<type>repo|path):\((?<key>[^,]+),?(?<id>.*)\)$/.match(ret[:id])
|
132
135
|
|
133
136
|
id = m[:id].empty? ? m[:key].sub(%r{^[^/]+/}, "") : m[:id]
|
134
137
|
ret.merge(id: id, type: m[:type], key: m[:key], nofetch: true)
|
@@ -156,16 +159,17 @@ module Asciidoctor
|
|
156
159
|
nil
|
157
160
|
end
|
158
161
|
|
159
|
-
def refitem1(xml, _item,
|
160
|
-
code = analyse_ref_code(
|
162
|
+
def refitem1(xml, _item, match)
|
163
|
+
code = analyse_ref_code(match[:code])
|
161
164
|
unless code[:id] && code[:numeric] || code[:nofetch]
|
162
165
|
ref = fetch_ref(xml, code[:id],
|
163
|
-
|
164
|
-
title:
|
165
|
-
usrlbl:
|
166
|
-
|
166
|
+
match.names.include?("year") ? match[:year] : nil,
|
167
|
+
title: match[:text],
|
168
|
+
usrlbl: match[:usrlbl], lang: (@lang || :all)) and
|
169
|
+
return use_my_anchor(ref, match[:anchor])
|
167
170
|
end
|
168
|
-
|
171
|
+
|
172
|
+
refitem_render(xml, match, code)
|
169
173
|
end
|
170
174
|
|
171
175
|
def ref_normalise(ref)
|
@@ -186,7 +190,7 @@ module Asciidoctor
|
|
186
190
|
\[(?<usrlbl>\([^)]+\))?(?<code>(ISO|IEC)[^0-9]*\s[0-9-]+):
|
187
191
|
(--|&\#821[12];)\]</ref>,?\s*
|
188
192
|
(<fn[^>]*>\s*<p>(?<fn>[^\]]+)</p>\s*</fn>)?,?\s?(?<text>.*)$}xm
|
189
|
-
|
193
|
+
.freeze
|
190
194
|
|
191
195
|
ISO_REF_ALL_PARTS =
|
192
196
|
%r{^<ref\sid="(?<anchor>[^"]+)">
|
@@ -12,7 +12,7 @@ module Asciidoctor
|
|
12
12
|
def sectiontype1(node)
|
13
13
|
node&.attr("heading")&.downcase ||
|
14
14
|
node.title.gsub(%r{<index>.*?</index>}m, "").gsub(/<[^>]+>/, "")
|
15
|
-
|
15
|
+
.strip.downcase
|
16
16
|
end
|
17
17
|
|
18
18
|
def sectiontype(node, level = true)
|
@@ -21,6 +21,7 @@ module Asciidoctor
|
|
21
21
|
return ret1 if "symbols and abbreviated terms" == ret1
|
22
22
|
return nil unless !level || node.level == 1
|
23
23
|
return nil if @seen_headers.include? ret
|
24
|
+
|
24
25
|
@seen_headers << ret
|
25
26
|
ret1
|
26
27
|
end
|
@@ -48,11 +49,14 @@ module Asciidoctor
|
|
48
49
|
script: node.attributes["script"],
|
49
50
|
number: node.attributes["number"],
|
50
51
|
type: node.attributes["type"],
|
51
|
-
annex: ( (
|
52
|
-
node.level == 1
|
53
|
-
|
54
|
-
|
52
|
+
annex: (if (node.attr("style") == "appendix" || node.role == "appendix") &&
|
53
|
+
node.level == 1
|
54
|
+
true
|
55
|
+
end),
|
56
|
+
preface: (
|
57
|
+
node.role == "preface" || node.attr("style") == "preface" ? true : nil) }
|
55
58
|
return ret unless node.attributes["change"]
|
59
|
+
|
56
60
|
ret.merge(change: node.attributes["change"],
|
57
61
|
path: node.attributes["path"],
|
58
62
|
path_end: node.attributes["path_end"],
|
@@ -75,7 +79,7 @@ module Asciidoctor
|
|
75
79
|
symbols_parse(symbols_attrs(node, a), xml, node)
|
76
80
|
when "acknowledgements"
|
77
81
|
acknowledgements_parse(a, xml, node)
|
78
|
-
when "bibliography"
|
82
|
+
when "bibliography"
|
79
83
|
bibliography_parse(a, xml, node)
|
80
84
|
else
|
81
85
|
if @term_def then term_def_subclause_parse(a, xml, node)
|
@@ -88,9 +92,9 @@ module Asciidoctor
|
|
88
92
|
bibliography_parse(a, xml, node)
|
89
93
|
elsif node.attr("style") == "bibliography"
|
90
94
|
bibliography_parse(a, xml, node)
|
91
|
-
elsif node.attr("style") == "abstract"
|
95
|
+
elsif node.attr("style") == "abstract"
|
92
96
|
abstract_parse(a, xml, node)
|
93
|
-
elsif node.attr("style") == "index"
|
97
|
+
elsif node.attr("style") == "index"
|
94
98
|
indexsect_parse(a, xml, node)
|
95
99
|
elsif node.attr("style") == "appendix" && node.level == 1
|
96
100
|
annex_parse(a, xml, node)
|
@@ -102,10 +106,13 @@ module Asciidoctor
|
|
102
106
|
end
|
103
107
|
|
104
108
|
def set_obligation(attrs, node)
|
105
|
-
attrs[:obligation] = node.attributes.has_key?("obligation")
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
+
attrs[:obligation] = if node.attributes.has_key?("obligation")
|
110
|
+
node.attr("obligation")
|
111
|
+
elsif node.parent.attributes.has_key?("obligation")
|
112
|
+
node.parent.attr("obligation")
|
113
|
+
else
|
114
|
+
"normative"
|
115
|
+
end
|
109
116
|
end
|
110
117
|
|
111
118
|
def preamble(node)
|