isodoc 3.4.2 → 3.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/isodoc/base_style/typography.scss +5 -0
- data/lib/isodoc/convert.rb +2 -1
- data/lib/isodoc/function/blocks.rb +33 -5
- data/lib/isodoc/function/blocks_example_note.rb +5 -3
- data/lib/isodoc/function/cleanup.rb +5 -4
- data/lib/isodoc/function/references.rb +11 -4
- data/lib/isodoc/function/setup.rb +1 -1
- data/lib/isodoc/function/table.rb +2 -2
- data/lib/isodoc/function/to_word_html.rb +1 -0
- data/lib/isodoc/function/utils.rb +1 -1
- data/lib/isodoc/init.rb +15 -6
- data/lib/isodoc/metadata.rb +6 -5
- data/lib/isodoc/metadata_contributor.rb +13 -0
- data/lib/isodoc/presentation_function/autonum.rb +65 -4
- data/lib/isodoc/presentation_function/bibdata.rb +15 -4
- data/lib/isodoc/presentation_function/block.rb +36 -78
- data/lib/isodoc/presentation_function/erefs.rb +55 -28
- data/lib/isodoc/presentation_function/erefs_locality.rb +18 -10
- data/lib/isodoc/presentation_function/footnotes.rb +2 -1
- data/lib/isodoc/presentation_function/image.rb +15 -5
- data/lib/isodoc/presentation_function/index.rb +1 -5
- data/lib/isodoc/presentation_function/inline.rb +0 -20
- data/lib/isodoc/presentation_function/list.rb +3 -3
- data/lib/isodoc/presentation_function/metadata.rb +50 -32
- data/lib/isodoc/presentation_function/refs.rb +57 -74
- data/lib/isodoc/presentation_function/section.rb +0 -3
- data/lib/isodoc/presentation_function/section_refs.rb +55 -0
- data/lib/isodoc/presentation_function/source.rb +73 -0
- data/lib/isodoc/presentation_function/terms.rb +7 -5
- data/lib/isodoc/presentation_function/xrefs.rb +17 -6
- data/lib/isodoc/presentation_xml_convert.rb +8 -3
- data/lib/isodoc/version.rb +1 -1
- data/lib/isodoc/word_function/lists.rb +4 -2
- data/lib/isodoc/word_function/postprocess_table.rb +3 -1
- data/lib/isodoc/xref/xref_gen.rb +72 -119
- data/lib/isodoc/xref/xref_gen_seq.rb +18 -14
- data/lib/isodoc/xref/xref_list_gen.rb +107 -0
- data/lib/isodoc/xref/xref_sect_asset.rb +0 -1
- data/lib/isodoc/xref.rb +1 -0
- data/lib/isodoc/xslfo_convert.rb +5 -1
- data/lib/isodoc-yaml/i18n-ar.yaml +9 -0
- data/lib/isodoc-yaml/i18n-de.yaml +9 -0
- data/lib/isodoc-yaml/i18n-en.yaml +9 -0
- data/lib/isodoc-yaml/i18n-es.yaml +9 -0
- data/lib/isodoc-yaml/i18n-fr.yaml +9 -0
- data/lib/isodoc-yaml/i18n-ja.yaml +9 -0
- data/lib/isodoc-yaml/i18n-ru.yaml +9 -0
- data/lib/isodoc-yaml/i18n-zh-Hans.yaml +9 -0
- metadata +5 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ab9b39e8179c40594c9f9665530cbbd6e5138379bd61e6b15799770a33032738
|
|
4
|
+
data.tar.gz: 6f3c2bd190862970a129ba9156c67dc4fc2610a90f1d561b8d057258c9f09420
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5d3f6c2eaaed487ae2c6921fb5ba4adcb52dd44c979e95a599532a0c3ebedf5471c25db030597cdf6dbac5f8eb1f17c0a51c1a9b608e5951226aa5098286b2d5
|
|
7
|
+
data.tar.gz: 51cc8feda89a2c3660723681bfe774cc17a926a8326be96466397c3c9efaa0185215e49e4bac84b8a0790f09e163003dbc1c9abb42838fbd3012285489ef7337
|
data/lib/isodoc/convert.rb
CHANGED
|
@@ -112,11 +112,12 @@ module IsoDoc
|
|
|
112
112
|
docxml = Nokogiri::XML(file, &:huge)
|
|
113
113
|
filename, dir = init_file(input_filename, debug)
|
|
114
114
|
docxml.root.default_namespace = ""
|
|
115
|
+
docxml_var_init(docxml)
|
|
115
116
|
convert_i18n_init(docxml)
|
|
116
117
|
metadata_init(@lang, @script, @locale, @i18n)
|
|
117
118
|
xref_init(@lang, @script, self, @i18n,
|
|
118
119
|
{ locale: @locale, bibrender: @bibrender })
|
|
119
|
-
|
|
120
|
+
@xrefs.klass.doctype = @doctype
|
|
120
121
|
[docxml, filename, dir]
|
|
121
122
|
end
|
|
122
123
|
|
|
@@ -118,6 +118,30 @@ module IsoDoc
|
|
|
118
118
|
end
|
|
119
119
|
end
|
|
120
120
|
|
|
121
|
+
def key_parse(node, out)
|
|
122
|
+
klass = "key #{node['class']}".strip
|
|
123
|
+
out.div **attr_code(class: klass) do |div|
|
|
124
|
+
node.children.each do |n|
|
|
125
|
+
if n.name == "name"
|
|
126
|
+
key_name_parse(n, div)
|
|
127
|
+
"<p keep-with-next='true'><strong>#{@i18n.key}</strong></p>"
|
|
128
|
+
else parse(n, div)
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
def key_name_parse(node, div)
|
|
135
|
+
a = keep_style(node)
|
|
136
|
+
a&.include?("page-break-after:") or
|
|
137
|
+
a = "page-break-after: avoid;#{a}"
|
|
138
|
+
div.p style: a do |p|
|
|
139
|
+
p.b do |s|
|
|
140
|
+
children_parse(node, s)
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
|
|
121
145
|
def para_class(node)
|
|
122
146
|
classtype = nil
|
|
123
147
|
classtype = "MsoCommentText" if in_comment
|
|
@@ -137,13 +161,17 @@ module IsoDoc
|
|
|
137
161
|
|
|
138
162
|
def para_parse(node, out)
|
|
139
163
|
out.p **attr_code(para_attrs(node)) do |p|
|
|
140
|
-
|
|
164
|
+
para_prefix(node, p)
|
|
165
|
+
node.children.each { |n| parse(n, p) unless n.name == "note" }
|
|
141
166
|
end
|
|
167
|
+
node.xpath(ns("./note")).each { |n| parse(n, out) }
|
|
142
168
|
end
|
|
143
169
|
|
|
170
|
+
def para_prefix(node, out); end
|
|
171
|
+
|
|
144
172
|
def attribution_parse(node, out)
|
|
145
173
|
out.div class: "QuoteAttribution" do |div|
|
|
146
|
-
|
|
174
|
+
children_parse(node, div)
|
|
147
175
|
end
|
|
148
176
|
end
|
|
149
177
|
|
|
@@ -167,14 +195,14 @@ module IsoDoc
|
|
|
167
195
|
|
|
168
196
|
def toc_parse(node, out)
|
|
169
197
|
out.div class: "toc" do |div|
|
|
170
|
-
|
|
198
|
+
children_parse(node, div)
|
|
171
199
|
end
|
|
172
200
|
end
|
|
173
201
|
|
|
174
202
|
def source_parse(node, out)
|
|
175
203
|
out.div class: "BlockSource" do |d|
|
|
176
204
|
d.p do |p|
|
|
177
|
-
|
|
205
|
+
children_parse(node, p)
|
|
178
206
|
end
|
|
179
207
|
end
|
|
180
208
|
end
|
|
@@ -201,7 +229,7 @@ module IsoDoc
|
|
|
201
229
|
tag = node.parent.name == "fmt-footnote-container" ? "aside" : "div"
|
|
202
230
|
id = node["is_table"] ? node["reference"] : node["id"]
|
|
203
231
|
out.send tag, id: "fn:#{id}", class: "footnote" do |div|
|
|
204
|
-
|
|
232
|
+
children_parse(node, div)
|
|
205
233
|
end
|
|
206
234
|
end
|
|
207
235
|
end
|
|
@@ -4,7 +4,7 @@ module IsoDoc
|
|
|
4
4
|
def example_label(_node, div, name)
|
|
5
5
|
name.nil? and return
|
|
6
6
|
div.p class: "example-title" do |_p|
|
|
7
|
-
|
|
7
|
+
children_parse(name, div)
|
|
8
8
|
end
|
|
9
9
|
end
|
|
10
10
|
|
|
@@ -64,7 +64,9 @@ module IsoDoc
|
|
|
64
64
|
end
|
|
65
65
|
|
|
66
66
|
def starts_with_para?(node)
|
|
67
|
-
block_body_first_elem(node)
|
|
67
|
+
elem = block_body_first_elem(node) or return
|
|
68
|
+
elem.name == "p" || elem.elements.first&.name == "p" ||
|
|
69
|
+
block_body_first_elem(elem)&.name == "p"
|
|
68
70
|
end
|
|
69
71
|
|
|
70
72
|
def note_p_class
|
|
@@ -73,7 +75,7 @@ module IsoDoc
|
|
|
73
75
|
|
|
74
76
|
def note_p_parse(node, div)
|
|
75
77
|
name = node.at(ns("./fmt-name"))
|
|
76
|
-
para = node.at(ns("./p"))
|
|
78
|
+
para = node.at(ns("./p")) || node.at(ns("./semx/p"))
|
|
77
79
|
div.p **attr_code(class: note_p_class) do |p|
|
|
78
80
|
name and p.span class: "note_label" do |s|
|
|
79
81
|
name.children.each { |n| parse(n, s) }
|
|
@@ -8,8 +8,8 @@ module IsoDoc
|
|
|
8
8
|
def passthrough_cleanup(docxml)
|
|
9
9
|
docxml.split(%r{(<passthrough>|</passthrough>)}).each_slice(4)
|
|
10
10
|
.map do |a|
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
a.size > 2 and a[2] = HTMLEntities.new.decode(a[2])
|
|
12
|
+
[a[0], a[2]]
|
|
13
13
|
end.join
|
|
14
14
|
end
|
|
15
15
|
|
|
@@ -112,7 +112,8 @@ module IsoDoc
|
|
|
112
112
|
end
|
|
113
113
|
|
|
114
114
|
TABLENOTE_CSS = "div[@class = 'Note' or @class = 'BlockSource' " \
|
|
115
|
-
"or @class = 'TableFootnote' or @class = 'figdl']"
|
|
115
|
+
"or @class = 'TableFootnote' or @class = 'figdl' or @class = 'key']"
|
|
116
|
+
.freeze
|
|
116
117
|
|
|
117
118
|
def table_note_cleanup(docxml)
|
|
118
119
|
docxml.xpath("//table[dl or #{TABLENOTE_CSS}]").each do |t|
|
|
@@ -120,7 +121,7 @@ module IsoDoc
|
|
|
120
121
|
insert_here = new_fullcolspan_row(t, tfoot)
|
|
121
122
|
t.xpath("dl | p[@class = 'ListTitle'] | #{TABLENOTE_CSS}")
|
|
122
123
|
.each do |d|
|
|
123
|
-
|
|
124
|
+
d.parent = insert_here
|
|
124
125
|
end
|
|
125
126
|
end
|
|
126
127
|
end
|
|
@@ -3,10 +3,17 @@ module IsoDoc
|
|
|
3
3
|
module References
|
|
4
4
|
def bibitem_entry(list, bib, _ordinal, biblio)
|
|
5
5
|
list.p **attr_code(iso_bibitem_entry_attrs(bib, biblio)) do |ref|
|
|
6
|
-
|
|
7
|
-
tag&.children&.each { |n| parse(n, ref) }
|
|
6
|
+
children_parse(bib.at(ns("./biblio-tag")), ref)
|
|
8
7
|
reference_format(bib, ref)
|
|
9
8
|
end
|
|
9
|
+
bibitem_notes(list, bib, _ordinal, biblio)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def bibitem_notes(list, bib, _ordinal, biblio)
|
|
13
|
+
bib.xpath(ns("./formattedref/note")).each do |n|
|
|
14
|
+
parse(n, list)
|
|
15
|
+
list.parent.elements[-1]["class"] += biblio ? " Biblio" : " NormRef"
|
|
16
|
+
end
|
|
10
17
|
end
|
|
11
18
|
|
|
12
19
|
def iso_bibitem_entry_attrs(bib, biblio)
|
|
@@ -14,8 +21,8 @@ module IsoDoc
|
|
|
14
21
|
end
|
|
15
22
|
|
|
16
23
|
def reference_format(bib, out)
|
|
17
|
-
ftitle = bib.at(ns("./formattedref"))
|
|
18
|
-
ftitle
|
|
24
|
+
ftitle = bib.at(ns("./formattedref")) or return
|
|
25
|
+
ftitle.children.each { |n| n.name == "note" or parse(n, out) }
|
|
19
26
|
end
|
|
20
27
|
|
|
21
28
|
def biblio_list(refs, div, biblio)
|
|
@@ -42,6 +42,7 @@ module IsoDoc
|
|
|
42
42
|
|
|
43
43
|
def info(isoxml, out)
|
|
44
44
|
@meta.localdir = @localdir
|
|
45
|
+
@meta.presentation isoxml, out
|
|
45
46
|
@meta.code_css isoxml, out
|
|
46
47
|
@meta.title isoxml, out
|
|
47
48
|
@meta.subtitle isoxml, out
|
|
@@ -58,7 +59,6 @@ module IsoDoc
|
|
|
58
59
|
@meta.keywords isoxml, out
|
|
59
60
|
@meta.note isoxml, out
|
|
60
61
|
@meta.images isoxml, out
|
|
61
|
-
@meta.presentation isoxml, out
|
|
62
62
|
@meta.get
|
|
63
63
|
end
|
|
64
64
|
end
|
|
@@ -51,7 +51,7 @@ module IsoDoc
|
|
|
51
51
|
c = node["class"]
|
|
52
52
|
style = table_attrs_style(node, c)
|
|
53
53
|
attr_code(id: node["id"],
|
|
54
|
-
class: node["plain"] == "true" ?
|
|
54
|
+
class: node["plain"] == "true" ? "plain" : (c || "MsoISOTable"),
|
|
55
55
|
style: style, title: node["alt"])
|
|
56
56
|
end
|
|
57
57
|
|
|
@@ -93,7 +93,7 @@ module IsoDoc
|
|
|
93
93
|
end
|
|
94
94
|
|
|
95
95
|
def table_parse_tail(node, out)
|
|
96
|
-
(dl = node.at(ns("./
|
|
96
|
+
(dl = node.at(ns("./key"))) && parse(dl, out)
|
|
97
97
|
node.xpath(ns("./fmt-source")).each { |n| parse(n, out) }
|
|
98
98
|
node.xpath(ns("./note")).each { |n| parse(n, out) }
|
|
99
99
|
node.xpath(ns("./fmt-footnote-container/fmt-fn-body"))
|
|
@@ -241,6 +241,7 @@ module IsoDoc
|
|
|
241
241
|
when "fmt-annotation-start" then fmt_annotation_start_parse(node, out)
|
|
242
242
|
when "fmt-annotation-end" then fmt_annotation_end_parse(node, out)
|
|
243
243
|
when "fmt-annotation-body" then fmt_annotation_body_parse(node, out)
|
|
244
|
+
when "key" then key_parse(node, out)
|
|
244
245
|
else error_parse(node, out)
|
|
245
246
|
end
|
|
246
247
|
end
|
|
@@ -84,7 +84,7 @@ module IsoDoc
|
|
|
84
84
|
end
|
|
85
85
|
|
|
86
86
|
NOTE_CONTAINER_ANCESTOR = <<~XPATH.strip.freeze
|
|
87
|
-
.//ancestor::*[local-name() = 'annex' or local-name() = 'foreword' or local-name() = 'appendix' or local-name() = 'introduction' or local-name() = 'terms' or local-name() = 'acknowledgements' or local-name() = 'executivesummary' or local-name() = 'term' or local-name() = 'clause' or local-name() = 'references' or local-name() = 'figure' or local-name() = 'formula' or local-name() = 'table' or local-name() = 'example']/@id
|
|
87
|
+
.//ancestor::*[local-name() = 'annex' or local-name() = 'foreword' or local-name() = 'appendix' or local-name() = 'introduction' or local-name() = 'terms' or local-name() = 'acknowledgements' or local-name() = 'executivesummary' or local-name() = 'term' or local-name() = 'clause' or local-name() = 'references' or local-name() = 'figure' or local-name() = 'formula' or local-name() = 'table' or local-name() = 'example' or local-name() = 'bibitem']/@id
|
|
88
88
|
XPATH
|
|
89
89
|
|
|
90
90
|
# no recursion on references
|
data/lib/isodoc/init.rb
CHANGED
|
@@ -19,15 +19,24 @@ module IsoDoc
|
|
|
19
19
|
@i18n.l10n(expr, lang, script, opt)
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
-
def
|
|
22
|
+
def docxml_var_init(docxml)
|
|
23
|
+
doctype_init(docxml)
|
|
24
|
+
toc_init(docxml)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def doctype_init(docxml)
|
|
23
28
|
@doctype = docxml.at(ns("//bibdata/ext/doctype"))&.text
|
|
24
29
|
@subdoctype = docxml.at(ns("//bibdata/ext/subdoctype"))&.text
|
|
25
|
-
@
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
30
|
+
@docscheme = docxml.at(ns("//metanorma-extension/presentation-metadata/"\
|
|
31
|
+
"document-scheme"))&.text
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def toc_init(docxml)
|
|
35
|
+
x = "//metanorma-extension/presentation-metadata/" \
|
|
36
|
+
"toc-heading-levels"
|
|
37
|
+
n = docxml.at(ns(x.sub("toc", "doc-toc"))) and
|
|
29
38
|
@wordToClevels = n.text.to_i
|
|
30
|
-
n = docxml.at(ns(x.sub("
|
|
39
|
+
n = docxml.at(ns(x.sub("toc", "html-toc"))) and
|
|
31
40
|
@htmlToClevels = n.text.to_i
|
|
32
41
|
end
|
|
33
42
|
|
data/lib/isodoc/metadata.rb
CHANGED
|
@@ -52,6 +52,8 @@ module IsoDoc
|
|
|
52
52
|
def doctype(isoxml, _out)
|
|
53
53
|
b = isoxml.at(ns("//bibdata/ext/doctype#{NOLANG}")) || return
|
|
54
54
|
set(:doctype, status_print(b.text))
|
|
55
|
+
ba = isoxml.at(ns("//bibdata/ext/doctype/@abbreviation")) and
|
|
56
|
+
set(:doctype_abbr, status_print(ba.text))
|
|
55
57
|
b1 = isoxml.at(ns("//bibdata/ext/doctype#{currlang}")) || b
|
|
56
58
|
set(:doctype_display, status_print(b1.text))
|
|
57
59
|
b = isoxml.at(ns("//bibdata/ext/subdoctype#{NOLANG}")) || return
|
|
@@ -113,7 +115,7 @@ module IsoDoc
|
|
|
113
115
|
def draftinfo(draft, revdate)
|
|
114
116
|
return "" unless draft
|
|
115
117
|
|
|
116
|
-
draftinfo = " (#{@labels['draft_label']}
|
|
118
|
+
draftinfo = " (#{@labels['draft_label']} <esc>#{draft}</esc>"
|
|
117
119
|
draftinfo += ", #{revdate}" if revdate
|
|
118
120
|
draftinfo += ")"
|
|
119
121
|
l10n(draftinfo, @lang, @script)
|
|
@@ -191,11 +193,10 @@ module IsoDoc
|
|
|
191
193
|
end
|
|
192
194
|
|
|
193
195
|
def presentation(xml, _out)
|
|
194
|
-
xml.xpath(ns("//metanorma-extension/presentation-metadata")).each do |p|
|
|
195
|
-
|
|
196
|
-
lbl = "presentation_metadata_#{n.text}".to_sym
|
|
196
|
+
xml.xpath(ns("//metanorma-extension/presentation-metadata/*")).each do |p|
|
|
197
|
+
lbl = "presentation_metadata_#{p.name}".to_sym
|
|
197
198
|
m = get[lbl] || []
|
|
198
|
-
set(lbl, m <<
|
|
199
|
+
set(lbl, m << p.text)
|
|
199
200
|
end
|
|
200
201
|
end
|
|
201
202
|
|
|
@@ -53,6 +53,19 @@ module IsoDoc
|
|
|
53
53
|
def author(xml, _out)
|
|
54
54
|
personal_authors(xml)
|
|
55
55
|
agency(xml)
|
|
56
|
+
contributor_role(xml, "authorizer")
|
|
57
|
+
contributor_role(xml, "enabler")
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def contributor_role(xml, role)
|
|
61
|
+
ret = xml.xpath(ns("//bibdata/contributor[xmlns:role/@type = " \
|
|
62
|
+
"'#{role}']/organization"))
|
|
63
|
+
.each_with_object([]) do |org, m|
|
|
64
|
+
name = org.at(ns("./name[@language = '#{@lang}']")) ||
|
|
65
|
+
org.at(ns("./name"))
|
|
66
|
+
m << name.text
|
|
67
|
+
end
|
|
68
|
+
ret.empty? or set(role.to_sym, ret)
|
|
56
69
|
end
|
|
57
70
|
|
|
58
71
|
def iso?(org)
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
module IsoDoc
|
|
2
2
|
class PresentationXMLConvert < ::IsoDoc::Convert
|
|
3
3
|
def prefix_name(node, delims, label, elem)
|
|
4
|
+
sem_xml_descendant?(node) and return
|
|
4
5
|
label, delims = prefix_name_defaults(node, delims, label, elem)
|
|
5
6
|
name, ins, ids, number = prefix_name_prep(node, elem)
|
|
6
7
|
ins.next = fmt_xref_label(label, number, ids)
|
|
@@ -30,7 +31,6 @@ module IsoDoc
|
|
|
30
31
|
end
|
|
31
32
|
|
|
32
33
|
def prefix_name_labels(node)
|
|
33
|
-
#@new_ids ||= {}
|
|
34
34
|
id = "_#{UUIDTools::UUID.random_create}"
|
|
35
35
|
@new_ids[id] = nil
|
|
36
36
|
{ elem: node["id"], name: id }
|
|
@@ -78,7 +78,7 @@ module IsoDoc
|
|
|
78
78
|
end
|
|
79
79
|
|
|
80
80
|
def semx(node, label, element = "autonum")
|
|
81
|
-
id = node["id"] || node[:id] || elem[
|
|
81
|
+
id = node["id"] || node[:id] || elem["original-id"]
|
|
82
82
|
/<semx element='[^']+' source='#{id}'/.match?(label) and return label
|
|
83
83
|
l = stripsemx(label)
|
|
84
84
|
%(<semx element='#{element}' source='#{id}'>#{l}</semx>)
|
|
@@ -113,13 +113,22 @@ module IsoDoc
|
|
|
113
113
|
|
|
114
114
|
def prefix_container_fmt_xref_label(container, xref)
|
|
115
115
|
container or return xref
|
|
116
|
-
container_container =
|
|
116
|
+
container_container = prefix_container_container(container)
|
|
117
117
|
container_label =
|
|
118
118
|
prefix_container_fmt_xref_label(container_container,
|
|
119
119
|
@xrefs.anchor(container, :xref, false))
|
|
120
120
|
l10n(connectives_spans(@i18n.nested_xref
|
|
121
121
|
.sub("%1", "<span class='fmt-xref-container'>#{esc container_label}</span>")
|
|
122
|
-
.sub("%2", xref)))
|
|
122
|
+
.sub("%2", xref || "[Unknown]")))
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
def prefix_container_container(container)
|
|
126
|
+
container_container = @xrefs.anchor(container, :container, false)
|
|
127
|
+
if @xrefs.anchor(container, :type) == "bibitem"
|
|
128
|
+
p = @bibitem_lookup[container].parent
|
|
129
|
+
p and container_container ||= p["id"]
|
|
130
|
+
end
|
|
131
|
+
container_container
|
|
123
132
|
end
|
|
124
133
|
|
|
125
134
|
# detect whether string which may contain XML markup is empty
|
|
@@ -160,5 +169,57 @@ module IsoDoc
|
|
|
160
169
|
text.nil? || text.empty? and return text
|
|
161
170
|
"<esc>#{text}</esc>"
|
|
162
171
|
end
|
|
172
|
+
|
|
173
|
+
# do not change to Presentation XML rendering
|
|
174
|
+
# this is sensitive to ordering of Presentation XML processing:
|
|
175
|
+
# blocks > terms > inline
|
|
176
|
+
def sem_xml_descendant?(node)
|
|
177
|
+
ancestor_names = node.ancestors.map(&:name)
|
|
178
|
+
sem_xml_descendant_terms?(node, ancestor_names) and return true
|
|
179
|
+
sem_xml_descendant_inline?(node, ancestor_names) and return true
|
|
180
|
+
sem_xml_descendant_bibitem?(node, ancestor_names) and return true
|
|
181
|
+
sem_xml_descendant_provision?(node, ancestor_names) and return true
|
|
182
|
+
false
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
# keep Presentation XML blocks within provisions,
|
|
186
|
+
# they are processed separately
|
|
187
|
+
# into distinct Presentation XML fmt-provision later
|
|
188
|
+
def sem_xml_descendant_provision?(node, ancestor_names)
|
|
189
|
+
block?(node) and return false
|
|
190
|
+
(ancestor_names & %w[requirement recommendation permission]).any? &&
|
|
191
|
+
!ancestor_names.include?("fmt-provision")
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
def sem_xml_descendant_bibitem?(_node, ancestor_names)
|
|
195
|
+
ancestor_names.include?("bibitem") &&
|
|
196
|
+
%w[formattedref biblio-tag].none? do |name|
|
|
197
|
+
ancestor_names.include?(name)
|
|
198
|
+
end
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
def sem_xml_descendant_inline?(_node, ancestor_names)
|
|
202
|
+
%w[xref eref origin link name title newcontent]
|
|
203
|
+
.any? do |name|
|
|
204
|
+
ancestor_names.include?(name)
|
|
205
|
+
end and return true
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
# keep Presentation XML blocks within designations,
|
|
209
|
+
# they are processed separately
|
|
210
|
+
# into distinct Presentation XML fmt-* designations later
|
|
211
|
+
def sem_xml_descendant_terms?(node, ancestor_names)
|
|
212
|
+
block?(node) and return false
|
|
213
|
+
%w[preferred admitted deprecated related definition source]
|
|
214
|
+
.any? do |name|
|
|
215
|
+
ancestor_names.include?(name)
|
|
216
|
+
end
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
def block?(node)
|
|
220
|
+
%w(figure table note example termnote termexample formula sourcecode
|
|
221
|
+
admonition ul ol dl quote permission requirement recommendation)
|
|
222
|
+
.include?(node.name)
|
|
223
|
+
end
|
|
163
224
|
end
|
|
164
225
|
end
|
|
@@ -42,7 +42,8 @@ module IsoDoc
|
|
|
42
42
|
def bibdata_i18n(bib)
|
|
43
43
|
hash_translate(bib, @i18n.get["doctype_dict"], "./ext/doctype",
|
|
44
44
|
"//presentation-metadata/doctype-alias", @lang)
|
|
45
|
-
hash_translate(bib, @i18n.get["stage_dict"], "./status/stage",
|
|
45
|
+
hash_translate(bib, @i18n.get["stage_dict"], "./status/stage",
|
|
46
|
+
"//presentation-metadata/stage-alias", @lang)
|
|
46
47
|
hash_translate(bib, @i18n.get["substage_dict"], "./status/substage", nil,
|
|
47
48
|
@lang)
|
|
48
49
|
edition_translate(bib)
|
|
@@ -63,10 +64,20 @@ module IsoDoc
|
|
|
63
64
|
# to be mixed
|
|
64
65
|
def edition_translate(bibdata)
|
|
65
66
|
x = bibdata.at(ns("./edition")) or return
|
|
67
|
+
if @i18n.edition_ordinal && num = edition_integer?(bibdata)
|
|
68
|
+
tag_translate(x, @lang, @i18n
|
|
69
|
+
.populate("edition_ordinal", { "var1" => num }))
|
|
70
|
+
elsif @i18n.edition_cardinal
|
|
71
|
+
tag_translate(x, @lang, @i18n
|
|
72
|
+
.populate("edition_cardinal", { "var1" => x.text }))
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def edition_integer?(bibdata)
|
|
77
|
+
x = bibdata.at(ns("./edition[not(@language) or @language = '']"))
|
|
78
|
+
x or return
|
|
66
79
|
/^\d+$/.match?(x.text) or return
|
|
67
|
-
|
|
68
|
-
tag_translate(x, @lang, @i18n
|
|
69
|
-
.populate("edition_ordinal", { "var1" => x.text.to_i }))
|
|
80
|
+
x.text.to_i
|
|
70
81
|
end
|
|
71
82
|
|
|
72
83
|
def tag_translate(tag, lang, value)
|
|
@@ -24,15 +24,17 @@ module IsoDoc
|
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
def formula1(elem)
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
dl = elem.at(ns("./dl")) and dl.replace("<key>#{to_xml(dl)}</key>")
|
|
28
|
+
formula_where(elem.at(ns("./key")))
|
|
29
|
+
lbl = @xrefs.anchor(elem["id"], :label, false) ||
|
|
30
|
+
@xrefs.anchor(elem["original-id"], :label, false)
|
|
29
31
|
lbl.nil? || lbl.empty? or prefix_name(elem, {}, lbl, "name")
|
|
30
32
|
end
|
|
31
33
|
|
|
32
34
|
def formula_where(dlist)
|
|
33
35
|
dlist or return
|
|
34
36
|
dlist["class"] = "formula_dl"
|
|
35
|
-
where = dlist.xpath(ns("
|
|
37
|
+
where = dlist.xpath(ns(".//dt")).size > 1 ? @i18n.where : @i18n.where_one
|
|
36
38
|
dlist.previous = "<p keep-with-next='true'>#{where}</p>"
|
|
37
39
|
end
|
|
38
40
|
|
|
@@ -41,8 +43,9 @@ module IsoDoc
|
|
|
41
43
|
end
|
|
42
44
|
|
|
43
45
|
def example1(elem)
|
|
44
|
-
n = @xrefs.get[elem["id"]]
|
|
45
|
-
lbl = labelled_autonum(@i18n.example, elem["id"],
|
|
46
|
+
n = @xrefs.get[elem["id"]] || @xrefs.get[elem["original-id"]]
|
|
47
|
+
lbl = labelled_autonum(@i18n.example, elem["id"] || elem["original-id"],
|
|
48
|
+
n&.dig(:label))
|
|
46
49
|
prefix_name(elem, { caption: block_delim }, lbl, "name")
|
|
47
50
|
end
|
|
48
51
|
|
|
@@ -61,8 +64,9 @@ module IsoDoc
|
|
|
61
64
|
end
|
|
62
65
|
|
|
63
66
|
def note_label(elem)
|
|
64
|
-
n = @xrefs.get[elem["id"]]
|
|
65
|
-
labelled_autonum(@i18n.note, elem["id"],
|
|
67
|
+
n = @xrefs.get[elem["id"]] || @xrefs.get[elem["original-id"]]
|
|
68
|
+
labelled_autonum(@i18n.note, elem["id"] || elem["original-id"],
|
|
69
|
+
n&.dig(:label))
|
|
66
70
|
end
|
|
67
71
|
|
|
68
72
|
def admonition(docxml)
|
|
@@ -81,7 +85,9 @@ module IsoDoc
|
|
|
81
85
|
end
|
|
82
86
|
|
|
83
87
|
def admonition_numbered1(elem)
|
|
84
|
-
label = admonition_label(elem,
|
|
88
|
+
label = admonition_label(elem,
|
|
89
|
+
@xrefs.anchor(elem["id"] || elem["original-id"],
|
|
90
|
+
:label, false))
|
|
85
91
|
prefix_name(elem, { caption: block_delim }, label, "name")
|
|
86
92
|
end
|
|
87
93
|
|
|
@@ -89,7 +95,7 @@ module IsoDoc
|
|
|
89
95
|
lbl = if elem["type"] == "box" then @i18n.box
|
|
90
96
|
else @i18n.admonition[elem["type"]]&.upcase
|
|
91
97
|
end
|
|
92
|
-
labelled_autonum(lbl, elem["id"], num)
|
|
98
|
+
labelled_autonum(lbl, elem["id"] || elem["original-id"], num)
|
|
93
99
|
end
|
|
94
100
|
|
|
95
101
|
def admonition_delim(_elem)
|
|
@@ -106,8 +112,9 @@ module IsoDoc
|
|
|
106
112
|
table_css(elem)
|
|
107
113
|
labelled_ancestor(elem) and return
|
|
108
114
|
elem["unnumbered"] && !elem.at(ns("./name")) and return
|
|
109
|
-
n = @xrefs.anchor(elem["id"], :label, false)
|
|
110
|
-
lbl = labelled_autonum(lower2cap(@i18n.table),
|
|
115
|
+
n = @xrefs.anchor(elem["id"] || elem["original-id"], :label, false)
|
|
116
|
+
lbl = labelled_autonum(lower2cap(@i18n.table),
|
|
117
|
+
elem["id"] || elem["original-id"], n)
|
|
111
118
|
prefix_name(elem, { caption: table_delim }, lbl, "name")
|
|
112
119
|
end
|
|
113
120
|
|
|
@@ -142,83 +149,34 @@ module IsoDoc
|
|
|
142
149
|
|
|
143
150
|
def amend1(elem)
|
|
144
151
|
ret = semx_fmt_dup(elem)
|
|
145
|
-
ret.xpath(ns("./locality | ./localityStack |
|
|
146
|
-
"./classification | ./contributor"
|
|
152
|
+
ret.xpath(ns("./locality | ./localityStack | .//autonumber | " \
|
|
153
|
+
"./classification | ./contributor | ./fmt-name | " \
|
|
154
|
+
"./fmt-xref-label")).each(&:remove)
|
|
155
|
+
amend_newcontent(ret)
|
|
147
156
|
ret.xpath(ns("./newcontent")).each { |a| a.name = "quote" }
|
|
148
157
|
ret.xpath(ns("./description")).each { |a| a.replace(a.children) }
|
|
149
|
-
elem.xpath(ns(".//fmt-name | .//fmt-xref-label")).each(&:remove)
|
|
150
158
|
elem.next = ret
|
|
151
159
|
end
|
|
152
160
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
source_types(docxml)
|
|
160
|
-
docxml.xpath(ns("//fmt-source/source")).each do |f|
|
|
161
|
-
f.replace(semx_fmt_dup(f))
|
|
162
|
-
end
|
|
163
|
-
end
|
|
164
|
-
|
|
165
|
-
def source_types(docxml)
|
|
166
|
-
docxml.xpath(ns("//table/fmt-source")).each { |f| tablesource(f) }
|
|
167
|
-
docxml.xpath(ns("//figure/fmt-source")).each { |f| figuresource(f) }
|
|
168
|
-
end
|
|
169
|
-
|
|
170
|
-
def fmt_source(docxml)
|
|
171
|
-
n = docxml.xpath(ns("//source")) - docxml.xpath(ns("//term//source")) -
|
|
172
|
-
docxml.xpath(ns("//quote/source"))
|
|
173
|
-
n.each do |s|
|
|
174
|
-
dup = s.clone
|
|
175
|
-
modification_dup_align(s, dup)
|
|
176
|
-
s.next = "<fmt-source>#{to_xml(dup)}</fmt-source>"
|
|
177
|
-
end
|
|
178
|
-
end
|
|
179
|
-
|
|
180
|
-
def tablesource(elem)
|
|
181
|
-
source1(elem, :table)
|
|
182
|
-
end
|
|
183
|
-
|
|
184
|
-
def figuresource(elem)
|
|
185
|
-
source1(elem, :figure)
|
|
186
|
-
end
|
|
187
|
-
|
|
188
|
-
def source_join_delim(_elem)
|
|
189
|
-
"; "
|
|
190
|
-
end
|
|
191
|
-
|
|
192
|
-
def source1(elem, ancestor)
|
|
193
|
-
source_elems = source1_gather(elem)
|
|
194
|
-
source_elems.each do |e|
|
|
195
|
-
e.xpath(ns(".//origin")).each do |origin|
|
|
196
|
-
origin.wrap("<esc></esc>")
|
|
161
|
+
def amend_newcontent(elem)
|
|
162
|
+
elem.xpath(ns("./newcontent")).each do |a|
|
|
163
|
+
a.name = "quote"
|
|
164
|
+
a.xpath(ns("./clause")).each do |c|
|
|
165
|
+
amend_subclause(c, 1)
|
|
166
|
+
a.next = c
|
|
197
167
|
end
|
|
198
|
-
elem << "#{source_join_delim(elem)}#{to_xml(e.remove.children).strip}"
|
|
199
168
|
end
|
|
200
|
-
source1_label(elem, @i18n.l10n(to_xml(elem.children).strip), ancestor)
|
|
201
169
|
end
|
|
202
170
|
|
|
203
|
-
def
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
source_elems << elem
|
|
210
|
-
else break
|
|
211
|
-
end
|
|
171
|
+
def amend_subclause(clause, depth)
|
|
172
|
+
clause.xpath(ns("./title")).reverse_each do |t|
|
|
173
|
+
# t.name = "floating-title"
|
|
174
|
+
# t["depth"] ||= depth || "1"
|
|
175
|
+
t.name = "p"
|
|
176
|
+
t["type"] = "floating-title"
|
|
212
177
|
end
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
def source1_label(elem, sources, _ancestor)
|
|
217
|
-
elem.children = l10n("[#{@i18n.source}: #{esc sources}]")
|
|
218
|
-
end
|
|
219
|
-
|
|
220
|
-
def source_modification(mod)
|
|
221
|
-
termsource_modification(mod.parent)
|
|
178
|
+
clause.name = depth == 1 ? "quote" : "quote" # "div"
|
|
179
|
+
clause.xpath(ns("./clause")).each { |c| amend_subclause(c, depth + 1) }
|
|
222
180
|
end
|
|
223
181
|
|
|
224
182
|
def quote(docxml)
|