metanorma-standoc 2.3.9 → 2.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/isodoc/html/htmlstyle.css +4 -0
- data/lib/metanorma/standoc/base.rb +1 -0
- data/lib/metanorma/standoc/blocks.rb +11 -10
- data/lib/metanorma/standoc/cleanup.rb +2 -1
- data/lib/metanorma/standoc/cleanup_boilerplate.rb +26 -20
- data/lib/metanorma/standoc/cleanup_inline.rb +16 -5
- data/lib/metanorma/standoc/cleanup_section.rb +1 -1
- data/lib/metanorma/standoc/cleanup_section_names.rb +1 -1
- data/lib/metanorma/standoc/cleanup_symbols.rb +4 -1
- data/lib/metanorma/standoc/cleanup_terms.rb +1 -1
- data/lib/metanorma/standoc/front_contributor.rb +1 -1
- data/lib/metanorma/standoc/inline.rb +0 -8
- data/lib/metanorma/standoc/isodoc.rng +46 -296
- data/lib/metanorma/standoc/macros_embed.rb +34 -12
- data/lib/metanorma/standoc/merge_bibitems.rb +1 -1
- data/lib/metanorma/standoc/spans_to_bibitem.rb +26 -145
- data/lib/metanorma/standoc/spans_to_bibitem_preprocessing.rb +148 -0
- data/lib/metanorma/standoc/utils.rb +7 -0
- data/lib/metanorma/standoc/validate.rb +1 -3
- data/lib/metanorma/standoc/version.rb +1 -1
- data/metanorma-standoc.gemspec +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 11179b51c3de0cefbd6cd55d2cd3e6945e0d72cb379ec9a32ed792b1239444fd
|
4
|
+
data.tar.gz: e3c6231ecd99e4f631da9173b1c89f10213428c331147b54efa1eccf8833a017
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d000c768270a37dacc417c3d29cab591a708bf7e7b47c51bbded56120c711c6bc82257335a44f34401cfb06d96dd8c64cb410d1664064534147fee3bf7525d85
|
7
|
+
data.tar.gz: 11799198a90c8b67a358365115cebf4594bfd1be0d58cbc193db94fa95096f98cbbd5974fb65f8b6dbc07349d6a76080591ed6703979d448ee768cd8e5f1ceae
|
@@ -59,6 +59,7 @@ module Metanorma
|
|
59
59
|
@index_terms = node.attr("index-terms")
|
60
60
|
@boilerplateauthority = node.attr("boilerplate-authority")
|
61
61
|
@embed_hdr = node.attr("embed_hdr")
|
62
|
+
@embed_id = node.attr("embed_id")
|
62
63
|
@document_scheme = node.attr("document-scheme")
|
63
64
|
@xrefstyle = node.attr("xrefstyle")
|
64
65
|
@source_linenums = node.attr("source-linenums-option") == "true"
|
@@ -1,4 +1,3 @@
|
|
1
|
-
require "htmlentities"
|
2
1
|
require "uri" if /^2\./.match?(RUBY_VERSION)
|
3
2
|
require_relative "./blocks_notes"
|
4
3
|
|
@@ -8,6 +7,7 @@ module Metanorma
|
|
8
7
|
def id_attr(node = nil)
|
9
8
|
{ id: Metanorma::Utils::anchor_or_uuid(node),
|
10
9
|
tag: node&.attr("tag"),
|
10
|
+
columns: node&.attr("columns"),
|
11
11
|
"multilingual-rendering": node&.attr("multilingual-rendering") }
|
12
12
|
end
|
13
13
|
|
@@ -43,11 +43,15 @@ module Metanorma
|
|
43
43
|
result
|
44
44
|
end
|
45
45
|
|
46
|
+
def form_attrs(node)
|
47
|
+
attr_code(id_attr(node)
|
48
|
+
.merge(class: node.attr("class"),
|
49
|
+
name: node.attr("name"), action: node.attr("action")))
|
50
|
+
end
|
51
|
+
|
46
52
|
def form(node)
|
47
53
|
noko do |xml|
|
48
|
-
xml.form **
|
49
|
-
.merge(class: node.attr("class"),
|
50
|
-
name: node.attr("name"), action: node.attr("action"))) do |f|
|
54
|
+
xml.form **form_attrs(node) do |f|
|
51
55
|
f << node.content
|
52
56
|
end
|
53
57
|
end
|
@@ -108,8 +112,7 @@ module Metanorma
|
|
108
112
|
end
|
109
113
|
|
110
114
|
def example_to_requirement(node, role)
|
111
|
-
|
112
|
-
|
115
|
+
@reqt_models.requirement_roles.key?(role&.to_sym) or return
|
113
116
|
# need to call here for proper recursion ordering
|
114
117
|
select_requirement_model(node)
|
115
118
|
requirement(node,
|
@@ -169,8 +172,7 @@ module Metanorma
|
|
169
172
|
end
|
170
173
|
|
171
174
|
def figure_title(node, out)
|
172
|
-
|
173
|
-
|
175
|
+
node.title.nil? and return
|
174
176
|
out.name { |name| name << node.title }
|
175
177
|
end
|
176
178
|
|
@@ -196,8 +198,7 @@ module Metanorma
|
|
196
198
|
end
|
197
199
|
|
198
200
|
def paragraph(node)
|
199
|
-
|
200
|
-
|
201
|
+
node.role == "source" and return termsource(node)
|
201
202
|
noko do |xml|
|
202
203
|
xml.p **para_attrs(node) do |xml_t|
|
203
204
|
xml_t << node.content
|
@@ -26,7 +26,8 @@ module Metanorma
|
|
26
26
|
def cleanup(xmldoc)
|
27
27
|
element_name_cleanup(xmldoc)
|
28
28
|
passthrough_cleanup(xmldoc)
|
29
|
-
sections_cleanup(xmldoc) # feeds: obligations_cleanup, toc_cleanup
|
29
|
+
sections_cleanup(xmldoc) # feeds: obligations_cleanup, toc_cleanup,
|
30
|
+
# floatingtitle_cleanup
|
30
31
|
obligations_cleanup(xmldoc)
|
31
32
|
para_index_cleanup(xmldoc)
|
32
33
|
block_index_cleanup(xmldoc)
|
@@ -22,10 +22,8 @@ module Metanorma
|
|
22
22
|
@log.add("Crossreferences", nil,
|
23
23
|
"term source #{s['bibitemid']} not referenced")
|
24
24
|
end
|
25
|
-
a = if source.empty? && term.nil?
|
26
|
-
|
27
|
-
else
|
28
|
-
term_defs_boilerplate_cont(source, term, isodoc)
|
25
|
+
a = if source.empty? && term.nil? then @i18n.no_terms_boilerplate
|
26
|
+
else term_defs_boilerplate_cont(source, term, isodoc)
|
29
27
|
end
|
30
28
|
a and div.next = a
|
31
29
|
end
|
@@ -81,7 +79,7 @@ module Metanorma
|
|
81
79
|
xmldoc.xpath(xpath).each do |f|
|
82
80
|
f.xpath(".//clause[@type = 'boilerplate'] | " \
|
83
81
|
".//note[@type = 'boilerplate']").each do |c|
|
84
|
-
c
|
82
|
+
c.at("./title")&.remove
|
85
83
|
c.replace(c.children)
|
86
84
|
end
|
87
85
|
end
|
@@ -89,13 +87,12 @@ module Metanorma
|
|
89
87
|
|
90
88
|
def termdef_boilerplate_insert(xmldoc, isodoc, once = false)
|
91
89
|
xmldoc.xpath(self.class::TERM_CLAUSE).each do |f|
|
92
|
-
|
93
|
-
|
94
|
-
|
90
|
+
f.at("./clause[@type = 'boilerplate'] | " \
|
91
|
+
"./note[@type = 'boilerplate']") and next
|
95
92
|
term_defs_boilerplate(f.at("./title"),
|
96
93
|
xmldoc.xpath(".//termdocsource"),
|
97
94
|
f.at(".//term"), f.at(".//p"), isodoc)
|
98
|
-
|
95
|
+
once and break
|
99
96
|
end
|
100
97
|
end
|
101
98
|
|
@@ -109,8 +106,7 @@ module Metanorma
|
|
109
106
|
end
|
110
107
|
|
111
108
|
def initial_boilerplate(xml, isodoc)
|
112
|
-
|
113
|
-
|
109
|
+
xml.at("//boilerplate") and return
|
114
110
|
preface = xml.at("//preface") || xml.at("//sections") ||
|
115
111
|
xml.at("//annex") || xml.at("//references") or return
|
116
112
|
b = boilerplate(xml, isodoc) or return
|
@@ -123,10 +119,8 @@ module Metanorma
|
|
123
119
|
|
124
120
|
def boilerplate(xml, conv)
|
125
121
|
file = boilerplate_file(xml)
|
126
|
-
|
127
|
-
file = File.join(@localdir,
|
128
|
-
@boilerplateauthority)
|
129
|
-
end
|
122
|
+
@boilerplateauthority and
|
123
|
+
file = File.join(@localdir, @boilerplateauthority)
|
130
124
|
(!file.nil? and File.exist?(file)) or return
|
131
125
|
conv.populate_template(File.read(file, encoding: "UTF-8"), nil)
|
132
126
|
end
|
@@ -134,7 +128,8 @@ module Metanorma
|
|
134
128
|
def bibdata_cleanup(xmldoc)
|
135
129
|
bibdata_anchor_cleanup(xmldoc)
|
136
130
|
bibdata_docidentifier_cleanup(xmldoc)
|
137
|
-
bibdata_embed_hdr_cleanup(xmldoc)
|
131
|
+
bibdata_embed_hdr_cleanup(xmldoc) # feeds bibdata_embed_id_cleanup
|
132
|
+
bibdata_embed_id_cleanup(xmldoc)
|
138
133
|
biblio_indirect_erefs(xmldoc, @internal_eref_namespaces&.uniq)
|
139
134
|
end
|
140
135
|
|
@@ -147,8 +142,7 @@ module Metanorma
|
|
147
142
|
def bibdata_docidentifier_cleanup(xmldoc)
|
148
143
|
ins = xmldoc.at("//bibdata/docidentifier")
|
149
144
|
xmldoc.xpath("//bibdata/docidentifier").each_with_index do |b, i|
|
150
|
-
|
151
|
-
|
145
|
+
i.zero? and next
|
152
146
|
ins.next = b.remove
|
153
147
|
ins = ins.next
|
154
148
|
end
|
@@ -212,8 +206,7 @@ module Metanorma
|
|
212
206
|
end
|
213
207
|
|
214
208
|
def bibdata_embed_hdr_cleanup(xmldoc)
|
215
|
-
|
216
|
-
|
209
|
+
(@embed_hdr.nil? || @embed_hdr.empty?) and return
|
217
210
|
xmldoc.at("//bibdata") << "<relation type='derivedFrom'>" \
|
218
211
|
"#{hdr2bibitem(@embed_hdr.first)}</relation>"
|
219
212
|
end
|
@@ -241,6 +234,19 @@ module Metanorma
|
|
241
234
|
bibitem << "<relation type='derivedFrom'>#{x}</relation>"
|
242
235
|
end
|
243
236
|
end
|
237
|
+
|
238
|
+
def bibdata_embed_id_cleanup(xmldoc)
|
239
|
+
@embed_id.nil? and return
|
240
|
+
bibdata = xmldoc.at("//bibdata")
|
241
|
+
#require "debug"; binding.b
|
242
|
+
@embed_id.each do |d|
|
243
|
+
bibdata = bibdata.at("./relation[@type = 'derivedFrom']/bibitem")
|
244
|
+
ident = bibdata.at("./docidentifier[@primary = 'true']") ||
|
245
|
+
bibdata.at("./docidentifier")
|
246
|
+
xmldoc.xpath("//xref[@target = '#{d}'][normalize-space(text()) = '']")
|
247
|
+
.each { |x| x << ident.text }
|
248
|
+
end
|
249
|
+
end
|
244
250
|
end
|
245
251
|
end
|
246
252
|
end
|
@@ -13,20 +13,31 @@ module Metanorma
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def strip_initial_space(elem)
|
16
|
-
|
17
|
-
|
16
|
+
elem.children[0].text? or return
|
18
17
|
if /\S/.match?(elem.children[0].text)
|
19
|
-
elem.children[0].content = elem.children[0].text.
|
18
|
+
elem.children[0].content = elem.children[0].text.lstrip
|
20
19
|
else
|
21
20
|
elem.children[0].remove
|
22
21
|
end
|
23
22
|
end
|
24
23
|
|
25
24
|
def bookmark_cleanup(xmldoc)
|
25
|
+
redundant_bookmark_cleanup(xmldoc)
|
26
26
|
li_bookmark_cleanup(xmldoc)
|
27
27
|
dt_bookmark_cleanup(xmldoc)
|
28
28
|
end
|
29
29
|
|
30
|
+
def redundant_bookmark_cleanup(xmldoc)
|
31
|
+
xmldoc.xpath("//bookmark").each do |b|
|
32
|
+
p = b
|
33
|
+
while !p.xml? && p = p.parent
|
34
|
+
p["id"] == b["id"] or next
|
35
|
+
b.remove
|
36
|
+
break
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
30
41
|
def bookmark_to_id(elem, bookmark)
|
31
42
|
parent = bookmark.parent
|
32
43
|
elem["id"] = bookmark.remove["id"]
|
@@ -103,8 +114,8 @@ module Metanorma
|
|
103
114
|
end
|
104
115
|
|
105
116
|
def concept_eref_cleanup(elem)
|
106
|
-
t = elem
|
107
|
-
l = elem
|
117
|
+
t = elem.at("./xrefrender")&.remove&.children&.to_xml
|
118
|
+
l = elem.at("./locality")&.remove&.children&.to_xml
|
108
119
|
elem.add_child "<eref bibitemid='#{elem['key']}'>#{l}</eref>"
|
109
120
|
extract_localities(elem.elements[-1])
|
110
121
|
elem.elements[-1].add_child(t) if t
|
@@ -86,6 +86,7 @@ module Metanorma
|
|
86
86
|
|
87
87
|
def sections_order_cleanup(xml)
|
88
88
|
s = xml.at("//sections")
|
89
|
+
pop_floating_title(xml)
|
89
90
|
make_preface(xml, s)
|
90
91
|
make_annexes(xml)
|
91
92
|
make_indexsect(xml, s)
|
@@ -214,7 +215,6 @@ module Metanorma
|
|
214
215
|
end
|
215
216
|
|
216
217
|
def floatingtitle_cleanup(xmldoc)
|
217
|
-
pop_floating_title(xmldoc)
|
218
218
|
floating_title_preface2sections(xmldoc)
|
219
219
|
end
|
220
220
|
|
@@ -17,7 +17,7 @@ module Metanorma
|
|
17
17
|
doc.xpath(xpath).each_with_index do |node, i|
|
18
18
|
first && !i.zero? and next
|
19
19
|
title = get_or_make_title(node)
|
20
|
-
fn = title.xpath("./fn")
|
20
|
+
fn = title.xpath("./fn | ./bookmark")
|
21
21
|
fn.each(&:remove)
|
22
22
|
title.children = text
|
23
23
|
fn.each { |n| title << n }
|
@@ -4,11 +4,14 @@ module Metanorma
|
|
4
4
|
# Indices sort after letter but before any following
|
5
5
|
# letter (x, x_m, x_1, xa); we use colon to force that sort order.
|
6
6
|
# Numbers sort *after* letters; we use thorn to force that sort order.
|
7
|
+
# Capitals sort before their corresponding lowercase.
|
7
8
|
def symbol_key(sym)
|
8
|
-
@c.decode(asciimath_key(sym).text
|
9
|
+
@c.decode(asciimath_key(sym).text)
|
9
10
|
.gsub(/[\[\]{}<>()]/, "").gsub(/\s/m, "")
|
10
11
|
.gsub(/[[:punct:]]|[_^]/, ":\\0").gsub(/`/, "")
|
11
12
|
.gsub(/[0-9]+/, "þ\\0")
|
13
|
+
.tr("AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz",
|
14
|
+
"ABCFEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")
|
12
15
|
end
|
13
16
|
|
14
17
|
def asciimath_key(sym)
|
@@ -74,7 +74,7 @@ module Metanorma
|
|
74
74
|
end
|
75
75
|
|
76
76
|
def term_children_cleanup(xmldoc)
|
77
|
-
xmldoc.xpath("//terms[terms]").each { |t| t.name = "clause" }
|
77
|
+
xmldoc.xpath("//terms[terms][not(term)]").each { |t| t.name = "clause" }
|
78
78
|
xmldoc.xpath("//term").each do |t|
|
79
79
|
%w(termnote termexample termsource term).each do |w|
|
80
80
|
t.xpath("./#{w}").each { |n| t << n.remove }
|
@@ -114,7 +114,7 @@ module Metanorma
|
|
114
114
|
aff = node.attr("affiliation#{suffix}")
|
115
115
|
pos = node.attr("contributor-position#{suffix}")
|
116
116
|
(aff || pos) and person.affiliation do |a|
|
117
|
-
pos and a.name pos
|
117
|
+
pos and a.name { |n| n << pos }
|
118
118
|
aff and a.organization do |o|
|
119
119
|
person_organization(node, suffix, o)
|
120
120
|
end
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require "asciidoctor/extensions"
|
2
|
-
require "htmlentities"
|
3
2
|
require "unicode2latex"
|
4
3
|
require "mime/types"
|
5
4
|
require "base64"
|
@@ -139,13 +138,6 @@ module Metanorma
|
|
139
138
|
noko { |xml| xml.hr }.join
|
140
139
|
end
|
141
140
|
|
142
|
-
def xml_encode(text)
|
143
|
-
@c.encode(text, :basic, :hexadecimal)
|
144
|
-
.gsub(/&gt;/, ">").gsub(/&lt;/, "<").gsub(/&amp;/, "&")
|
145
|
-
.gsub(/>/, ">").gsub(/</, "<").gsub(/&/, "&")
|
146
|
-
.gsub(/"/, '"').gsub(/
/, "\n").gsub(/&#/, "&#")
|
147
|
-
end
|
148
|
-
|
149
141
|
def latex_parse1(text)
|
150
142
|
lxm_input = Unicode2LaTeX.unicode2latex(@c.decode(text))
|
151
143
|
results = Latexmath.parse(lxm_input).to_mathml
|