metanorma-standoc 2.3.8 → 2.4.0
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/html/htmlstyle.css +4 -0
- data/lib/metanorma/standoc/base.rb +10 -3
- data/lib/metanorma/standoc/biblio.rng +11 -1
- data/lib/metanorma/standoc/blocks.rb +11 -10
- data/lib/metanorma/standoc/cleanup.rb +3 -1
- data/lib/metanorma/standoc/cleanup_block.rb +9 -2
- data/lib/metanorma/standoc/cleanup_boilerplate.rb +26 -20
- data/lib/metanorma/standoc/cleanup_image.rb +1 -1
- data/lib/metanorma/standoc/cleanup_inline.rb +16 -5
- data/lib/metanorma/standoc/cleanup_section.rb +20 -6
- 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/cleanup_toc.rb +3 -3
- data/lib/metanorma/standoc/front.rb +10 -5
- data/lib/metanorma/standoc/front_contributor.rb +11 -2
- data/lib/metanorma/standoc/inline.rb +0 -8
- data/lib/metanorma/standoc/isodoc.rng +56 -296
- data/lib/metanorma/standoc/lists.rb +4 -1
- data/lib/metanorma/standoc/macros_embed.rb +34 -12
- data/lib/metanorma/standoc/merge_bibitems.rb +2 -2
- data/lib/metanorma/standoc/section.rb +4 -0
- data/lib/metanorma/standoc/spans_to_bibitem.rb +34 -146
- 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 -15
- data/lib/metanorma/standoc/validate_section.rb +13 -1
- 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"
|
@@ -82,14 +83,20 @@ module Metanorma
|
|
82
83
|
end
|
83
84
|
|
84
85
|
def init_toc(node)
|
85
|
-
@htmltoclevels = node.attr("htmltoclevels")
|
86
|
-
|
87
|
-
@
|
86
|
+
@htmltoclevels = node.attr("htmltoclevels") ||
|
87
|
+
node.attr("toclevels") || toc_default[:html_levels]
|
88
|
+
@doctoclevels = node.attr("doctoclevels") ||
|
89
|
+
node.attr("toclevels") || toc_default[:word_levels]
|
90
|
+
@toclevels = node.attr("toclevels") || toc_default[:word_levels]
|
88
91
|
@tocfigures = node.attr("toc-figures")
|
89
92
|
@toctables = node.attr("toc-tables")
|
90
93
|
@tocrecommendations = node.attr("toc-recommendations")
|
91
94
|
end
|
92
95
|
|
96
|
+
def toc_default
|
97
|
+
{ word_levels: 2, html_levels: 2 }
|
98
|
+
end
|
99
|
+
|
93
100
|
def init_output(node)
|
94
101
|
@fontheader = default_fonts(node)
|
95
102
|
@log = Metanorma::Utils::Log.new
|
@@ -216,6 +216,9 @@
|
|
216
216
|
<optional>
|
217
217
|
<ref name="fullname"/>
|
218
218
|
</optional>
|
219
|
+
<zeroOrMore>
|
220
|
+
<ref name="credential"/>
|
221
|
+
</zeroOrMore>
|
219
222
|
<zeroOrMore>
|
220
223
|
<ref name="affiliation"/>
|
221
224
|
</zeroOrMore>
|
@@ -232,6 +235,11 @@
|
|
232
235
|
<ref name="FullNameType"/>
|
233
236
|
</element>
|
234
237
|
</define>
|
238
|
+
<define name="credential">
|
239
|
+
<element name="credential">
|
240
|
+
<text/>
|
241
|
+
</element>
|
242
|
+
</define>
|
235
243
|
<define name="FullNameType">
|
236
244
|
<choice>
|
237
245
|
<group>
|
@@ -305,7 +313,9 @@
|
|
305
313
|
<zeroOrMore>
|
306
314
|
<ref name="affiliationdescription"/>
|
307
315
|
</zeroOrMore>
|
308
|
-
<
|
316
|
+
<optional>
|
317
|
+
<ref name="organization"/>
|
318
|
+
</optional>
|
309
319
|
</element>
|
310
320
|
</define>
|
311
321
|
<define name="affiliationname">
|
@@ -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)
|
@@ -60,6 +61,7 @@ module Metanorma
|
|
60
61
|
quotesource_cleanup(xmldoc)
|
61
62
|
callout_cleanup(xmldoc)
|
62
63
|
footnote_cleanup(xmldoc)
|
64
|
+
ol_cleanup(xmldoc)
|
63
65
|
mathml_cleanup(xmldoc)
|
64
66
|
script_cleanup(xmldoc)
|
65
67
|
docidentifier_cleanup(xmldoc) # feeds: bibdata_cleanup
|
@@ -100,8 +100,7 @@ module Metanorma
|
|
100
100
|
# it is moved inside its preceding block if it is not delimited
|
101
101
|
# (so there was no way of making that block include the note)
|
102
102
|
def note_cleanup(xmldoc)
|
103
|
-
|
104
|
-
xmldoc.xpath(q).each do |n|
|
103
|
+
xmldoc.xpath("//note").each do |n|
|
105
104
|
next if n["keep-separate"] == "true" || !n.ancestors("table").empty?
|
106
105
|
|
107
106
|
prev = n.previous_element || next
|
@@ -221,6 +220,14 @@ module Metanorma
|
|
221
220
|
foll.children.first.previous = para.remove.children
|
222
221
|
end
|
223
222
|
end
|
223
|
+
|
224
|
+
def ol_cleanup(doc)
|
225
|
+
doc.xpath("//ol[@explicit-type]").each do |x|
|
226
|
+
x.delete("explicit-type")
|
227
|
+
@log.add("Bibliography", x,
|
228
|
+
"Style override set for ordered list")
|
229
|
+
end
|
230
|
+
end
|
224
231
|
end
|
225
232
|
end
|
226
233
|
end
|
@@ -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
|
@@ -80,7 +80,7 @@ module Metanorma
|
|
80
80
|
types = MIME::Types.type_for(path) or return false
|
81
81
|
types.first == "image/svg+xml" or return false
|
82
82
|
svg = File.read(path, encoding: "utf-8") or return false
|
83
|
-
img.replace(Nokogiri::XML(svg).root
|
83
|
+
img.replace(Nokogiri::XML(svg).root)
|
84
84
|
true
|
85
85
|
end
|
86
86
|
|
@@ -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
|
@@ -11,18 +11,31 @@ module Metanorma
|
|
11
11
|
if xml.at("//foreword | //introduction | //acknowledgements | " \
|
12
12
|
"//*[@preface]")
|
13
13
|
preface = sect.add_previous_sibling("<preface/>").first
|
14
|
-
f = xml.at("//foreword") and preface
|
15
|
-
f = xml.at("//introduction") and preface
|
14
|
+
f = xml.at("//foreword") and to_preface(preface, f)
|
15
|
+
f = xml.at("//introduction") and to_preface(preface, f)
|
16
16
|
move_clauses_into_preface(xml, preface)
|
17
|
-
f = xml.at("//acknowledgements") and preface
|
17
|
+
f = xml.at("//acknowledgements") and to_preface(preface, f)
|
18
18
|
end
|
19
19
|
make_abstract(xml, sect)
|
20
20
|
end
|
21
21
|
|
22
22
|
def move_clauses_into_preface(xml, preface)
|
23
23
|
xml.xpath("//*[@preface]").each do |c|
|
24
|
-
|
25
|
-
|
24
|
+
to_preface(preface, c)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def to_preface(preface, clause)
|
29
|
+
clause.delete("preface")
|
30
|
+
preface.add_child clause.remove
|
31
|
+
end
|
32
|
+
|
33
|
+
def make_colophon(xml)
|
34
|
+
xml.at("//clause[@colophon]") or return
|
35
|
+
colophon = xml.root.add_child("<colophon/>").first
|
36
|
+
xml.xpath("//*[@colophon]").each do |c|
|
37
|
+
c.delete("colophon")
|
38
|
+
colophon.add_child c.remove
|
26
39
|
end
|
27
40
|
end
|
28
41
|
|
@@ -73,10 +86,12 @@ module Metanorma
|
|
73
86
|
|
74
87
|
def sections_order_cleanup(xml)
|
75
88
|
s = xml.at("//sections")
|
89
|
+
pop_floating_title(xml)
|
76
90
|
make_preface(xml, s)
|
77
91
|
make_annexes(xml)
|
78
92
|
make_indexsect(xml, s)
|
79
93
|
make_bibliography(xml, s)
|
94
|
+
make_colophon(xml)
|
80
95
|
xml.xpath("//sections/annex").reverse_each { |r| s.next = r.remove }
|
81
96
|
end
|
82
97
|
|
@@ -200,7 +215,6 @@ module Metanorma
|
|
200
215
|
end
|
201
216
|
|
202
217
|
def floatingtitle_cleanup(xmldoc)
|
203
|
-
pop_floating_title(xmldoc)
|
204
218
|
floating_title_preface2sections(xmldoc)
|
205
219
|
end
|
206
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 }
|
@@ -86,9 +86,9 @@ module Metanorma
|
|
86
86
|
|
87
87
|
def toc_metadata1(ins)
|
88
88
|
[[@toclevels, "TOC Heading Levels"],
|
89
|
-
[@
|
90
|
-
[@
|
91
|
-
n[0] and ins << "<presentation-metadata><name>#{n[1]}</name>"\
|
89
|
+
[@htmltoclevels, "HTML TOC Heading Levels"],
|
90
|
+
[@doctoclevels, "DOC TOC Heading Levels"]].each do |n|
|
91
|
+
n[0] and ins << "<presentation-metadata><name>#{n[1]}</name>" \
|
92
92
|
"<value>#{n[0]}</value></presentation-metadata>"
|
93
93
|
end
|
94
94
|
end
|
@@ -9,12 +9,17 @@ module Metanorma
|
|
9
9
|
module Standoc
|
10
10
|
module Front
|
11
11
|
def metadata_id(node, xml)
|
12
|
+
id = node.attr("docidentifier") || metadata_id_build(node)
|
13
|
+
xml.docidentifier id
|
14
|
+
xml.docnumber node.attr("docnumber")
|
15
|
+
end
|
16
|
+
|
17
|
+
def metadata_id_build(node)
|
12
18
|
part, subpart = node&.attr("partnumber")&.split(/-/)
|
13
19
|
id = node.attr("docnumber") || ""
|
14
20
|
id += "-#{part}" if part
|
15
21
|
id += "-#{subpart}" if subpart
|
16
|
-
|
17
|
-
xml.docnumber node.attr("docnumber")
|
22
|
+
id
|
18
23
|
end
|
19
24
|
|
20
25
|
def metadata_other_id(node, xml)
|
@@ -69,7 +74,7 @@ module Metanorma
|
|
69
74
|
|
70
75
|
def metadata_date1(node, xml, type)
|
71
76
|
date = node.attr("#{type}-date")
|
72
|
-
date and xml.date
|
77
|
+
date and xml.date type: type do |d|
|
73
78
|
d.on date
|
74
79
|
end
|
75
80
|
end
|
@@ -87,7 +92,7 @@ module Metanorma
|
|
87
92
|
|
88
93
|
type, date = node.attr(a).split(/ /, 2)
|
89
94
|
type or next
|
90
|
-
xml.date
|
95
|
+
xml.date type: type do |d|
|
91
96
|
d.on date
|
92
97
|
end
|
93
98
|
end
|
@@ -134,7 +139,7 @@ module Metanorma
|
|
134
139
|
|
135
140
|
def metadata_getrelation1(doc, xml, type, desc)
|
136
141
|
id = doc.split(/,\s*/)
|
137
|
-
xml.relation
|
142
|
+
xml.relation type: relation_normalise(type) do |r|
|
138
143
|
desc.nil? or r.description desc.gsub(/-/, " ")
|
139
144
|
fetch_ref(r, doc, nil, **{}) or r.bibitem do |b|
|
140
145
|
b.title id[1] || "--"
|
@@ -86,6 +86,7 @@ module Metanorma
|
|
86
86
|
personal_role(node, c, suffix)
|
87
87
|
c.person do |p|
|
88
88
|
person_name(node, xml, suffix, p)
|
89
|
+
person_credentials(node, xml, suffix, p)
|
89
90
|
person_affiliation(node, xml, suffix, p)
|
90
91
|
personal_contact(node, suffix, p)
|
91
92
|
end
|
@@ -104,9 +105,17 @@ module Metanorma
|
|
104
105
|
end
|
105
106
|
end
|
106
107
|
|
108
|
+
def person_credentials(node, _xml, suffix, person)
|
109
|
+
c = node.attr("contributor-credentials#{suffix}") and
|
110
|
+
person.credentials c
|
111
|
+
end
|
112
|
+
|
107
113
|
def person_affiliation(node, _xml, suffix, person)
|
108
|
-
node.attr("affiliation#{suffix}")
|
109
|
-
|
114
|
+
aff = node.attr("affiliation#{suffix}")
|
115
|
+
pos = node.attr("contributor-position#{suffix}")
|
116
|
+
(aff || pos) and person.affiliation do |a|
|
117
|
+
pos and a.name { |n| n << pos }
|
118
|
+
aff and a.organization do |o|
|
110
119
|
person_organization(node, suffix, o)
|
111
120
|
end
|
112
121
|
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
|