isodoc 3.1.6 → 3.1.9
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/css_border_parser.rb +229 -0
- data/lib/isodoc/css_border_parser_vars.rb +211 -0
- data/lib/isodoc/function/blocks.rb +1 -1
- data/lib/isodoc/function/blocks_example_note.rb +0 -2
- data/lib/isodoc/function/footnotes.rb +4 -3
- data/lib/isodoc/function/inline.rb +1 -0
- data/lib/isodoc/function/lists.rb +0 -15
- data/lib/isodoc/function/section.rb +6 -2
- data/lib/isodoc/function/section_titles.rb +2 -2
- data/lib/isodoc/function/table.rb +1 -1
- data/lib/isodoc/function/terms.rb +1 -1
- data/lib/isodoc/function/to_word_html.rb +4 -1
- data/lib/isodoc/function/utils.rb +6 -15
- data/lib/isodoc/html_function/postprocess.rb +1 -2
- data/lib/isodoc/html_function/postprocess_cover.rb +14 -5
- data/lib/isodoc/init.rb +12 -3
- data/lib/isodoc/presentation_function/autonum.rb +4 -3
- data/lib/isodoc/presentation_function/block.rb +50 -10
- data/lib/isodoc/presentation_function/concepts.rb +19 -13
- data/lib/isodoc/presentation_function/docid.rb +2 -1
- data/lib/isodoc/presentation_function/erefs.rb +1 -2
- data/lib/isodoc/presentation_function/footnotes.rb +4 -4
- data/lib/isodoc/presentation_function/ids.rb +79 -0
- data/lib/isodoc/presentation_function/image.rb +1 -2
- data/lib/isodoc/presentation_function/inline.rb +13 -7
- data/lib/isodoc/presentation_function/math.rb +19 -23
- data/lib/isodoc/presentation_function/refs.rb +1 -1
- data/lib/isodoc/presentation_function/section.rb +11 -10
- data/lib/isodoc/presentation_function/terms.rb +50 -21
- data/lib/isodoc/presentation_function/title.rb +1 -3
- data/lib/isodoc/presentation_function/xrefs.rb +2 -2
- data/lib/isodoc/presentation_xml_convert.rb +3 -75
- data/lib/isodoc/version.rb +1 -1
- data/lib/isodoc/word_function/comments.rb +1 -2
- data/lib/isodoc/word_function/footnotes.rb +0 -29
- data/lib/isodoc/word_function/inline.rb +1 -1
- data/lib/isodoc/word_function/postprocess.rb +0 -1
- data/lib/isodoc/xref/xref_gen_seq.rb +5 -30
- data/lib/isodoc/xref/xref_sect_asset.rb +44 -0
- data/lib/isodoc/xref/xref_sect_gen.rb +39 -37
- data/lib/isodoc/xref/xref_util.rb +28 -1
- data/lib/isodoc-yaml/i18n-ar.yaml +1 -0
- data/lib/isodoc-yaml/i18n-de.yaml +1 -0
- data/lib/isodoc-yaml/i18n-en.yaml +1 -0
- data/lib/isodoc-yaml/i18n-es.yaml +1 -0
- data/lib/isodoc-yaml/i18n-fr.yaml +1 -0
- data/lib/isodoc-yaml/i18n-ja.yaml +1 -0
- data/lib/isodoc-yaml/i18n-ru.yaml +1 -0
- data/lib/isodoc-yaml/i18n-zh-Hans.yaml +1 -0
- data/lib/isodoc.rb +1 -1
- metadata +6 -2
@@ -26,8 +26,7 @@ module IsoDoc
|
|
26
26
|
|
27
27
|
def html_cleanup(html)
|
28
28
|
html = term_header(html_footnote_filter(html_preface(htmlstyle(html))))
|
29
|
-
|
30
|
-
html = (footnote_backlinks(html))
|
29
|
+
html = footnote_backlinks(html)
|
31
30
|
html = mathml(html_list_clean(remove_placeholder_paras(html)))
|
32
31
|
html_toc(heading_anchors(sourcecode_cleanup(html)))
|
33
32
|
end
|
@@ -82,7 +82,6 @@ module IsoDoc
|
|
82
82
|
def html_cover(docxml)
|
83
83
|
doc = to_xhtml_fragment(File.read(@htmlcoverpage, encoding: "UTF-8"))
|
84
84
|
d = docxml.at('//div[@class="title-section"]')
|
85
|
-
#d.children.first.add_previous_sibling(
|
86
85
|
d.add_first_child(
|
87
86
|
populate_template(doc.to_xml(encoding: "US-ASCII"), :html),
|
88
87
|
)
|
@@ -91,7 +90,6 @@ module IsoDoc
|
|
91
90
|
def html_intro(docxml)
|
92
91
|
doc = to_xhtml_fragment(File.read(@htmlintropage, encoding: "UTF-8"))
|
93
92
|
d = docxml.at('//div[@class="prefatory-section"]')
|
94
|
-
#d.children.first.add_previous_sibling(
|
95
93
|
d.add_first_child(
|
96
94
|
populate_template(doc.to_xml(encoding: "US-ASCII"), :html),
|
97
95
|
)
|
@@ -180,9 +178,20 @@ module IsoDoc
|
|
180
178
|
MATHJAX = <<~"MATHJAX".freeze
|
181
179
|
<script type="text/x-mathjax-config">
|
182
180
|
MathJax.Hub.Config({
|
183
|
-
"HTML-CSS": {
|
184
|
-
|
185
|
-
|
181
|
+
"HTML-CSS": {
|
182
|
+
preferredFont: "STIX",
|
183
|
+
linebreaks: {
|
184
|
+
automatic: true,
|
185
|
+
width: "container" // or specify something like "90%"/"30em"
|
186
|
+
}
|
187
|
+
},
|
188
|
+
MathML: {
|
189
|
+
linebreaks: {
|
190
|
+
automatic: true
|
191
|
+
}
|
192
|
+
},
|
193
|
+
asciimath2jax: { delimiters: [['(#(', ')#)']] }
|
194
|
+
});
|
186
195
|
</script>
|
187
196
|
<script src="#{MATHJAX_ADDR}?config=MML_HTMLorMML-full" async="async"></script>
|
188
197
|
MATHJAX
|
data/lib/isodoc/init.rb
CHANGED
@@ -143,9 +143,9 @@ module IsoDoc
|
|
143
143
|
self.class::AGENCIES.include?(text)
|
144
144
|
end
|
145
145
|
|
146
|
-
def docid_l10n(text)
|
146
|
+
def docid_l10n(text, citation: true)
|
147
147
|
text.nil? and return text
|
148
|
-
|
148
|
+
docid_all_parts(text, citation)
|
149
149
|
x = Nokogiri::XML::DocumentFragment.parse(text)
|
150
150
|
(x.xpath(".//text()") - x.xpath(".//fn//text()")).each do |n|
|
151
151
|
n.replace(n.text.gsub(/ /, " "))
|
@@ -153,10 +153,19 @@ module IsoDoc
|
|
153
153
|
to_xml(x)
|
154
154
|
end
|
155
155
|
|
156
|
+
def docid_all_parts(text, citation)
|
157
|
+
if citation
|
158
|
+
text.sub!(%r{\p{Zs}\(all\p{Zs}parts\)}, "")
|
159
|
+
else
|
160
|
+
@i18n.all_parts && !citation and
|
161
|
+
text.gsub!(/all\p{Zs}parts/, @i18n.all_parts.downcase)
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
156
165
|
def docid_prefix(prefix, docid)
|
157
166
|
docid = "#{prefix} #{docid}" if prefix && !omit_docid_prefix(prefix) &&
|
158
167
|
!/^#{prefix}\b/.match(docid)
|
159
|
-
docid_l10n(docid)
|
168
|
+
docid_l10n(docid, citation: false)
|
160
169
|
end
|
161
170
|
|
162
171
|
def omit_docid_prefix(prefix)
|
@@ -11,7 +11,7 @@ module IsoDoc
|
|
11
11
|
prefix_name_postprocess(node, elem)
|
12
12
|
end
|
13
13
|
|
14
|
-
def prefix_name_defaults(
|
14
|
+
def prefix_name_defaults(_node, delims, label)
|
15
15
|
label&.empty? and label = nil
|
16
16
|
delims.nil? and delims = {}
|
17
17
|
[label, delims]
|
@@ -80,7 +80,7 @@ module IsoDoc
|
|
80
80
|
end
|
81
81
|
|
82
82
|
def autonum(id, num)
|
83
|
-
|
83
|
+
num.include?("<semx") and return num # already contains markup
|
84
84
|
"<semx element='autonum' source='#{id}'>#{num}</semx>"
|
85
85
|
end
|
86
86
|
|
@@ -135,7 +135,8 @@ module IsoDoc
|
|
135
135
|
end
|
136
136
|
|
137
137
|
def fmt_caption_label_wrap(label)
|
138
|
-
empty_xml?(label) ||
|
138
|
+
empty_xml?(label) ||
|
139
|
+
%r{<span class=['"]fmt-caption-label['"]}.match?(label) or
|
139
140
|
label = "<span class='fmt-caption-label'>#{label}</span>"
|
140
141
|
label
|
141
142
|
end
|
@@ -102,6 +102,7 @@ module IsoDoc
|
|
102
102
|
|
103
103
|
def table1(elem)
|
104
104
|
table_fn(elem)
|
105
|
+
table_css(elem)
|
105
106
|
labelled_ancestor(elem) and return
|
106
107
|
elem["unnumbered"] && !elem.at(ns("./name")) and return
|
107
108
|
n = @xrefs.anchor(elem["id"], :label, false)
|
@@ -109,6 +110,16 @@ module IsoDoc
|
|
109
110
|
prefix_name(elem, { caption: table_delim }, l10n(lbl), "name")
|
110
111
|
end
|
111
112
|
|
113
|
+
def table_css(elem)
|
114
|
+
parser = IsoDoc::CssBorderParser::BorderParser.new
|
115
|
+
elem.xpath(ns(".//tr | .//th | .//td")).each do |n|
|
116
|
+
n["style"] or next
|
117
|
+
parsed_properties = parser.parse_declaration(n["style"])
|
118
|
+
new_style = parser.to_css_string(parsed_properties)
|
119
|
+
n["style"] = new_style
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
112
123
|
def table_delim
|
113
124
|
block_delim
|
114
125
|
end
|
@@ -131,34 +142,63 @@ module IsoDoc
|
|
131
142
|
def amend1(elem)
|
132
143
|
ret = semx_fmt_dup(elem)
|
133
144
|
ret.xpath(ns("./locality | ./localityStack | ./autonumber | " \
|
134
|
-
|
145
|
+
"./classification | ./contributor")).each(&:remove)
|
135
146
|
ret.xpath(ns("./newcontent")).each { |a| a.name = "quote" }
|
136
147
|
ret.xpath(ns("./description")).each { |a| a.replace(a.children) }
|
137
148
|
elem.xpath(ns(".//fmt-name | .//fmt-xref-label")).each(&:remove)
|
138
149
|
elem.next = ret
|
139
150
|
end
|
140
151
|
|
152
|
+
# TODO will go back to just one source/modification, preserving it
|
141
153
|
def source(docxml)
|
142
|
-
docxml
|
154
|
+
fmt_source(docxml)
|
155
|
+
docxml.xpath(ns("//fmt-source/source/modification")).each do |f|
|
143
156
|
source_modification(f)
|
144
157
|
end
|
145
|
-
docxml
|
146
|
-
docxml.xpath(ns("//
|
158
|
+
source_types(docxml)
|
159
|
+
docxml.xpath(ns("//fmt-source/source")).each do |f|
|
160
|
+
f.replace(semx_fmt_dup(f))
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
def source_types(docxml)
|
165
|
+
docxml.xpath(ns("//table/fmt-source")).each { |f| tablesource(f) }
|
166
|
+
docxml.xpath(ns("//figure/fmt-source")).each { |f| figuresource(f) }
|
167
|
+
end
|
168
|
+
|
169
|
+
def fmt_source(docxml)
|
170
|
+
n = docxml.xpath(ns("//source")) - docxml.xpath(ns("//term//source")) -
|
171
|
+
docxml.xpath(ns("//quote/source"))
|
172
|
+
n.each do |s|
|
173
|
+
dup = s.clone
|
174
|
+
modification_dup_align(s, dup)
|
175
|
+
s.next = "<fmt-source>#{to_xml(dup)}</fmt-source>"
|
176
|
+
end
|
147
177
|
end
|
148
178
|
|
149
179
|
def tablesource(elem)
|
150
|
-
source1(elem)
|
180
|
+
source1(elem, :table)
|
151
181
|
end
|
152
182
|
|
153
183
|
def figuresource(elem)
|
154
|
-
source1(elem)
|
184
|
+
source1(elem, :figure)
|
155
185
|
end
|
156
186
|
|
157
|
-
def source1(elem)
|
158
|
-
|
159
|
-
|
187
|
+
def source1(elem, ancestor)
|
188
|
+
n = elem
|
189
|
+
while n = n&.next_element
|
190
|
+
case n.name
|
191
|
+
when "source"
|
192
|
+
when "fmt-source"
|
193
|
+
elem << "; #{to_xml(n.remove.children)}"
|
194
|
+
else break
|
195
|
+
end
|
160
196
|
end
|
161
|
-
elem
|
197
|
+
source1_label(elem, to_xml(elem.children).strip, ancestor)
|
198
|
+
end
|
199
|
+
|
200
|
+
def source1_label(elem, sources, _ancestor)
|
201
|
+
elem.children = l10n("[#{@i18n.source}: #{sources}]")
|
162
202
|
end
|
163
203
|
|
164
204
|
def source_modification(mod)
|
@@ -7,7 +7,7 @@ module IsoDoc
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def concept1(node)
|
10
|
-
node.ancestors("definition,
|
10
|
+
node.ancestors("definition, source, related").empty? or return
|
11
11
|
xref = node&.at(ns("./semx/fmt-xref/@target"))&.text or
|
12
12
|
return concept_render(node, ital: "true", ref: "true", bold: "false",
|
13
13
|
linkref: "true", linkmention: "false")
|
@@ -30,8 +30,7 @@ module IsoDoc
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def concept_dup(node, ret)
|
33
|
-
node
|
34
|
-
"xmlns:fmt-origin | xmlns:fmt-link]").each(&:remove)
|
33
|
+
concept_dup_cleanup_orig(node)
|
35
34
|
ret.xpath(ns(".//xref | .//eref | .//origin | .//link")).each(&:remove)
|
36
35
|
ret.xpath(ns(".//semx")).each do |s|
|
37
36
|
s.children.empty? and s.remove
|
@@ -41,6 +40,16 @@ module IsoDoc
|
|
41
40
|
node.next = f
|
42
41
|
end
|
43
42
|
|
43
|
+
def concept_dup_cleanup_orig(node)
|
44
|
+
node.xpath(".//xmlns:semx[xmlns:fmt-xref | xmlns:fmt-eref | " \
|
45
|
+
"xmlns:fmt-origin | xmlns:fmt-link]").each(&:remove)
|
46
|
+
node.xpath(ns(".//xref | .//eref | .//origin | .//link")).each do |x|
|
47
|
+
x["original-id"] or next
|
48
|
+
x["id"] = x["original-id"]
|
49
|
+
x.delete("original-id")
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
44
53
|
def concept1_style(node, opts)
|
45
54
|
r = node.at(ns(".//renderterm")) or return
|
46
55
|
opts[:ital] == "true" and r.children = "<em>#{to_xml(r.children)}</em>"
|
@@ -103,13 +112,9 @@ module IsoDoc
|
|
103
112
|
def related1(node)
|
104
113
|
p, ref, orig = related1_prep(node)
|
105
114
|
label = @i18n.relatedterms[orig["type"]].upcase
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
else
|
110
|
-
node.children = (l10n("<p><strong>#{label}:</strong> " \
|
111
|
-
"<strong>**RELATED TERM NOT FOUND**</strong></p>"))
|
112
|
-
end
|
115
|
+
ret = "<strong>**RELATED TERM NOT FOUND**</strong>"
|
116
|
+
p && ref and ret = "<em>#{to_xml(p)}</em> (#{Common::to_xml(ref)})"
|
117
|
+
node.children = (l10n("<p><strong>#{label}:</strong> #{ret}</p>"))
|
113
118
|
end
|
114
119
|
|
115
120
|
def related1_prep(node)
|
@@ -152,8 +157,7 @@ module IsoDoc
|
|
152
157
|
.with_object([]) do |(p, i), m|
|
153
158
|
if (i.zero? && (pref = p)) || merge_preferred_eligible?(pref, p)
|
154
159
|
m << p
|
155
|
-
else
|
156
|
-
p.wrap("<p></p>")
|
160
|
+
else p.wrap("<p></p>")
|
157
161
|
end
|
158
162
|
end
|
159
163
|
pref&.replace(merge_second_preferred1(out, term))
|
@@ -188,7 +192,9 @@ module IsoDoc
|
|
188
192
|
desgn.parent.name == "related" and return
|
189
193
|
out = desgn.parent.at(ns("./fmt-#{desgn.name}"))
|
190
194
|
d1 = semx_fmt_dup(desgn)
|
191
|
-
s = d1.at(ns("./
|
195
|
+
s = d1.at(ns("./source"))
|
196
|
+
s0 = desgn.at(ns("./source"))
|
197
|
+
modification_dup_align(s0, s)
|
192
198
|
name = d1.at(ns("./expression/name | ./letter-symbol/name | " \
|
193
199
|
"./graphical-symbol")) or return
|
194
200
|
designation_annotate(d1, name, desgn)
|
@@ -13,7 +13,8 @@ module IsoDoc
|
|
13
13
|
ret = pref_ref_code_parse(bib) or return nil
|
14
14
|
ins = bib.at(ns("./docidentifier[last()]"))
|
15
15
|
ret.reverse_each do |r|
|
16
|
-
|
16
|
+
id = docid_l10n(r, citation: false)
|
17
|
+
ins.next = "<docidentifier scope='biblio-tag'>#{id}</docidentifier>"
|
17
18
|
end
|
18
19
|
ret
|
19
20
|
end
|
@@ -15,7 +15,7 @@ module IsoDoc
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def citeas_cleanup(ref)
|
18
|
-
if
|
18
|
+
if ref.include?("<")
|
19
19
|
xml = Nokogiri::XML("<root>#{ref}</root>")
|
20
20
|
xml.xpath("//semx").each { |x| x.replace(x.children) }
|
21
21
|
ref = to_xml(xml.at("//root").children)
|
@@ -33,7 +33,6 @@ module IsoDoc
|
|
33
33
|
[e["connective"], to_xml(e.parent.remove)]
|
34
34
|
end.flatten
|
35
35
|
ret = resolve_eref_connectives(locs)
|
36
|
-
elem["id"] ||= "_#{UUIDTools::UUID.random_create}"
|
37
36
|
elem.next = "<semx element='erefstack' source='#{elem['id']}'>#{ret[1]}</semx>"
|
38
37
|
end
|
39
38
|
|
@@ -3,11 +3,12 @@ module IsoDoc
|
|
3
3
|
def footnote_collect(fnotes)
|
4
4
|
seen = {}
|
5
5
|
fnotes.each_with_object([]) do |x, m|
|
6
|
-
x["id"] ||= "_#{UUIDTools::UUID.random_create}"
|
7
6
|
seen[x["reference"]] or m << fnbody(x, seen)
|
8
7
|
x["target"] = seen[x["reference"]]
|
9
8
|
ref = x["hiddenref"] == "true" ? "" : fn_ref_label(x)
|
10
|
-
x <<
|
9
|
+
x << <<~FNOTE.strip
|
10
|
+
<fmt-fn-label><span class='fmt-caption-label'>#{ref}</span</fmt-fn-label>
|
11
|
+
FNOTE
|
11
12
|
end
|
12
13
|
end
|
13
14
|
|
@@ -35,7 +36,7 @@ module IsoDoc
|
|
35
36
|
body.at(ns("./semx")).children.first.before("<p> </p>").previous
|
36
37
|
lbl = fn_body_label(fnote)
|
37
38
|
ins.children.first.previous = <<~FNOTE.strip
|
38
|
-
<fmt-fn-label>#{lbl}
|
39
|
+
<fmt-fn-label><span class='fmt-caption-label'>#{lbl}</span><span class="fmt-caption-delim"><tab/></fmt-fn-label>
|
39
40
|
FNOTE
|
40
41
|
end
|
41
42
|
|
@@ -145,7 +146,6 @@ module IsoDoc
|
|
145
146
|
end
|
146
147
|
|
147
148
|
def comment_body(elem)
|
148
|
-
elem["id"] ||= "_#{UUIDTools::UUID.random_create}"
|
149
149
|
c1 = elem.after("<fmt-review-body/>").next
|
150
150
|
elem.attributes.each_key { |k| c1[k] = elem[k] }
|
151
151
|
c1["id"] = "_#{UUIDTools::UUID.random_create}"
|
@@ -0,0 +1,79 @@
|
|
1
|
+
module IsoDoc
|
2
|
+
class PresentationXMLConvert < ::IsoDoc::Convert
|
3
|
+
def id_validate(docxml)
|
4
|
+
repeat_id_validate(docxml)
|
5
|
+
idref_validate(docxml)
|
6
|
+
end
|
7
|
+
|
8
|
+
def repeat_id_validate1(elem)
|
9
|
+
if @doc_ids[elem["id"]]
|
10
|
+
@log.add("Anchors", elem,
|
11
|
+
"Anchor #{elem['id']} has already been " \
|
12
|
+
"used at line #{@doc_ids[elem['id']]}", severity: 0)
|
13
|
+
end
|
14
|
+
@doc_ids[elem["id"]] = elem.line
|
15
|
+
end
|
16
|
+
|
17
|
+
def repeat_id_validate(doc)
|
18
|
+
@log or return
|
19
|
+
@doc_ids = {}
|
20
|
+
doc.xpath("//*[@id]").each do |x|
|
21
|
+
repeat_id_validate1(x)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def idref_validate(doc)
|
26
|
+
@log or return
|
27
|
+
doc.xpath("//*[@original-id]").each do |x|
|
28
|
+
@doc_ids[x["original-id"]] = x.line
|
29
|
+
end
|
30
|
+
Metanorma::Utils::anchor_attributes(presxml: true).each do |e|
|
31
|
+
doc.xpath("//xmlns:#{e[0]}[@#{e[1]}]").each do |x|
|
32
|
+
idref_validate1(x, e[1])
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def idref_validate1(node, attr)
|
38
|
+
node[attr].strip.empty? and return
|
39
|
+
@doc_ids[node[attr]] and return
|
40
|
+
@log.add("Anchors", node,
|
41
|
+
"Anchor #{node[attr]} pointed to by #{node.name} " \
|
42
|
+
"is not defined in the document", severity: 1)
|
43
|
+
end
|
44
|
+
|
45
|
+
def provide_ids(docxml)
|
46
|
+
anchor_sanitise(docxml)
|
47
|
+
populate_id(docxml)
|
48
|
+
add_missing_id(docxml)
|
49
|
+
end
|
50
|
+
|
51
|
+
def anchor_sanitise(docxml)
|
52
|
+
Metanorma::Utils::anchor_attributes.each do |a|
|
53
|
+
docxml.xpath("//xmlns:#{a[0]}").each do |x|
|
54
|
+
x[a[1]] &&= to_ncname(x[a[1]])
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def populate_id(docxml)
|
60
|
+
docxml.xpath("//*[@id]").each do |x|
|
61
|
+
x["semx-id"] = x["id"]
|
62
|
+
x["anchor"] and x["id"] = to_ncname(x["anchor"])
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def add_missing_id(docxml)
|
67
|
+
docxml.xpath(ns("//source | //modification | //erefstack | //fn | " \
|
68
|
+
"//review | //floating-title")).each do |s|
|
69
|
+
s["id"] ||= "_#{UUIDTools::UUID.random_create}"
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
# do not sanitise "#"
|
74
|
+
def to_ncname(ident)
|
75
|
+
ret = ident.split("#", 2)
|
76
|
+
ret.map { |x| Metanorma::Utils::to_ncname(x) }.join("#")
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -24,11 +24,10 @@ module IsoDoc
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def svgmap_extract(elem)
|
27
|
-
if elem.at(ns("./figure"))
|
27
|
+
if elem.at(ns("./figure"))
|
28
28
|
n = semx_fmt_dup(elem)
|
29
29
|
n.xpath(ns("./target")).each(&:remove)
|
30
30
|
elem.next = n
|
31
|
-
#else elem.remove
|
32
31
|
end
|
33
32
|
end
|
34
33
|
|
@@ -71,13 +71,19 @@ module IsoDoc
|
|
71
71
|
# do not change to Presentation XML rendering
|
72
72
|
def sem_xml_descendant?(node)
|
73
73
|
ancestor_names = node.ancestors.map(&:name)
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
return true
|
78
|
-
|
79
|
-
|
80
|
-
|
74
|
+
%w[preferred admitted deprecated related definition source]
|
75
|
+
.any? do |name|
|
76
|
+
ancestor_names.include?(name)
|
77
|
+
end and return true
|
78
|
+
%w[xref eref origin link name title].any? do |name|
|
79
|
+
ancestor_names.include?(name)
|
80
|
+
end and return true
|
81
|
+
ancestor_names.include?("bibitem") &&
|
82
|
+
%w[formattedref biblio-tag].none? do |name|
|
83
|
+
ancestor_names.include?(name)
|
84
|
+
end and return true
|
85
|
+
(ancestor_names & %w[requirement recommendation permission]).any? &&
|
86
|
+
!ancestor_names.include?("fmt-provision") and return true
|
81
87
|
|
82
88
|
false
|
83
89
|
end
|
@@ -50,41 +50,37 @@ module IsoDoc
|
|
50
50
|
precision: num_precision(num.text))
|
51
51
|
end
|
52
52
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
53
|
+
COMMA_PLACEHOLDER = "##COMMA##".freeze
|
54
|
+
|
55
|
+
# Temporarily replace commas inside quotes with a placeholder
|
56
|
+
def comma_placeholder(options)
|
57
57
|
processed = ""
|
58
58
|
in_quotes = false
|
59
|
-
placeholder = "##COMMA##"
|
60
|
-
|
61
59
|
options.each_char do |c|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
if c == ',' && in_quotes
|
67
|
-
processed << placeholder
|
68
|
-
else
|
69
|
-
processed << c
|
70
|
-
end
|
60
|
+
c == "'" and in_quotes = !in_quotes
|
61
|
+
processed << if c == "," && in_quotes
|
62
|
+
COMMA_PLACEHOLDER
|
63
|
+
else c end
|
71
64
|
end
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
65
|
+
processed
|
66
|
+
end
|
67
|
+
|
68
|
+
def numberformat_extract(options)
|
69
|
+
options.gsub!(/([a-z_]+)='/, %('\\1=))
|
70
|
+
processed = comma_placeholder(options)
|
71
|
+
CSV.parse_line(processed,
|
72
|
+
quote_char: "'").each_with_object({}) do |x, acc|
|
73
|
+
x.gsub!(COMMA_PLACEHOLDER, ",")
|
76
74
|
m = /^(.+?)=(.+)?$/.match(x) or next
|
77
75
|
acc[m[1].to_sym] = m[2].sub(/^(["'])(.+)\1$/, "\\2")
|
78
76
|
end
|
79
|
-
|
80
|
-
result
|
81
77
|
end
|
82
78
|
|
83
79
|
def numberformat_type(ret)
|
84
80
|
%i(precision significant digit_count group_digits fraction_group_digits)
|
85
81
|
.each do |i|
|
86
|
-
|
87
|
-
|
82
|
+
ret[i] &&= ret[i].to_i
|
83
|
+
end
|
88
84
|
%i(notation exponent_sign number_sign locale).each do |i|
|
89
85
|
ret[i] &&= ret[i].to_sym
|
90
86
|
end
|
@@ -211,7 +211,7 @@ module IsoDoc
|
|
211
211
|
date_note = bib.at(ns("./note[@type = 'Unpublished-Status']"))
|
212
212
|
date_note.nil? and return ret
|
213
213
|
id = "_#{UUIDTools::UUID.random_create}"
|
214
|
-
"#{ret}<fn reference='#{id}'><p>#{date_note.content}</p></fn>"
|
214
|
+
"#{ret}<fn id='#{id}' reference='#{id}'><p>#{date_note.content}</p></fn>"
|
215
215
|
end
|
216
216
|
|
217
217
|
def ident_fn(bib)
|
@@ -6,8 +6,8 @@ module IsoDoc
|
|
6
6
|
def clause(docxml)
|
7
7
|
docxml.xpath(ns("//clause | //terms | //definitions | //references | " \
|
8
8
|
"//introduction | //foreword | //preface/abstract | " \
|
9
|
-
"//acknowledgements | //colophon | //indexsect "
|
10
|
-
|
9
|
+
"//acknowledgements | //colophon | //indexsect | " \
|
10
|
+
"//executivesummary | //appendix")).each do |f|
|
11
11
|
f.parent.name == "annex" &&
|
12
12
|
@xrefs.klass.single_term_clause?(f.parent) and next
|
13
13
|
clause1(f)
|
@@ -133,14 +133,15 @@ module IsoDoc
|
|
133
133
|
end
|
134
134
|
|
135
135
|
def preface_rearrange(doc)
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
136
|
+
[["//preface/abstract",
|
137
|
+
%w(foreword introduction clause acknowledgements executivesummary)],
|
138
|
+
["//preface/foreword",
|
139
|
+
%w(introduction clause acknowledgements executivesummary)],
|
140
|
+
["//preface/introduction", %w(clause acknowledgements executivesummary)],
|
141
|
+
["//preface/acknowledgements", %w(executivesummary)],
|
142
|
+
["//preface/executivesummary", %w()]].each do |x|
|
143
|
+
preface_move(doc.xpath(ns(x[0])), x[1], doc)
|
144
|
+
end
|
144
145
|
end
|
145
146
|
|
146
147
|
def preface_move(clauses, after, _doc)
|