isodoc 2.12.0 → 2.12.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/isodoc.gemspec +2 -2
- data/lib/isodoc/convert.rb +0 -21
- data/lib/isodoc/function/blocks.rb +19 -48
- data/lib/isodoc/function/blocks_example_note.rb +75 -29
- data/lib/isodoc/function/cleanup.rb +3 -40
- data/lib/isodoc/function/inline.rb +39 -9
- data/lib/isodoc/function/lists.rb +5 -5
- data/lib/isodoc/function/references.rb +9 -133
- data/lib/isodoc/function/reqt.rb +2 -2
- data/lib/isodoc/function/section.rb +25 -28
- data/lib/isodoc/function/section_titles.rb +16 -13
- data/lib/isodoc/function/table.rb +3 -3
- data/lib/isodoc/function/terms.rb +21 -20
- data/lib/isodoc/function/to_word_html.rb +8 -5
- data/lib/isodoc/function/utils.rb +1 -1
- data/lib/isodoc/html_function/footnotes.rb +2 -1
- data/lib/isodoc/html_function/html.rb +1 -5
- data/lib/isodoc/init.rb +31 -0
- data/lib/isodoc/metadata.rb +9 -0
- data/lib/isodoc/metadata_contributor.rb +1 -1
- data/lib/isodoc/metadata_date.rb +1 -1
- data/lib/isodoc/presentation_function/autonum.rb +139 -0
- data/lib/isodoc/presentation_function/block.rb +95 -36
- data/lib/isodoc/presentation_function/docid.rb +78 -0
- data/lib/isodoc/presentation_function/erefs.rb +6 -4
- data/lib/isodoc/presentation_function/image.rb +52 -13
- data/lib/isodoc/presentation_function/inline.rb +6 -6
- data/lib/isodoc/presentation_function/math.rb +0 -14
- data/lib/isodoc/presentation_function/metadata.rb +0 -62
- data/lib/isodoc/presentation_function/refs.rb +44 -14
- data/lib/isodoc/presentation_function/reqt.rb +1 -1
- data/lib/isodoc/presentation_function/section.rb +46 -121
- data/lib/isodoc/presentation_function/sourcecode.rb +7 -4
- data/lib/isodoc/presentation_function/terms.rb +27 -2
- data/lib/isodoc/presentation_function/title.rb +107 -0
- data/lib/isodoc/presentation_function/xrefs.rb +17 -10
- data/lib/isodoc/presentation_xml_convert.rb +6 -2
- data/lib/isodoc/version.rb +1 -1
- data/lib/isodoc/word_function/body.rb +8 -36
- data/lib/isodoc/word_function/footnotes.rb +1 -1
- data/lib/isodoc/word_function/lists.rb +12 -10
- data/lib/isodoc/word_function/postprocess_cover.rb +0 -2
- data/lib/isodoc/word_function/postprocess_table.rb +1 -1
- data/lib/isodoc/word_function/table.rb +2 -2
- data/lib/isodoc/xref/clause_order.rb +2 -2
- data/lib/isodoc/xref/xref_anchor.rb +31 -16
- data/lib/isodoc/xref/xref_counter_types.rb +3 -2
- data/lib/isodoc/xref/xref_gen.rb +57 -33
- data/lib/isodoc/xref/xref_gen_seq.rb +145 -56
- data/lib/isodoc/xref/xref_sect_gen.rb +64 -47
- data/lib/isodoc/xref/xref_util.rb +49 -1
- data/lib/isodoc/xref.rb +3 -0
- data/lib/isodoc-yaml/i18n-ar.yaml +9 -9
- data/lib/isodoc-yaml/i18n-de.yaml +9 -9
- data/lib/isodoc-yaml/i18n-en.yaml +9 -9
- data/lib/isodoc-yaml/i18n-es.yaml +9 -9
- data/lib/isodoc-yaml/i18n-fr.yaml +9 -9
- data/lib/isodoc-yaml/i18n-ja.yaml +10 -10
- data/lib/isodoc-yaml/i18n-ru.yaml +9 -9
- data/lib/isodoc-yaml/i18n-zh-Hans.yaml +9 -9
- data/lib/nokogiri/xml/node.rb +1 -0
- metadata +9 -6
@@ -7,13 +7,14 @@ module IsoDoc
|
|
7
7
|
prefix_container(container_container,
|
8
8
|
anchor_xref(node, container, container: true),
|
9
9
|
node, target)
|
10
|
-
l10n(@i18n.nested_xref
|
11
|
-
.sub("%
|
10
|
+
l10n(connectives_spans(@i18n.nested_xref
|
11
|
+
.sub("%1", "<span class='fmt-xref-container'>#{container_label}</span>")
|
12
|
+
.sub("%2", linkend)))
|
12
13
|
end
|
13
14
|
|
14
15
|
def anchor_value(id)
|
15
|
-
@xrefs.anchor(id, :bare_xref) || @xrefs.anchor(id, :
|
16
|
-
@xrefs.anchor(id, :
|
16
|
+
@xrefs.anchor(id, :bare_xref) || @xrefs.anchor(id, :label) ||
|
17
|
+
@xrefs.anchor(id, :value) || @xrefs.anchor(id, :xref)
|
17
18
|
end
|
18
19
|
|
19
20
|
def anchor_linkend(node, linkend)
|
@@ -55,14 +56,15 @@ module IsoDoc
|
|
55
56
|
|
56
57
|
def anchor_xref_short(node, target, container)
|
57
58
|
if (l = node["label"]) && !container
|
58
|
-
|
59
|
+
v = anchor_value(target)
|
60
|
+
@i18n.l10n(%[<span class="fmt-element-name">#{l}</span> #{v}])
|
59
61
|
else @xrefs.anchor(target, :xref)
|
60
62
|
end
|
61
63
|
end
|
62
64
|
|
63
65
|
def anchor_xref_full(num, title)
|
64
66
|
(!title.nil? && !title.empty?) or return nil
|
65
|
-
l10n("#{num}
|
67
|
+
l10n("#{num}<span class='fmt-comma'>,</span> #{title}")
|
66
68
|
end
|
67
69
|
|
68
70
|
def prefix_container?(container, node)
|
@@ -133,9 +135,13 @@ module IsoDoc
|
|
133
135
|
def combine_conn(list)
|
134
136
|
list.size == 1 and list.first[:label]
|
135
137
|
if list[1..].all? { |l| l[:conn] == "and" }
|
136
|
-
@i18n.boolean_conj(list.map
|
138
|
+
connectives_spans(@i18n.boolean_conj(list.map do |l|
|
139
|
+
loc2xref(l)
|
140
|
+
end, "and"))
|
137
141
|
elsif list[1..].all? { |l| l[:conn] == "or" }
|
138
|
-
@i18n.boolean_conj(list.map
|
142
|
+
connectives_spans(@i18n.boolean_conj(list.map do |l|
|
143
|
+
loc2xref(l)
|
144
|
+
end, "or"))
|
139
145
|
else
|
140
146
|
ret = loc2xref(list[0])
|
141
147
|
list[1..].each { |l| ret = i18n_chain_boolean(ret, l) }
|
@@ -144,8 +150,9 @@ module IsoDoc
|
|
144
150
|
end
|
145
151
|
|
146
152
|
def i18n_chain_boolean(value, entry)
|
147
|
-
@i18n.send("chain_#{entry[:conn]}")
|
148
|
-
.sub("%
|
153
|
+
connectives_spans(@i18n.send("chain_#{entry[:conn]}")
|
154
|
+
.sub("%1", value)
|
155
|
+
.sub("%2", loc2xref(entry)))
|
149
156
|
end
|
150
157
|
|
151
158
|
def can_conflate_xref_rendering?(locs)
|
@@ -55,15 +55,16 @@ module IsoDoc
|
|
55
55
|
# feeds middle_title
|
56
56
|
# triggers xrefs reparse, so put references before all other sections,
|
57
57
|
# which alter titles and thus can alter xrefs
|
58
|
-
rearrange_clauses docxml # feeds toc, display_order, clausetitle,
|
58
|
+
rearrange_clauses docxml # feeds toc, display_order, clausetitle,
|
59
59
|
# clause, middle_title
|
60
60
|
middle_title docxml
|
61
|
+
missing_title docxml # feeds clause
|
61
62
|
annex docxml
|
62
63
|
clause docxml # feeds clausetitle
|
63
64
|
term docxml
|
64
|
-
index docxml
|
65
65
|
clausetitle docxml # feeds floattitle
|
66
66
|
floattitle docxml # feeds rearrange_clauses
|
67
|
+
index docxml # fed by strip_duplicate_ids
|
67
68
|
toc docxml
|
68
69
|
display_order docxml
|
69
70
|
end
|
@@ -78,7 +79,10 @@ module IsoDoc
|
|
78
79
|
note docxml
|
79
80
|
admonition docxml
|
80
81
|
source docxml
|
82
|
+
ul docxml
|
81
83
|
ol docxml
|
84
|
+
dl docxml
|
85
|
+
quote docxml
|
82
86
|
permission docxml
|
83
87
|
requirement docxml
|
84
88
|
recommendation docxml
|
data/lib/isodoc/version.rb
CHANGED
@@ -102,40 +102,12 @@ module IsoDoc
|
|
102
102
|
end
|
103
103
|
end
|
104
104
|
|
105
|
-
def
|
106
|
-
|
107
|
-
div.p class: "Note" do |p|
|
108
|
-
p.span class: "note_label" do |s|
|
109
|
-
name&.children&.each { |n| parse(n, s) }
|
110
|
-
end
|
111
|
-
insert_tab(p, 1)
|
112
|
-
node.first_element_child.children.each { |n| parse(n, p) }
|
113
|
-
end
|
114
|
-
node.element_children[1..-1].each { |n| parse(n, div) }
|
105
|
+
def note_p_class
|
106
|
+
"Note"
|
115
107
|
end
|
116
108
|
|
117
|
-
def
|
118
|
-
|
119
|
-
div.p class: "Note" do |p|
|
120
|
-
p.span class: "note_label" do |s|
|
121
|
-
name&.children&.each { |n| parse(n, s) }
|
122
|
-
end
|
123
|
-
insert_tab(p, 1)
|
124
|
-
end
|
125
|
-
node.children.each { |n| parse(n, div) }
|
126
|
-
end
|
127
|
-
|
128
|
-
def termnote_parse(node, out)
|
129
|
-
name = node&.at(ns("./name"))&.remove
|
130
|
-
out.div **note_attrs(node) do |div|
|
131
|
-
div.p class: "Note" do |p|
|
132
|
-
if name
|
133
|
-
name.children.each { |n| parse(n, p) }
|
134
|
-
p << termnote_delim
|
135
|
-
end
|
136
|
-
para_then_remainder(node.first_element_child, node, p, div)
|
137
|
-
end
|
138
|
-
end
|
109
|
+
def termnote_p_class
|
110
|
+
"Note"
|
139
111
|
end
|
140
112
|
|
141
113
|
def para_attrs(node)
|
@@ -164,8 +136,8 @@ module IsoDoc
|
|
164
136
|
div.p do |_p|
|
165
137
|
parse(node.at(ns("./stem")), div)
|
166
138
|
insert_tab(div, 1)
|
167
|
-
if lbl = node&.at(ns("./name"))&.text
|
168
|
-
div <<
|
139
|
+
if lbl = node&.at(ns("./fmt-name"))&.text
|
140
|
+
div << lbl
|
169
141
|
end
|
170
142
|
end
|
171
143
|
end
|
@@ -185,10 +157,10 @@ module IsoDoc
|
|
185
157
|
page_break(out)
|
186
158
|
out.div **attr_code(preface_attrs(clause)) do |div|
|
187
159
|
div.p class: "zzContents" do |p|
|
188
|
-
clause.at(ns("./title"))&.children&.each { |c| parse(c, p) }
|
160
|
+
clause.at(ns("./fmt-title"))&.children&.each { |c| parse(c, p) }
|
189
161
|
end
|
190
162
|
clause.elements.each do |e|
|
191
|
-
parse(e, div) unless e.name == "title"
|
163
|
+
parse(e, div) unless e.name == "fmt-title"
|
192
164
|
end
|
193
165
|
end
|
194
166
|
end
|
@@ -83,7 +83,7 @@ module IsoDoc
|
|
83
83
|
|
84
84
|
def footnote_parse(node, out)
|
85
85
|
return table_footnote_parse(node, out) if (@in_table || @in_figure) &&
|
86
|
-
!node.ancestors.map(&:name).include?("name")
|
86
|
+
!node.ancestors.map(&:name).include?("fmt-name")
|
87
87
|
|
88
88
|
fn = node["reference"] || UUIDTools::UUID.random_create.to_s
|
89
89
|
return seen_footnote_parse(node, out, fn) if @seen_footnote.include?(fn)
|
@@ -25,13 +25,13 @@ module IsoDoc
|
|
25
25
|
|
26
26
|
def dl_parse_nontable(node, out)
|
27
27
|
out.div **attr_code(class: "figdl") do |div|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
28
|
+
node["id"] and bookmark_parse(node, div)
|
29
|
+
list_title_parse(node, div)
|
30
|
+
node.elements.select { |n| dt_dd?(n) }
|
31
|
+
.each_slice(2) do |dt, dd|
|
32
|
+
dl_parse_nontable1(div, dt, dd)
|
33
|
+
end
|
34
|
+
dl_parse_notes(node, div)
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
@@ -58,13 +58,13 @@ module IsoDoc
|
|
58
58
|
|
59
59
|
def ddef_other_paras(out, ddef)
|
60
60
|
ddef.elements&.first&.name == "p" or return
|
61
|
-
ddef.children[1
|
61
|
+
ddef.children[1..].each { |n| parse(n, out) }
|
62
62
|
end
|
63
63
|
|
64
64
|
def dl_parse_table(node, out)
|
65
65
|
list_title_parse(node, out)
|
66
66
|
out.table **attr_code(id: node["id"],
|
67
|
-
class:
|
67
|
+
class: node["class"] || "dl") do |v|
|
68
68
|
node.elements.select { |n| dt_dd?(n) }
|
69
69
|
.each_slice(2) do |dt, dd|
|
70
70
|
dl_parse_table1(v, dt, dd)
|
@@ -85,7 +85,9 @@ module IsoDoc
|
|
85
85
|
end
|
86
86
|
|
87
87
|
def dl_parse_table_notes(node, out)
|
88
|
-
remainder = node.elements.reject
|
88
|
+
remainder = node.elements.reject do |n|
|
89
|
+
dt_dd?(n) || n.name == "fmt-name"
|
90
|
+
end
|
89
91
|
remainder.empty? and return
|
90
92
|
out.tr do |tr|
|
91
93
|
tr.td colspan: 2 do |td|
|
@@ -22,7 +22,6 @@ module IsoDoc
|
|
22
22
|
cover = File.read(@wordcoverpage, encoding: "UTF-8")
|
23
23
|
cover = populate_template(cover, :word)
|
24
24
|
coverxml = to_word_xhtml_fragment(cover)
|
25
|
-
#ins.children.first.previous = coverxml.to_xml(encoding: "US-ASCII")
|
26
25
|
ins.add_first_child coverxml.to_xml(encoding: "US-ASCII")
|
27
26
|
end
|
28
27
|
|
@@ -32,7 +31,6 @@ module IsoDoc
|
|
32
31
|
docxml, level)
|
33
32
|
intro = populate_template(intro, :word)
|
34
33
|
introxml = to_word_xhtml_fragment(intro)
|
35
|
-
#ins.children.first.previous = introxml.to_xml(encoding: "US-ASCII")
|
36
34
|
ins.add_first_child introxml.to_xml(encoding: "US-ASCII")
|
37
35
|
end
|
38
36
|
|
@@ -34,7 +34,7 @@ module IsoDoc
|
|
34
34
|
def make_tr_attr_style(cell, row, rowmax, totalrows, opt)
|
35
35
|
top = row.zero? ? "#{SW1} 1.5pt;" : "none;"
|
36
36
|
bottom = "#{SW1} #{rowmax >= totalrows ? '1.5' : '1.0'}pt;"
|
37
|
-
ret = <<~STYLE.
|
37
|
+
ret = <<~STYLE.delete("\n")
|
38
38
|
border-top:#{top}mso-border-top-alt:#{top}
|
39
39
|
border-bottom:#{bottom}mso-border-bottom-alt:#{bottom}
|
40
40
|
STYLE
|
@@ -46,7 +46,7 @@ module IsoDoc
|
|
46
46
|
def keep_rows_together(_cell, rowmax, totalrows, opt)
|
47
47
|
opt[:header] and return true
|
48
48
|
@table_line_count > 15 and return false
|
49
|
-
|
49
|
+
totalrows <= 10 && rowmax < totalrows
|
50
50
|
end
|
51
51
|
|
52
52
|
def tbody_parse(node, table)
|
@@ -17,10 +17,10 @@ module IsoDoc
|
|
17
17
|
{ path: "//sections/clause[@type = 'scope']" },
|
18
18
|
{ path: @klass.norm_ref_xpath },
|
19
19
|
{ path: "//sections/terms | " \
|
20
|
-
"//sections/clause[descendant::terms]" },
|
20
|
+
"//sections/clause[descendant::terms]", multi: true },
|
21
21
|
{ path: "//sections/definitions | " \
|
22
22
|
"//sections/clause[descendant::definitions]" \
|
23
|
-
"[not(descendant::terms)]" },
|
23
|
+
"[not(descendant::terms)]", multi: true },
|
24
24
|
{ path: @klass.middle_clause(docxml), multi: true },
|
25
25
|
]
|
26
26
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require "singleton"
|
2
|
+
require_relative "xref_util"
|
2
3
|
|
3
4
|
module IsoDoc
|
4
5
|
module XrefGen
|
@@ -29,37 +30,51 @@ module IsoDoc
|
|
29
30
|
@anchors
|
30
31
|
end
|
31
32
|
|
32
|
-
def anchor_struct_label(lbl, elem)
|
33
|
+
def anchor_struct_label(lbl, node, elem)
|
33
34
|
case elem
|
34
|
-
when @labels["appendix"]
|
35
|
+
when @labels["appendix"]
|
36
|
+
s = "<semx element='autonum' source='#{node['id'] || node[:id]}'>" \
|
37
|
+
"#{lbl}</semx>"
|
38
|
+
"<span class='fmt-element-name'>#{elem}</span> #{s}"
|
35
39
|
else
|
36
|
-
lbl
|
40
|
+
anchor_struct_value(lbl, elem)
|
37
41
|
end
|
38
42
|
end
|
39
43
|
|
40
|
-
def anchor_struct_xref(lbl, elem)
|
41
|
-
|
44
|
+
def anchor_struct_xref(lbl, node, elem)
|
45
|
+
unless lbl.blank?
|
46
|
+
lbl = semx(node, lbl)
|
47
|
+
s = " #{anchor_struct_value(lbl, elem)}"
|
48
|
+
end
|
49
|
+
l10n("<span class='fmt-element-name'>#{elem}</span>#{s}")
|
50
|
+
.gsub(/ $/, "")
|
42
51
|
end
|
43
52
|
|
44
53
|
def anchor_struct_value(lbl, elem)
|
45
54
|
case elem
|
46
|
-
|
55
|
+
# TODO hardcoded ( ) ?
|
56
|
+
when @labels["formula"], @labels["inequality"] then <<~SPAN.strip
|
57
|
+
#{delim_wrap('(')}#{lbl}#{delim_wrap(')')}
|
58
|
+
SPAN
|
47
59
|
else
|
48
|
-
lbl
|
60
|
+
lbl.to_s
|
49
61
|
end
|
50
62
|
end
|
51
63
|
|
52
|
-
def anchor_struct(lbl, container, elem, type, unnumb = false)
|
53
|
-
|
54
|
-
ret
|
55
|
-
|
56
|
-
|
57
|
-
ret[:
|
58
|
-
|
59
|
-
|
60
|
-
ret[:
|
64
|
+
# def anchor_struct(lbl, container, elem, type, unnumb = false)
|
65
|
+
def anchor_struct(lbl, node, elem_name, type, opt = {})
|
66
|
+
ret = { type: type, elem: elem_name, label: nil }
|
67
|
+
opt[:unnumb] != "true" and
|
68
|
+
ret[:label] = anchor_struct_label(lbl, node, elem_name)
|
69
|
+
ret[:xref] =
|
70
|
+
anchor_struct_xref(opt[:unnumb] == "true" ? "(??)" : lbl, node,
|
71
|
+
elem_name)
|
72
|
+
ret[:container] = @klass.get_clause_id(node) if opt[:container]
|
73
|
+
ret[:value] = stripsemx(lbl)
|
61
74
|
ret
|
62
75
|
end
|
76
|
+
|
77
|
+
include ::IsoDoc::XrefGen::Util
|
63
78
|
end
|
64
79
|
end
|
65
80
|
end
|
@@ -2,11 +2,12 @@ require_relative "xref_counter"
|
|
2
2
|
|
3
3
|
module IsoDoc
|
4
4
|
class Xref
|
5
|
-
def clause_counter(num = 0, opts = {
|
5
|
+
def clause_counter(num = 0, opts = {})
|
6
|
+
opts[:numerals] ||= :arabic
|
6
7
|
::IsoDoc::XrefGen::Counter.new(num, opts)
|
7
8
|
end
|
8
9
|
|
9
|
-
def list_counter(num = 0, opts = {
|
10
|
+
def list_counter(num = 0, opts = {})
|
10
11
|
::IsoDoc::XrefGen::Counter.new(num, opts)
|
11
12
|
end
|
12
13
|
end
|
data/lib/isodoc/xref/xref_gen.rb
CHANGED
@@ -28,14 +28,18 @@ module IsoDoc
|
|
28
28
|
autonum
|
29
29
|
end
|
30
30
|
|
31
|
-
def termnote_label(
|
32
|
-
|
31
|
+
def termnote_label(node, label)
|
32
|
+
if label.blank?
|
33
|
+
@labels["termnote"].gsub(/%\s?/, "")
|
34
|
+
else
|
35
|
+
@labels["termnote"].gsub("%", semx(node, label.to_s))
|
36
|
+
end
|
33
37
|
end
|
34
38
|
|
35
39
|
def increment_label(elems, node, counter, increment: true)
|
36
40
|
elems.size == 1 && !node["number"] and return ""
|
37
41
|
counter.increment(node) if increment
|
38
|
-
|
42
|
+
counter.print
|
39
43
|
end
|
40
44
|
|
41
45
|
def termnote_anchor_names(docxml)
|
@@ -44,10 +48,10 @@ module IsoDoc
|
|
44
48
|
t.xpath(ns("./termnote")).noblank.each do |n|
|
45
49
|
c.increment(n)
|
46
50
|
@anchors[n["id"]] =
|
47
|
-
{ label: termnote_label(c.print), type: "termnote",
|
51
|
+
{ label: termnote_label(n, c.print), type: "termnote",
|
48
52
|
value: c.print, elem: @labels["termnote"],
|
49
53
|
container: t["id"],
|
50
|
-
xref:
|
54
|
+
xref: anchor_struct_xref(c.print, n, @labels["note_xref"]) }
|
51
55
|
end
|
52
56
|
end
|
53
57
|
end
|
@@ -63,7 +67,7 @@ module IsoDoc
|
|
63
67
|
{ label: idx, type: "termexample",
|
64
68
|
value: idx, elem: @labels["example_xref"],
|
65
69
|
container: t["id"],
|
66
|
-
xref:
|
70
|
+
xref: anchor_struct_xref(idx, n, @labels["example_xref"]) }
|
67
71
|
end
|
68
72
|
end
|
69
73
|
end
|
@@ -73,7 +77,7 @@ module IsoDoc
|
|
73
77
|
notes = s.xpath(child_asset_path("note")) -
|
74
78
|
s.xpath(ns(".//figure//note | .//table//note"))
|
75
79
|
note_anchor_names1(notes, Counter.new)
|
76
|
-
note_anchor_names(s.xpath(ns(
|
80
|
+
note_anchor_names(s.xpath(ns(child_sections)))
|
77
81
|
end
|
78
82
|
end
|
79
83
|
|
@@ -81,7 +85,8 @@ module IsoDoc
|
|
81
85
|
notes.noblank.each do |n|
|
82
86
|
@anchors[n["id"]] =
|
83
87
|
anchor_struct(increment_label(notes, n, counter), n,
|
84
|
-
@labels["note_xref"], "note",
|
88
|
+
@labels["note_xref"], "note",
|
89
|
+
{ container: true, unnumb: false })
|
85
90
|
end
|
86
91
|
end
|
87
92
|
|
@@ -90,7 +95,7 @@ module IsoDoc
|
|
90
95
|
s.at(ns(".//admonition[@type = 'box']")) or next
|
91
96
|
notes = s.xpath(child_asset_path("admonition[@type = 'box']"))
|
92
97
|
admonition_anchor_names1(notes, Counter.new)
|
93
|
-
admonition_anchor_names(s.xpath(ns(
|
98
|
+
admonition_anchor_names(s.xpath(ns(child_sections)))
|
94
99
|
end
|
95
100
|
end
|
96
101
|
|
@@ -98,7 +103,8 @@ module IsoDoc
|
|
98
103
|
notes.noblank.each do |n|
|
99
104
|
@anchors[n["id"]] ||=
|
100
105
|
anchor_struct(increment_label(notes, n, counter), n,
|
101
|
-
@labels["box"], "admonition",
|
106
|
+
@labels["box"], "admonition",
|
107
|
+
{ container: true, unnumb: n["unnumbered"] })
|
102
108
|
end
|
103
109
|
end
|
104
110
|
|
@@ -106,7 +112,7 @@ module IsoDoc
|
|
106
112
|
sections.each do |s|
|
107
113
|
notes = s.xpath(child_asset_path("example"))
|
108
114
|
example_anchor_names1(notes, Counter.new)
|
109
|
-
example_anchor_names(s.xpath(ns(
|
115
|
+
example_anchor_names(s.xpath(ns(child_sections)))
|
110
116
|
end
|
111
117
|
end
|
112
118
|
|
@@ -114,7 +120,8 @@ module IsoDoc
|
|
114
120
|
notes.noblank.each do |n|
|
115
121
|
@anchors[n["id"]] ||=
|
116
122
|
anchor_struct(increment_label(notes, n, counter), n,
|
117
|
-
@labels["example_xref"], "example",
|
123
|
+
@labels["example_xref"], "example",
|
124
|
+
{ unnumb: n["unnumbered"], container: true })
|
118
125
|
end
|
119
126
|
end
|
120
127
|
|
@@ -122,27 +129,35 @@ module IsoDoc
|
|
122
129
|
sections.each do |s|
|
123
130
|
notes = s.xpath(ns(".//ol")) - s.xpath(ns(".//clause//ol")) -
|
124
131
|
s.xpath(ns(".//appendix//ol")) - s.xpath(ns(".//ol//ol"))
|
125
|
-
c = list_counter
|
132
|
+
c = list_counter(0, {})
|
126
133
|
notes.noblank.each do |n|
|
127
|
-
@anchors[n["id"]] =
|
128
|
-
|
134
|
+
@anchors[n["id"]] =
|
135
|
+
anchor_struct(increment_label(notes, n, c), n,
|
136
|
+
@labels["list"], "list",
|
137
|
+
{ unnumb: false, container: true })
|
129
138
|
list_item_anchor_names(n, @anchors[n["id"]], 1, "", notes.size != 1)
|
130
139
|
end
|
131
|
-
list_anchor_names(s.xpath(ns(
|
140
|
+
list_anchor_names(s.xpath(ns(child_sections)))
|
132
141
|
end
|
133
142
|
end
|
134
143
|
|
135
|
-
def
|
136
|
-
|
144
|
+
def list_item_delim
|
145
|
+
")"
|
146
|
+
end
|
147
|
+
|
148
|
+
def list_item_anchor_names(list, list_anchor, depth, prev_label,
|
149
|
+
refer_list)
|
150
|
+
c = list_counter(list["start"] ? list["start"].to_i - 1 : 0, {})
|
137
151
|
list.xpath(ns("./li")).each do |li|
|
138
152
|
bare_label, label =
|
139
|
-
list_item_value(li, c, depth,
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
153
|
+
list_item_value(li, c, depth,
|
154
|
+
{ list_anchor:, prev_label:,
|
155
|
+
refer_list: depth == 1 ? refer_list : nil })
|
156
|
+
li["id"] ||= "_#{UUIDTools::UUID.random_create}"
|
157
|
+
@anchors[li["id"]] =
|
158
|
+
{ label: bare_label, bare_xref: "#{label})", type: "listitem",
|
159
|
+
xref: %[#{label}#{delim_wrap(list_item_delim)}], refer_list:,
|
160
|
+
container: list_anchor[:container] }
|
146
161
|
(li.xpath(ns(".//ol")) - li.xpath(ns(".//ol//ol"))).each do |ol|
|
147
162
|
list_item_anchor_names(ol, list_anchor, depth + 1, label,
|
148
163
|
refer_list)
|
@@ -152,18 +167,21 @@ module IsoDoc
|
|
152
167
|
|
153
168
|
def list_item_value(entry, counter, depth, opts)
|
154
169
|
label = counter.increment(entry).listlabel(entry.parent, depth)
|
170
|
+
s = semx(entry, label)
|
155
171
|
[label,
|
156
|
-
list_item_anchor_label(
|
172
|
+
list_item_anchor_label(s, opts[:list_anchor], opts[:prev_label],
|
157
173
|
opts[:refer_list])]
|
158
174
|
end
|
159
175
|
|
160
176
|
def list_item_anchor_label(label, list_anchor, prev_label, refer_list)
|
161
177
|
prev_label.empty? or
|
162
|
-
label = @i18n.list_nested_xref
|
163
|
-
.sub("%
|
178
|
+
label = @klass.connectives_spans(@i18n.list_nested_xref
|
179
|
+
.sub("%1", %[#{prev_label}#{delim_wrap(list_item_delim)}])
|
180
|
+
.sub("%2", label))
|
164
181
|
refer_list and
|
165
|
-
label = @i18n.list_nested_xref
|
166
|
-
.sub("%
|
182
|
+
label = @klass.connectives_spans(@i18n.list_nested_xref
|
183
|
+
.sub("%1", list_anchor[:xref])
|
184
|
+
.sub("%2", label))
|
167
185
|
label
|
168
186
|
end
|
169
187
|
|
@@ -172,7 +190,7 @@ module IsoDoc
|
|
172
190
|
notes = s.xpath(ns(".//dl")) - s.xpath(ns(".//clause//dl")) -
|
173
191
|
s.xpath(ns(".//appendix//dl")) - s.xpath(ns(".//dl//dl"))
|
174
192
|
deflist_anchor_names1(notes, Counter.new)
|
175
|
-
deflist_anchor_names(s.xpath(ns(
|
193
|
+
deflist_anchor_names(s.xpath(ns(child_sections)))
|
176
194
|
end
|
177
195
|
end
|
178
196
|
|
@@ -180,14 +198,15 @@ module IsoDoc
|
|
180
198
|
notes.noblank.each do |n|
|
181
199
|
@anchors[n["id"]] =
|
182
200
|
anchor_struct(increment_label(notes, n, counter), n,
|
183
|
-
@labels["deflist"], "deflist",
|
201
|
+
@labels["deflist"], "deflist",
|
202
|
+
{ unnumb: false, container: true })
|
184
203
|
deflist_term_anchor_names(n, @anchors[n["id"]])
|
185
204
|
end
|
186
205
|
end
|
187
206
|
|
188
207
|
def deflist_term_anchor_names(list, list_anchor)
|
189
208
|
list.xpath(ns("./dt")).each do |li|
|
190
|
-
label =
|
209
|
+
label = deflist_term_anchor_lbl(li, list_anchor)
|
191
210
|
li["id"] and @anchors[li["id"]] =
|
192
211
|
{ xref: label, type: "deflistitem",
|
193
212
|
container: list_anchor[:container] }
|
@@ -197,6 +216,11 @@ module IsoDoc
|
|
197
216
|
end
|
198
217
|
end
|
199
218
|
|
219
|
+
def deflist_term_anchor_lbl(listitem, list_anchor)
|
220
|
+
s = semx(listitem, dt2xreflabel(listitem))
|
221
|
+
%(#{list_anchor[:xref]}#{delim_wrap(":")} #{s}</semx>)
|
222
|
+
end
|
223
|
+
|
200
224
|
def dt2xreflabel(dterm)
|
201
225
|
label = dterm.dup
|
202
226
|
label.xpath(ns(".//p")).each { |x| x.replace(x.children) }
|