isodoc 2.5.10 → 2.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/isodoc.gemspec +1 -1
- data/lib/isodoc/base_style/metanorma_word.css +3 -3
- data/lib/isodoc/base_style/metanorma_word.scss +5 -3
- data/lib/isodoc/common.rb +13 -13
- data/lib/isodoc/convert.rb +4 -2
- data/lib/isodoc/function/blocks.rb +1 -4
- data/lib/isodoc/function/blocks_example_note.rb +1 -7
- data/lib/isodoc/function/inline.rb +2 -2
- data/lib/isodoc/function/references.rb +13 -15
- data/lib/isodoc/function/section.rb +35 -63
- data/lib/isodoc/function/section_titles.rb +0 -14
- data/lib/isodoc/function/to_word_html.rb +44 -21
- data/lib/isodoc/function/utils.rb +1 -0
- data/lib/isodoc/html_function/footnotes.rb +2 -2
- data/lib/isodoc/html_function/html.rb +0 -10
- data/lib/isodoc/init.rb +11 -3
- data/lib/isodoc/metadata.rb +3 -3
- data/lib/isodoc/metadata_contributor.rb +7 -1
- data/lib/isodoc/presentation_function/erefs.rb +2 -2
- data/lib/isodoc/presentation_function/image.rb +22 -10
- data/lib/isodoc/presentation_function/inline.rb +12 -13
- data/lib/isodoc/presentation_function/refs.rb +16 -3
- data/lib/isodoc/presentation_function/section.rb +39 -20
- data/lib/isodoc/presentation_function/terms.rb +7 -0
- data/lib/isodoc/presentation_function/xrefs.rb +4 -4
- data/lib/isodoc/presentation_xml_convert.rb +3 -1
- data/lib/isodoc/version.rb +1 -1
- data/lib/isodoc/word_function/body.rb +15 -6
- data/lib/isodoc/word_function/inline.rb +3 -3
- data/lib/isodoc/word_function/postprocess.rb +20 -4
- data/lib/isodoc/xref/xref_gen.rb +5 -5
- data/lib/isodoc/xref/xref_sect_gen.rb +90 -34
- data/lib/isodoc-yaml/i18n-ar.yaml +1 -1
- data/lib/isodoc-yaml/i18n-de.yaml +1 -1
- data/lib/isodoc-yaml/i18n-en.yaml +1 -1
- data/lib/isodoc-yaml/i18n-es.yaml +1 -1
- data/lib/isodoc-yaml/i18n-fr.yaml +1 -1
- data/lib/isodoc-yaml/i18n-ja.yaml +1 -1
- data/lib/isodoc-yaml/i18n-ru.yaml +1 -1
- data/lib/isodoc-yaml/i18n-zh-Hans.yaml +1 -1
- metadata +4 -4
@@ -108,25 +108,37 @@ module IsoDoc
|
|
108
108
|
|
109
109
|
def svg_to_emf(node)
|
110
110
|
uri = svg_to_emf_uri(node)
|
111
|
-
|
112
|
-
(!node["height"] || node["height"] == "auto")
|
113
|
-
node["height"] = node.elements.first["height"]
|
114
|
-
node["width"] = node.elements.first["width"]
|
115
|
-
end
|
111
|
+
svg_impose_height_attr(node)
|
116
112
|
ret = imgfile_suffix(uri, "emf")
|
117
|
-
File.exist?(ret)
|
113
|
+
if File.exist?(ret) && File.exist?(node["src"])
|
114
|
+
warn "Exists: #{ret}, Exists: #{node['src']}"
|
115
|
+
return ret
|
116
|
+
end
|
117
|
+
warn "Converting..."
|
118
118
|
inkscape_convert(uri, ret, '--export-type="emf"')
|
119
119
|
end
|
120
120
|
|
121
|
+
def svg_impose_height_attr(node)
|
122
|
+
e = node.elements&.first or return
|
123
|
+
(e.name == "svg" &&
|
124
|
+
(!node["height"] || node["height"] == "auto")) or return
|
125
|
+
node["height"] = e["height"]
|
126
|
+
node["width"] = e["width"]
|
127
|
+
end
|
128
|
+
|
121
129
|
def inkscape_convert(uri, file, option)
|
122
130
|
exe = inkscape_installed? or raise "Inkscape missing in PATH, unable" \
|
123
131
|
"to convert image #{uri}. Aborting."
|
124
132
|
uri = Metanorma::Utils::external_path uri
|
125
133
|
exe = Metanorma::Utils::external_path exe
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
134
|
+
warn %(#{exe} #{option} #{uri})
|
135
|
+
err = system %(#{exe} #{option} #{uri})
|
136
|
+
File.exist?(file) and return Metanorma::Utils::datauri(file)
|
137
|
+
file2 = uri + File.extname(file)
|
138
|
+
warn "Checking #{file2}"
|
139
|
+
warn `ls #{File.dirname(file2)}`
|
140
|
+
File.exist?(file2) and return Metanorma::Utils::datauri(file2)
|
141
|
+
raise %(Fail on #{exe} #{option} #{uri} outputting #{file}: status #{err})
|
130
142
|
end
|
131
143
|
|
132
144
|
def svg_to_emf_uri(node)
|
@@ -10,10 +10,10 @@ module IsoDoc
|
|
10
10
|
|
11
11
|
def get_linkend(node)
|
12
12
|
node["style"] == "id" and anchor_id_postprocess(node)
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
xref_empty?(node) or return
|
14
|
+
target = docid_l10n(node["target"]) ||
|
15
|
+
expand_citeas(docid_l10n(node["citeas"]))
|
16
|
+
link = anchor_linkend(node, target)
|
17
17
|
link += eref_localities(node.xpath(ns("./locality | ./localityStack")),
|
18
18
|
link, node)
|
19
19
|
non_locality_elems(node).each(&:remove)
|
@@ -24,8 +24,7 @@ module IsoDoc
|
|
24
24
|
# <locality type="section"><reference>3.1</reference></locality></origin>
|
25
25
|
|
26
26
|
def unnest_linkend(node)
|
27
|
-
|
28
|
-
|
27
|
+
node.at(ns("./xref[@nested]")) or return
|
29
28
|
node.xpath(ns("./xref[@nested]")).each { |x| x.delete("nested") }
|
30
29
|
node.xpath(ns("./location | ./locationStack")).each(&:remove)
|
31
30
|
node.replace(node.children)
|
@@ -64,15 +63,15 @@ module IsoDoc
|
|
64
63
|
get_linkend(node)
|
65
64
|
end
|
66
65
|
|
67
|
-
def variant(
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
66
|
+
def variant(xml)
|
67
|
+
b = xml.xpath(ns("//bibdata//variant"))
|
68
|
+
(xml.xpath(ns("//variant")) - b).each { |f| variant1(f) }
|
69
|
+
(xml.xpath(ns("//variant[@remove = 'true']")) - b).each(&:remove)
|
70
|
+
(xml.xpath(ns("//variant")) - b).each do |v|
|
71
|
+
v.next&.name == "variant" or next
|
73
72
|
v.next = "/"
|
74
73
|
end
|
75
|
-
|
74
|
+
(xml.xpath(ns("//variant")) - b).each { |f| f.replace(f.children) }
|
76
75
|
end
|
77
76
|
|
78
77
|
def variant1(node)
|
@@ -7,9 +7,21 @@ module IsoDoc
|
|
7
7
|
bibitem(x, renderings)
|
8
8
|
end
|
9
9
|
hidden_items(docxml)
|
10
|
+
move_norm_ref_to_sections(docxml)
|
10
11
|
@xrefs.parse_inclusions(refs: true).parse(docxml)
|
11
12
|
end
|
12
13
|
|
14
|
+
def move_norm_ref_to_sections(docxml)
|
15
|
+
docxml.at(ns(@xrefs.klass.norm_ref_xpath)) or return
|
16
|
+
s = docxml.at(ns("//sections")) ||
|
17
|
+
docxml.at(ns("//preface"))&.after("<sections/>")&.next_element ||
|
18
|
+
docxml.at(ns("//annex | //bibliography"))&.before("<sections/>")
|
19
|
+
&.previous_element or return
|
20
|
+
docxml.xpath(ns(@xrefs.klass.norm_ref_xpath)).each do |r|
|
21
|
+
s << r.remove
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
13
25
|
def hidden_items(docxml)
|
14
26
|
docxml.xpath(ns("//references[bibitem/@hidden = 'true']")).each do |x|
|
15
27
|
x.at(ns("./bibitem[not(@hidden = 'true')]")) and next
|
@@ -131,7 +143,8 @@ module IsoDoc
|
|
131
143
|
idents = @xrefs.klass.render_identifier(ids)
|
132
144
|
ret = if biblio then biblio_ref_entry_code(ordinal, idents, ids,
|
133
145
|
standard, datefn, bib)
|
134
|
-
else norm_ref_entry_code(ordinal, idents, ids, standard, datefn,
|
146
|
+
else norm_ref_entry_code(ordinal, idents, ids, standard, datefn,
|
147
|
+
bib)
|
135
148
|
end
|
136
149
|
bib << "<biblio-tag>#{ret}</biblio-tag>"
|
137
150
|
end
|
@@ -148,8 +161,8 @@ module IsoDoc
|
|
148
161
|
|
149
162
|
# if ids is just a number, only use that ([1] Non-Standard)
|
150
163
|
# else, use both ordinal, as prefix, and ids
|
151
|
-
def biblio_ref_entry_code(ordinal, ids, _id,
|
152
|
-
#standard and id = nil
|
164
|
+
def biblio_ref_entry_code(ordinal, ids, _id, _standard, datefn, _bib)
|
165
|
+
# standard and id = nil
|
153
166
|
ret = (ids[:ordinal] || ids[:metanorma] || "[#{ordinal}]")
|
154
167
|
if ids[:sdo]
|
155
168
|
ret = prefix_bracketed_ref(ret)
|
@@ -2,6 +2,14 @@ require_relative "refs"
|
|
2
2
|
|
3
3
|
module IsoDoc
|
4
4
|
class PresentationXMLConvert < ::IsoDoc::Convert
|
5
|
+
def middle_title(docxml)
|
6
|
+
s = docxml.at(ns("//sections")) or return
|
7
|
+
t = @meta.get[:doctitle]
|
8
|
+
t.nil? || t.empty? and return
|
9
|
+
s.children.first.previous =
|
10
|
+
"<p class='zzSTDTitle1'>#{t}</p>"
|
11
|
+
end
|
12
|
+
|
5
13
|
def clause(docxml)
|
6
14
|
docxml.xpath(ns("//clause | " \
|
7
15
|
"//terms | //definitions | //references"))
|
@@ -17,19 +25,18 @@ module IsoDoc
|
|
17
25
|
level = @xrefs.anchor(elem["id"], :level, false) ||
|
18
26
|
(elem.ancestors("clause, annex").size + 1)
|
19
27
|
t = elem.at(ns("./title")) and t["depth"] = level
|
20
|
-
|
21
|
-
@suppressheadingnumbers || elem["unnumbered"]
|
22
|
-
|
28
|
+
!elem.ancestors("boilerplate, metanorma-extension").empty? ||
|
29
|
+
@suppressheadingnumbers || elem["unnumbered"] and return
|
23
30
|
lbl = @xrefs.anchor(elem["id"], :label,
|
24
31
|
elem.parent.name != "sections") or return
|
25
32
|
prefix_name(elem, "<tab/>", "#{lbl}#{clausedelim}", "title")
|
26
33
|
end
|
27
34
|
|
28
35
|
def floattitle(docxml)
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
36
|
+
p = "//clause | //annex | //appendix | //introduction | //foreword | " \
|
37
|
+
"//preface/abstract | //acknowledgements | //terms | " \
|
38
|
+
"//definitions | //references | //colophon | //indexsect"
|
39
|
+
docxml.xpath(ns(p)).each do |f|
|
33
40
|
floattitle1(f)
|
34
41
|
end
|
35
42
|
# top-level
|
@@ -94,9 +101,9 @@ module IsoDoc
|
|
94
101
|
end
|
95
102
|
|
96
103
|
def display_order_at(docxml, xpath, idx)
|
97
|
-
|
98
|
-
|
104
|
+
c = docxml.at(ns(xpath)) or return idx
|
99
105
|
idx += 1
|
106
|
+
idx = preceding_floating_titles(c, idx)
|
100
107
|
c["displayorder"] = idx
|
101
108
|
idx
|
102
109
|
end
|
@@ -104,24 +111,36 @@ module IsoDoc
|
|
104
111
|
def display_order_xpath(docxml, xpath, idx)
|
105
112
|
docxml.xpath(ns(xpath)).each do |c|
|
106
113
|
idx += 1
|
114
|
+
idx = preceding_floating_titles(c, idx)
|
115
|
+
c["displayorder"] = idx
|
116
|
+
end
|
117
|
+
idx
|
118
|
+
end
|
119
|
+
|
120
|
+
def preceding_floating_titles(node, idx)
|
121
|
+
out = node.xpath("./preceding-sibling::*")
|
122
|
+
.reverse.each_with_object([]) do |p, m|
|
123
|
+
%w(note admonition p).include?(p.name) or break m
|
124
|
+
m << p
|
125
|
+
end
|
126
|
+
out.reject { |c| c["displayorder"] }.reverse.each do |c|
|
107
127
|
c["displayorder"] = idx
|
128
|
+
idx += 1
|
108
129
|
end
|
109
130
|
idx
|
110
131
|
end
|
111
132
|
|
112
133
|
def display_order(docxml)
|
113
134
|
i = 0
|
114
|
-
|
115
|
-
i
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
i = display_order_xpath(docxml, "//indexsect", i)
|
124
|
-
display_order_xpath(docxml, "//colophon/*", i)
|
135
|
+
d = @xrefs.clause_order(docxml)
|
136
|
+
%i(preface main annex back).each do |s|
|
137
|
+
d[s].each do |a|
|
138
|
+
i = if a[:multi]
|
139
|
+
display_order_xpath(docxml, a[:path], i)
|
140
|
+
else display_order_at(docxml, a[:path], i)
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
125
144
|
end
|
126
145
|
|
127
146
|
def clausetitle(docxml)
|
@@ -52,6 +52,7 @@ module IsoDoc
|
|
52
52
|
name << ", #{designation_grammar(g).join(', ')}"
|
53
53
|
designation_localization(desgn, name)
|
54
54
|
designation_pronunciation(desgn, name)
|
55
|
+
designation_bookmarks(desgn, name)
|
55
56
|
desgn.children = name.children
|
56
57
|
end
|
57
58
|
|
@@ -94,6 +95,12 @@ module IsoDoc
|
|
94
95
|
name << ", /#{to_xml(f.children)}/"
|
95
96
|
end
|
96
97
|
|
98
|
+
def designation_bookmarks(desgn, name)
|
99
|
+
desgn.xpath(ns(".//bookmark")).each do |b|
|
100
|
+
name << b.remove
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
97
104
|
def termexample(docxml)
|
98
105
|
docxml.xpath(ns("//termexample")).each { |f| example1(f) }
|
99
106
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
module IsoDoc
|
2
2
|
class PresentationXMLConvert < ::IsoDoc::Convert
|
3
3
|
def prefix_container(container, linkend, node, _target)
|
4
|
-
l10n(@i18n.nested_xref.sub(
|
5
|
-
.sub(
|
4
|
+
l10n(@i18n.nested_xref.sub("%1", anchor_xref(node, container))
|
5
|
+
.sub("%2", linkend))
|
6
6
|
end
|
7
7
|
|
8
8
|
def anchor_value(id)
|
@@ -133,8 +133,8 @@ module IsoDoc
|
|
133
133
|
end
|
134
134
|
|
135
135
|
def i18n_chain_boolean(value, entry)
|
136
|
-
@i18n.send("chain_#{entry[:conn]}").sub(
|
137
|
-
.sub(
|
136
|
+
@i18n.send("chain_#{entry[:conn]}").sub("%1", value)
|
137
|
+
.sub("%2", loc2xref(entry))
|
138
138
|
end
|
139
139
|
|
140
140
|
def can_conflate_xref_rendering?(locs)
|
@@ -47,9 +47,11 @@ module IsoDoc
|
|
47
47
|
# to deal with single-term and single-ref annexes
|
48
48
|
def section(docxml)
|
49
49
|
references docxml
|
50
|
+
# feeds middle_title
|
50
51
|
# triggers xrefs reparse, so put references before all other sections,
|
51
52
|
# which alter titles and thus can alter xrefs
|
52
|
-
rearrange_clauses docxml # feeds toc, display_order, clausetitle, clause
|
53
|
+
rearrange_clauses docxml # feeds toc, display_order, clausetitle, clause, middle_title
|
54
|
+
middle_title docxml
|
53
55
|
annex docxml
|
54
56
|
clause docxml # feeds clausetitle
|
55
57
|
term docxml
|
data/lib/isodoc/version.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
require_relative "
|
2
|
-
require_relative "
|
3
|
-
require_relative "
|
1
|
+
require_relative "table"
|
2
|
+
require_relative "inline"
|
3
|
+
require_relative "lists"
|
4
4
|
|
5
5
|
module IsoDoc
|
6
6
|
module WordFunction
|
@@ -29,25 +29,34 @@ module IsoDoc
|
|
29
29
|
def make_body2(body, docxml)
|
30
30
|
body.div class: "WordSection2" do |div2|
|
31
31
|
boilerplate docxml, div2
|
32
|
-
|
32
|
+
content(div2, docxml, ns("//preface/*[@displayorder]"))
|
33
33
|
div2.p { |p| p << " " } # placeholder
|
34
34
|
end
|
35
35
|
section_break(body)
|
36
36
|
end
|
37
37
|
|
38
|
+
MAIN_ELEMENTS =
|
39
|
+
"//sections/*[@displayorder] | //annex[@displayorder] | " \
|
40
|
+
"//bibliography/*[@displayorder] | //colophon/*[@displayorder] | " \
|
41
|
+
"//indexsect[@displayorder]".freeze
|
42
|
+
|
38
43
|
def make_body3(body, docxml)
|
39
44
|
body.div class: "WordSection3" do |div3|
|
40
|
-
|
45
|
+
content(div3, docxml, ns(self.class::MAIN_ELEMENTS))
|
41
46
|
footnotes div3
|
42
47
|
comments div3
|
43
48
|
end
|
44
49
|
end
|
45
50
|
|
46
|
-
def para_class(
|
51
|
+
def para_class(node)
|
47
52
|
return "Sourcecode" if @annotation
|
48
53
|
return "MsoCommentText" if @in_comment
|
49
54
|
return "Note" if @note
|
55
|
+
if node["type"] == "floating-title"
|
56
|
+
return "h#{node['depth']}"
|
57
|
+
end
|
50
58
|
|
59
|
+
n = node["class"] and return n
|
51
60
|
nil
|
52
61
|
end
|
53
62
|
|
@@ -8,7 +8,7 @@ module IsoDoc
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def section_break(body, continuous: false)
|
11
|
-
body.p do |p|
|
11
|
+
body.p class: "section-break" do |p|
|
12
12
|
if continuous
|
13
13
|
p.br clear: "all", style: "page-break-before:auto;" \
|
14
14
|
"mso-break-type:section-break"
|
@@ -19,7 +19,7 @@ module IsoDoc
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def page_break(out)
|
22
|
-
out.p do |p|
|
22
|
+
out.p class: "page-break" do |p|
|
23
23
|
p.br clear: "all",
|
24
24
|
style: "mso-special-character:line-break;" \
|
25
25
|
"page-break-before:always"
|
@@ -58,7 +58,7 @@ module IsoDoc
|
|
58
58
|
|
59
59
|
def xref_parse(node, out)
|
60
60
|
target = if /#/.match?(node["target"])
|
61
|
-
node["target"].sub(
|
61
|
+
node["target"].sub("#", ".doc#")
|
62
62
|
else
|
63
63
|
"##{node['target']}"
|
64
64
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require "fileutils"
|
2
|
-
require_relative "
|
3
|
-
require_relative "
|
4
|
-
require_relative "
|
2
|
+
require_relative "postprocess_cover"
|
3
|
+
require_relative "postprocess_toc"
|
4
|
+
require_relative "postprocess_table"
|
5
5
|
|
6
6
|
module IsoDoc
|
7
7
|
module WordFunction
|
@@ -16,7 +16,7 @@ module IsoDoc
|
|
16
16
|
|
17
17
|
def toWord(result, filename, dir, header)
|
18
18
|
result = from_xhtml(word_cleanup(to_xhtml(result)))
|
19
|
-
.gsub(
|
19
|
+
.gsub("-DOUBLE_HYPHEN_ESCAPE-", "--")
|
20
20
|
@wordstylesheet = wordstylesheet_update
|
21
21
|
Html2Doc.new(
|
22
22
|
filename: filename, imagedir: @localdir,
|
@@ -56,6 +56,7 @@ module IsoDoc
|
|
56
56
|
word_example_cleanup(docxml)
|
57
57
|
word_pseudocode_cleanup(docxml)
|
58
58
|
word_image_caption(docxml)
|
59
|
+
word_floating_titles(docxml)
|
59
60
|
word_section_breaks(docxml)
|
60
61
|
word_tab_clean(docxml)
|
61
62
|
authority_cleanup(docxml)
|
@@ -173,6 +174,21 @@ module IsoDoc
|
|
173
174
|
end
|
174
175
|
docxml
|
175
176
|
end
|
177
|
+
|
178
|
+
# move p.h1 (floating title) after any page, section breaks
|
179
|
+
def word_floating_titles(docxml)
|
180
|
+
docxml.xpath("//p[@class = 'section-break' or @class = 'page-break']")
|
181
|
+
.each do |b|
|
182
|
+
out = b.xpath("./preceding-sibling::*").reverse
|
183
|
+
.each_with_object([]) do |p, m|
|
184
|
+
(p.name == "p" && p["class"] == "h1") or break m
|
185
|
+
m << p
|
186
|
+
end
|
187
|
+
b.delete("class")
|
188
|
+
out.empty? and next
|
189
|
+
out[-1].previous = b.remove
|
190
|
+
end
|
191
|
+
end
|
176
192
|
end
|
177
193
|
end
|
178
194
|
end
|
data/lib/isodoc/xref/xref_gen.rb
CHANGED
@@ -44,7 +44,7 @@ module IsoDoc
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def termnote_label(note)
|
47
|
-
@labels["termnote"].gsub(
|
47
|
+
@labels["termnote"].gsub("%", note.to_s)
|
48
48
|
end
|
49
49
|
|
50
50
|
def increment_label(elems, node, counter, increment: true)
|
@@ -194,11 +194,11 @@ refer_list)
|
|
194
194
|
|
195
195
|
def list_item_anchor_label(label, list_anchor, prev_label, refer_list)
|
196
196
|
prev_label.empty? or
|
197
|
-
label = @i18n.list_nested_xref.sub(
|
198
|
-
.sub(
|
197
|
+
label = @i18n.list_nested_xref.sub("%1", "#{prev_label})")
|
198
|
+
.sub("%2", label)
|
199
199
|
refer_list and
|
200
|
-
label = @i18n.list_nested_xref.sub(
|
201
|
-
.sub(
|
200
|
+
label = @i18n.list_nested_xref.sub("%1", list_anchor[:xref])
|
201
|
+
.sub("%2", label)
|
202
202
|
label
|
203
203
|
end
|
204
204
|
|
@@ -1,18 +1,66 @@
|
|
1
1
|
module IsoDoc
|
2
2
|
module XrefGen
|
3
3
|
module Sections
|
4
|
+
def clause_order(docxml)
|
5
|
+
{ preface: clause_order_preface(docxml),
|
6
|
+
main: clause_order_main(docxml),
|
7
|
+
annex: clause_order_annex(docxml),
|
8
|
+
back: clause_order_back(docxml) }
|
9
|
+
end
|
10
|
+
|
11
|
+
def clause_order_preface(_docxml)
|
12
|
+
[{ path: "//preface/*", multi: true }]
|
13
|
+
end
|
14
|
+
|
15
|
+
def clause_order_main(docxml)
|
16
|
+
[
|
17
|
+
{ path: "//clause[@type = 'scope']" },
|
18
|
+
{ path: @klass.norm_ref_xpath },
|
19
|
+
{ path: "//sections/terms | " \
|
20
|
+
"//sections/clause[descendant::terms]" },
|
21
|
+
{ path: "//sections/definitions | " \
|
22
|
+
"//sections/clause[descendant::definitions][not(descendant::terms)]" },
|
23
|
+
{ path: @klass.middle_clause(docxml), multi: true },
|
24
|
+
]
|
25
|
+
end
|
26
|
+
|
27
|
+
def clause_order_annex(_docxml)
|
28
|
+
[{ path: "//annex", multi: true }]
|
29
|
+
end
|
30
|
+
|
31
|
+
def clause_order_back(_docxml)
|
32
|
+
[
|
33
|
+
{ path: @klass.bibliography_xpath },
|
34
|
+
{ path: "//indexsect", multi: true },
|
35
|
+
{ path: "//colophon/*", multi: true },
|
36
|
+
]
|
37
|
+
end
|
38
|
+
|
4
39
|
def back_anchor_names(xml)
|
5
40
|
if @parse_settings.empty? || @parse_settings[:clauses]
|
6
|
-
|
7
|
-
xml
|
41
|
+
annex_anchor_names(xml)
|
42
|
+
back_clauses_anchor_names(xml)
|
43
|
+
end
|
44
|
+
references(xml) if @parse_settings.empty? || @parse_settings[:refs]
|
45
|
+
end
|
46
|
+
|
47
|
+
def annex_anchor_names(xml)
|
48
|
+
i = Counter.new("@")
|
49
|
+
clause_order_annex(xml).each do |a|
|
50
|
+
xml.xpath(ns(a[:path])).each do |c|
|
8
51
|
annex_names(c, i.increment(c).print)
|
52
|
+
a[:multi] or break
|
9
53
|
end
|
10
|
-
|
11
|
-
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def back_clauses_anchor_names(xml)
|
58
|
+
clause_order_back(xml).each do |a|
|
59
|
+
xml.xpath(ns(a[:path])).each do |c|
|
60
|
+
back_names(c)
|
61
|
+
a[:multi] or break
|
12
62
|
end
|
13
|
-
xml.xpath(ns("//colophon/clause")).each { |b| preface_names(b) }
|
14
63
|
end
|
15
|
-
references(xml) if @parse_settings.empty? || @parse_settings[:refs]
|
16
64
|
end
|
17
65
|
|
18
66
|
def references(docxml)
|
@@ -21,20 +69,29 @@ module IsoDoc
|
|
21
69
|
end
|
22
70
|
end
|
23
71
|
|
24
|
-
def initial_anchor_names(
|
72
|
+
def initial_anchor_names(xml)
|
25
73
|
if @parse_settings.empty? || @parse_settings[:clauses]
|
26
|
-
|
27
|
-
|
74
|
+
preface_anchor_names(xml)
|
75
|
+
main_anchor_names(xml)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def preface_anchor_names(xml)
|
80
|
+
clause_order_preface(xml).each do |a|
|
81
|
+
xml.xpath(ns(a[:path])).each do |c|
|
82
|
+
preface_names(c)
|
83
|
+
a[:multi] or break
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def main_anchor_names(xml)
|
89
|
+
n = Counter.new
|
90
|
+
clause_order_main(xml).each do |a|
|
91
|
+
xml.xpath(ns(a[:path])).each do |c|
|
92
|
+
section_names(c, n, 1)
|
93
|
+
a[:multi] or break
|
28
94
|
end
|
29
|
-
# potentially overridden in middle_section_asset_names()
|
30
|
-
sequential_asset_names(doc.xpath(ns("//preface/*")))
|
31
|
-
n = Counter.new
|
32
|
-
n = section_names(doc.at(ns("//clause[@type = 'scope']")), n, 1)
|
33
|
-
n = section_names(doc.at(ns(@klass.norm_ref_xpath)), n, 1)
|
34
|
-
n = section_names(doc.at(ns("//sections/terms | " \
|
35
|
-
"//sections/clause[descendant::terms]")), n, 1)
|
36
|
-
n = section_names(doc.at(ns("//sections/definitions")), n, 1)
|
37
|
-
clause_names(doc, n)
|
38
95
|
end
|
39
96
|
end
|
40
97
|
|
@@ -57,8 +114,7 @@ module IsoDoc
|
|
57
114
|
ret = clause.at(ns("./title"))&.text
|
58
115
|
if use_elem_name && !ret
|
59
116
|
clause.name.capitalize
|
60
|
-
else
|
61
|
-
ret
|
117
|
+
else ret
|
62
118
|
end
|
63
119
|
end
|
64
120
|
|
@@ -67,8 +123,15 @@ module IsoDoc
|
|
67
123
|
|
68
124
|
# in StanDoc, prefaces have no numbering; they are referenced only by title
|
69
125
|
def preface_names(clause)
|
70
|
-
|
126
|
+
unnumbered_names(clause)
|
127
|
+
end
|
128
|
+
|
129
|
+
def back_names(clause)
|
130
|
+
unnumbered_names(clause)
|
131
|
+
end
|
71
132
|
|
133
|
+
def unnumbered_names(clause)
|
134
|
+
clause.nil? and return
|
72
135
|
preface_name_anchors(clause, 1,
|
73
136
|
clause_title(clause, use_elem_name: true))
|
74
137
|
clause.xpath(ns(SUBCLAUSES)).each_with_index do |c, i|
|
@@ -94,23 +157,15 @@ module IsoDoc
|
|
94
157
|
end
|
95
158
|
|
96
159
|
def middle_section_asset_names(doc)
|
97
|
-
middle_sections =
|
98
|
-
|
99
|
-
|
100
|
-
|
160
|
+
middle_sections =
|
161
|
+
"//clause[@type = 'scope'] | #{@klass.norm_ref_xpath} | " \
|
162
|
+
"//sections/terms | //preface/* | " \
|
163
|
+
"//sections/definitions | //clause[parent::sections]"
|
101
164
|
sequential_asset_names(doc.xpath(ns(middle_sections)))
|
102
165
|
end
|
103
166
|
|
104
|
-
def clause_names(docxml, num)
|
105
|
-
docxml.xpath(ns(@klass.middle_clause(docxml)))
|
106
|
-
.each_with_index do |c, _i|
|
107
|
-
section_names(c, num, 1)
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
167
|
def section_names(clause, num, lvl)
|
112
168
|
clause.nil? and return num
|
113
|
-
|
114
169
|
num.increment(clause)
|
115
170
|
section_name_anchors(clause, num.print, lvl)
|
116
171
|
clause.xpath(ns(SUBCLAUSES)).each_with_object(Counter.new) do |c, i|
|
@@ -138,7 +193,8 @@ module IsoDoc
|
|
138
193
|
obl = l10n("(#{@labels['inform_annex']})")
|
139
194
|
clause["obligation"] == "normative" and
|
140
195
|
obl = l10n("(#{@labels['norm_annex']})")
|
141
|
-
title = Common::case_with_markup(@labels["annex"], "capital",
|
196
|
+
title = Common::case_with_markup(@labels["annex"], "capital",
|
197
|
+
@script)
|
142
198
|
l10n("<strong>#{title} #{num}</strong><br/>#{obl}")
|
143
199
|
end
|
144
200
|
|
@@ -30,7 +30,7 @@ external_terms_boilerplate: |
|
|
30
30
|
<p> لأغراض هذا المستند ، تنطبق المصطلحات والتعريفات الواردة في%. </ p>
|
31
31
|
internal_external_terms_boilerplate: |
|
32
32
|
<p>لأغراض هذه الوثيقة ،تنطبق المصطلحات والتعاريف الواردة في % وما يلي.</p>
|
33
|
-
term_defined_in: "
|
33
|
+
term_defined_in: "(%)"
|
34
34
|
binary_and: "%1 و %2"
|
35
35
|
multiple_and: "%1, و %2"
|
36
36
|
binary_or: "%1 او %2"
|
@@ -32,7 +32,7 @@ external_terms_boilerplate: |
|
|
32
32
|
<p>Für die Zwecke dieses Dokuments gelten die in % angegebenen Begriffe und Definitionen.</p>
|
33
33
|
internal_external_terms_boilerplate: |
|
34
34
|
<p>Für die Zwecke dieses Dokuments gelten die in % und im Folgenden aufgeführten Begriffe und Definitionen.</p>
|
35
|
-
term_defined_in: "
|
35
|
+
term_defined_in: "(%)"
|
36
36
|
binary_and: "%1 und %2"
|
37
37
|
multiple_and: "%1, und %2"
|
38
38
|
binary_or: "%1 oder %2"
|
@@ -38,7 +38,7 @@ external_terms_boilerplate: |
|
|
38
38
|
internal_external_terms_boilerplate: |
|
39
39
|
<p>For the purposes of this document, the terms and definitions
|
40
40
|
given in % and the following apply.</p>
|
41
|
-
term_defined_in: "
|
41
|
+
term_defined_in: "(%)"
|
42
42
|
binary_and: "%1 and %2"
|
43
43
|
multiple_and: "%1, and %2"
|
44
44
|
binary_or: "%1 or %2"
|