metanorma-standoc 3.1.10 → 3.2.1
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/metanorma/standoc/anchor.rb +3 -2
- data/lib/metanorma/standoc/base.rb +2 -2
- data/lib/metanorma/standoc/biblio.rng +4 -4
- data/lib/metanorma/standoc/blocks.rb +4 -8
- data/lib/metanorma/standoc/cleanup.rb +31 -61
- data/lib/metanorma/standoc/cleanup_asciibib.rb +7 -10
- data/lib/metanorma/standoc/cleanup_attachment.rb +1 -2
- data/lib/metanorma/standoc/cleanup_bibdata.rb +9 -0
- data/lib/metanorma/standoc/cleanup_bibitem.rb +29 -2
- data/lib/metanorma/standoc/cleanup_block.rb +1 -2
- data/lib/metanorma/standoc/cleanup_boilerplate.rb +1 -2
- data/lib/metanorma/standoc/cleanup_footnotes.rb +1 -2
- data/lib/metanorma/standoc/cleanup_inline.rb +44 -4
- data/lib/metanorma/standoc/cleanup_maths.rb +3 -3
- data/lib/metanorma/standoc/cleanup_section_names.rb +1 -0
- data/lib/metanorma/standoc/cleanup_terms_boilerplate.rb +1 -3
- data/lib/metanorma/standoc/cleanup_terms_designations.rb +2 -3
- data/lib/metanorma/standoc/cleanup_xref.rb +14 -11
- data/lib/metanorma/standoc/converter.rb +7 -5
- data/lib/metanorma/standoc/front.rb +27 -25
- data/lib/metanorma/standoc/front_committee.rb +5 -5
- data/lib/metanorma/standoc/front_contributor.rb +14 -14
- data/lib/metanorma/standoc/front_ext.rb +7 -5
- data/lib/metanorma/standoc/front_organisation.rb +16 -21
- data/lib/metanorma/standoc/init.rb +31 -5
- data/lib/metanorma/standoc/inline.rb +31 -12
- data/lib/metanorma/standoc/isodoc.rng +27 -10
- data/lib/metanorma/standoc/lists.rb +1 -1
- data/lib/metanorma/standoc/localbib.rb +5 -9
- data/lib/metanorma/standoc/log.rb +207 -0
- data/lib/metanorma/standoc/macros_embed.rb +5 -3
- data/lib/metanorma/standoc/macros_link.rb +2 -3
- data/lib/metanorma/standoc/macros_terms.rb +2 -0
- data/lib/metanorma/standoc/ref.rb +12 -13
- data/lib/metanorma/standoc/ref_queue.rb +4 -6
- data/lib/metanorma/standoc/ref_sect.rb +3 -6
- data/lib/metanorma/standoc/ref_utility.rb +4 -13
- data/lib/metanorma/standoc/section.rb +3 -9
- data/lib/metanorma/standoc/spans_to_bibitem.rb +12 -1
- data/lib/metanorma/standoc/spans_to_bibitem_preprocessing.rb +11 -7
- data/lib/metanorma/standoc/table.rb +1 -1
- data/lib/metanorma/standoc/term_lookup_cleanup.rb +7 -18
- data/lib/metanorma/standoc/terms.rb +2 -4
- data/lib/metanorma/standoc/utils.rb +27 -2
- data/lib/metanorma/standoc/validate.rb +9 -17
- data/lib/metanorma/standoc/validate_image.rb +52 -9
- data/lib/metanorma/standoc/validate_schema.rb +3 -2
- data/lib/metanorma/standoc/validate_section.rb +3 -6
- data/lib/metanorma/standoc/validate_table.rb +3 -5
- data/lib/metanorma/standoc/validate_term.rb +4 -14
- data/lib/metanorma/standoc/version.rb +1 -1
- data/metanorma-standoc.gemspec +5 -3
- metadata +49 -20
|
@@ -9,7 +9,7 @@ module Metanorma
|
|
|
9
9
|
module Front
|
|
10
10
|
def metadata_id(node, xml)
|
|
11
11
|
id = node.attr("docidentifier") || metadata_id_build(node)
|
|
12
|
-
xml
|
|
12
|
+
add_noko_elem(xml, "docidentifier", id, primary: "true")
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
def metadata_id_build(node)
|
|
@@ -21,21 +21,23 @@ module Metanorma
|
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
def metadata_other_id(node, xml)
|
|
24
|
-
a = node.attr("isbn") and
|
|
25
|
-
|
|
24
|
+
a = node.attr("isbn") and
|
|
25
|
+
add_noko_elem(xml, "docidentifier", a, type: "ISBN")
|
|
26
|
+
a = node.attr("isbn10") and
|
|
27
|
+
add_noko_elem(xml, "docidentifier", a, type: "ISBN10")
|
|
26
28
|
csv_split(node.attr("docidentifier-additional"), ",")&.each do |n|
|
|
27
29
|
t, v = n.split(":", 2)
|
|
28
|
-
xml
|
|
30
|
+
add_noko_elem(xml, "docidentifier", v, type: t)
|
|
29
31
|
end
|
|
30
|
-
xml
|
|
32
|
+
add_noko_elem(xml, "docnumber", node.attr("docnumber"))
|
|
31
33
|
end
|
|
32
34
|
|
|
33
35
|
def metadata_version(node, xml)
|
|
34
36
|
draft = metadata_version_value(node)
|
|
35
|
-
xml
|
|
37
|
+
add_noko_elem(xml, "edition", node.attr("edition"))
|
|
36
38
|
xml.version do |v|
|
|
37
|
-
v
|
|
38
|
-
v
|
|
39
|
+
add_noko_elem(v, "revision_date", node.attr("revdate"))
|
|
40
|
+
add_noko_elem(v, "draft", draft)
|
|
39
41
|
end
|
|
40
42
|
end
|
|
41
43
|
|
|
@@ -48,23 +50,24 @@ module Metanorma
|
|
|
48
50
|
|
|
49
51
|
def metadata_status(node, xml)
|
|
50
52
|
xml.status do |s|
|
|
51
|
-
s
|
|
52
|
-
|
|
53
|
-
|
|
53
|
+
add_noko_elem(s, "stage",
|
|
54
|
+
node.attr("status") || node.attr("docstage") || "published")
|
|
55
|
+
add_noko_elem(s, "substage", node.attr("docsubstage"))
|
|
56
|
+
add_noko_elem(s, "iteration", node.attr("iteration"))
|
|
54
57
|
end
|
|
55
58
|
end
|
|
56
59
|
|
|
57
60
|
def metadata_source(node, xml)
|
|
58
|
-
|
|
61
|
+
add_noko_elem(xml, "uri", node.attr("uri"))
|
|
59
62
|
%w(xml html pdf doc relaton).each do |t|
|
|
60
|
-
|
|
63
|
+
add_noko_elem(xml, "uri", node.attr("#{t}-uri"), type: t)
|
|
61
64
|
end
|
|
62
65
|
end
|
|
63
66
|
|
|
64
67
|
def metadata_date1(node, xml, type)
|
|
65
68
|
date = node.attr("#{type}-date")
|
|
66
69
|
date and xml.date(type:) do |d|
|
|
67
|
-
d
|
|
70
|
+
add_noko_elem(d, "on", date)
|
|
68
71
|
end
|
|
69
72
|
end
|
|
70
73
|
|
|
@@ -80,17 +83,17 @@ module Metanorma
|
|
|
80
83
|
a == "date" || /^date_\d+$/.match(a) or next
|
|
81
84
|
type, date = node.attr(a).split(/ /, 2)
|
|
82
85
|
type or next
|
|
83
|
-
xml.date(type:) { |d| d
|
|
86
|
+
xml.date(type:) { |d| add_noko_elem(d, "on", date) }
|
|
84
87
|
end
|
|
85
88
|
end
|
|
86
89
|
|
|
87
90
|
def metadata_language(node, xml)
|
|
88
|
-
xml
|
|
89
|
-
|
|
91
|
+
add_noko_elem(xml, "language", node.attr("language") || "en")
|
|
92
|
+
add_noko_elem(xml, "locale", node.attr("locale"))
|
|
90
93
|
end
|
|
91
94
|
|
|
92
95
|
def metadata_script(node, xml)
|
|
93
|
-
xml
|
|
96
|
+
add_noko_elem(xml, "script", node.attr("script") ||
|
|
94
97
|
Metanorma::Utils.default_script(node.attr("language")))
|
|
95
98
|
end
|
|
96
99
|
|
|
@@ -128,8 +131,8 @@ module Metanorma
|
|
|
128
131
|
xml.relation type: relation_normalise(type) do |r|
|
|
129
132
|
desc.nil? or r.description desc.tr("-", " ")
|
|
130
133
|
fetch_ref(r, doc, nil, **{}) or r.bibitem do |b|
|
|
131
|
-
b
|
|
132
|
-
b
|
|
134
|
+
add_noko_elem(b, "title", id[1] || "--")
|
|
135
|
+
add_noko_elem(b, "docidentifier", id[0])
|
|
133
136
|
end
|
|
134
137
|
end
|
|
135
138
|
end
|
|
@@ -137,7 +140,7 @@ module Metanorma
|
|
|
137
140
|
def metadata_keywords(node, xml)
|
|
138
141
|
node.attr("keywords") or return
|
|
139
142
|
node.attr("keywords").split(/,\s*/).each do |kw|
|
|
140
|
-
xml
|
|
143
|
+
add_noko_elem(xml, "keyword", kw)
|
|
141
144
|
end
|
|
142
145
|
end
|
|
143
146
|
|
|
@@ -145,7 +148,7 @@ module Metanorma
|
|
|
145
148
|
csv_split(node.attr("classification"), ",")&.each do |c|
|
|
146
149
|
vals = c.split(/:/, 2)
|
|
147
150
|
vals.size == 1 and vals = ["default", vals[0]]
|
|
148
|
-
xml
|
|
151
|
+
add_noko_elem(xml, "classification", vals[1], type: vals[0])
|
|
149
152
|
end
|
|
150
153
|
end
|
|
151
154
|
|
|
@@ -204,9 +207,8 @@ module Metanorma
|
|
|
204
207
|
end
|
|
205
208
|
|
|
206
209
|
def add_title_xml(xml, content, language, type)
|
|
207
|
-
xml
|
|
208
|
-
|
|
209
|
-
end
|
|
210
|
+
add_noko_elem(xml, "title", Metanorma::Utils::asciidoc_sub(content),
|
|
211
|
+
language: language, type: type)
|
|
210
212
|
end
|
|
211
213
|
|
|
212
214
|
def title_fallback(node, xml)
|
|
@@ -46,13 +46,13 @@ module Metanorma
|
|
|
46
46
|
committee[:agency_abbrev] = agency
|
|
47
47
|
agency = name
|
|
48
48
|
end
|
|
49
|
-
xml
|
|
49
|
+
add_noko_elem(xml, "name", agency)
|
|
50
50
|
s = committee
|
|
51
51
|
loop do
|
|
52
52
|
contrib_committee_subdiv(xml, s)
|
|
53
53
|
s = s[:subdiv] or break
|
|
54
54
|
end
|
|
55
|
-
|
|
55
|
+
add_noko_elem(xml, "abbreviation", committee[:agency_abbrev])
|
|
56
56
|
full_committee_id(xml.parent)
|
|
57
57
|
end
|
|
58
58
|
|
|
@@ -60,9 +60,9 @@ module Metanorma
|
|
|
60
60
|
contributors_committees_filter_empty?(committee) and return
|
|
61
61
|
xml.subdivision **attr_code(type: committee[:subdivtype],
|
|
62
62
|
subtype: committee[:type]) do |o|
|
|
63
|
-
o
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
add_noko_elem(o, "name", committee[:name])
|
|
64
|
+
add_noko_elem(o, "abbreviation", committee[:abbr])
|
|
65
|
+
add_noko_elem(o, "identifier", committee[:ident])
|
|
66
66
|
end
|
|
67
67
|
end
|
|
68
68
|
|
|
@@ -37,19 +37,19 @@ module Metanorma
|
|
|
37
37
|
type = node.attr("role#{suffix}")&.downcase || "author"
|
|
38
38
|
desc = node.attr("role-description#{suffix}")
|
|
39
39
|
contrib.role type: type do |r|
|
|
40
|
-
|
|
41
|
-
d << desc
|
|
42
|
-
end
|
|
40
|
+
add_noko_elem(r, "description", desc)
|
|
43
41
|
end
|
|
44
42
|
end
|
|
45
43
|
|
|
46
44
|
def personal_contact(node, suffix, person)
|
|
47
|
-
node.attr("phone#{suffix}") and
|
|
45
|
+
node.attr("phone#{suffix}") and
|
|
46
|
+
add_noko_elem(person, "phone", node.attr("phone#{suffix}"))
|
|
48
47
|
node.attr("fax#{suffix}") and
|
|
49
|
-
person
|
|
50
|
-
node.attr("email#{suffix}") and
|
|
48
|
+
add_noko_elem(person, "phone", node.attr("fax#{suffix}"), type: "fax")
|
|
49
|
+
node.attr("email#{suffix}") and
|
|
50
|
+
add_noko_elem(person, "email", node.attr("email#{suffix}"))
|
|
51
51
|
node.attr("contributor-uri#{suffix}") and
|
|
52
|
-
person
|
|
52
|
+
add_noko_elem(person, "uri", node.attr("contributor-uri#{suffix}"))
|
|
53
53
|
end
|
|
54
54
|
|
|
55
55
|
def personal_author1(node, xml, suffix)
|
|
@@ -67,25 +67,25 @@ module Metanorma
|
|
|
67
67
|
def person_name(node, _xml, suffix, person)
|
|
68
68
|
person.name do |n|
|
|
69
69
|
if node.attr("fullname#{suffix}")
|
|
70
|
-
n
|
|
70
|
+
add_noko_elem(n, "completename", node.attr("fullname#{suffix}"))
|
|
71
71
|
else
|
|
72
|
-
n
|
|
73
|
-
n
|
|
74
|
-
n
|
|
72
|
+
add_noko_elem(n, "forename", node.attr("givenname#{suffix}"))
|
|
73
|
+
add_noko_elem(n, "initial", node.attr("initials#{suffix}"))
|
|
74
|
+
add_noko_elem(n, "surname", node.attr("surname#{suffix}"))
|
|
75
75
|
end
|
|
76
76
|
end
|
|
77
77
|
end
|
|
78
78
|
|
|
79
79
|
def person_credentials(node, _xml, suffix, person)
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
add_noko_elem(person, "credentials",
|
|
81
|
+
node.attr("contributor-credentials#{suffix}"))
|
|
82
82
|
end
|
|
83
83
|
|
|
84
84
|
def person_affiliation(node, _xml, suffix, person)
|
|
85
85
|
aff = node.attr("affiliation#{suffix}")
|
|
86
86
|
pos = node.attr("contributor-position#{suffix}")
|
|
87
87
|
(aff || pos) and person.affiliation do |a|
|
|
88
|
-
|
|
88
|
+
add_noko_elem(a, "name", pos)
|
|
89
89
|
aff and a.organization do |o|
|
|
90
90
|
person_organization(node, suffix, o)
|
|
91
91
|
end
|
|
@@ -5,7 +5,7 @@ module Metanorma
|
|
|
5
5
|
ics = node.attr("library-ics")
|
|
6
6
|
ics&.split(/,\s*/)&.each do |i|
|
|
7
7
|
xml.ics do |elem|
|
|
8
|
-
elem
|
|
8
|
+
add_noko_elem(elem, "code", i)
|
|
9
9
|
icsdata = Isoics.fetch i
|
|
10
10
|
elem.text_ icsdata.description
|
|
11
11
|
end
|
|
@@ -24,15 +24,15 @@ module Metanorma
|
|
|
24
24
|
def structured_id(node, xml); end
|
|
25
25
|
|
|
26
26
|
def metadata_doctype(node, xml)
|
|
27
|
-
xml
|
|
27
|
+
add_noko_elem(xml, "doctype", doctype(node))
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
def metadata_subdoctype(node, xml)
|
|
31
|
-
|
|
31
|
+
add_noko_elem(xml, "subdoctype", node.attr("docsubtype"))
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
def metadata_flavor(_node, ext)
|
|
35
|
-
ext
|
|
35
|
+
add_noko_elem(ext, "flavor", processor.new.asciidoctor_backend.to_s)
|
|
36
36
|
end
|
|
37
37
|
|
|
38
38
|
def metadata_coverpage_images(node, xml)
|
|
@@ -40,7 +40,9 @@ module Metanorma
|
|
|
40
40
|
backpage-image).each do |n|
|
|
41
41
|
if a = node.attr(n)
|
|
42
42
|
xml.send n do |c|
|
|
43
|
-
a.split(",").each
|
|
43
|
+
a.split(",").each do |x|
|
|
44
|
+
c.image src: x
|
|
45
|
+
end
|
|
44
46
|
end
|
|
45
47
|
end
|
|
46
48
|
end
|
|
@@ -3,11 +3,11 @@ module Metanorma
|
|
|
3
3
|
module Front
|
|
4
4
|
def organization(org, orgname, node = nil, default_org = nil, attrs = {})
|
|
5
5
|
orgname, abbr = org_name_and_abbrev(attrs, orgname)
|
|
6
|
-
org
|
|
6
|
+
add_noko_elem(org, "name", orgname)
|
|
7
7
|
default_org && (a = node&.attr("subdivision")) && !attrs[:subdiv] and
|
|
8
8
|
subdivision(a, node&.attr("subdivision-abbr"), org)
|
|
9
9
|
a = attrs[:subdiv] and subdivision(a, nil, org)
|
|
10
|
-
|
|
10
|
+
add_noko_elem(org, "abbreviation", abbr)
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
def org_name_and_abbrev(org, orgname)
|
|
@@ -45,32 +45,30 @@ module Metanorma
|
|
|
45
45
|
def subdiv_build(list, org)
|
|
46
46
|
list.empty? and return
|
|
47
47
|
org.subdivision **attr_code(type: list[0][:type]) do |s|
|
|
48
|
-
s
|
|
48
|
+
add_noko_elem(s, "name", list[0][:value])
|
|
49
49
|
subdiv_build(list[1..], s)
|
|
50
|
-
|
|
50
|
+
add_noko_elem(s, "abbreviation", list[0][:abbr])
|
|
51
51
|
end
|
|
52
52
|
end
|
|
53
53
|
|
|
54
54
|
def org_address(org, xml)
|
|
55
55
|
p = org[:address] and xml.address do |ad|
|
|
56
|
-
ad
|
|
57
|
-
f << p.gsub(/ \+\n/, "<br/>")
|
|
58
|
-
end
|
|
56
|
+
add_noko_elem(ad, "formattedAddress", p.gsub(/ \+\n/, "<br/>"))
|
|
59
57
|
end
|
|
60
58
|
org_contact(org, xml)
|
|
61
59
|
end
|
|
62
60
|
|
|
63
61
|
def org_contact(org, xml)
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
62
|
+
add_noko_elem(xml, "phone", org[:phone])
|
|
63
|
+
add_noko_elem(xml, "phone", org[:fax], type: "fax")
|
|
64
|
+
add_noko_elem(xml, "email", org[:email])
|
|
65
|
+
add_noko_elem(xml, "uri", org[:uri])
|
|
68
66
|
end
|
|
69
67
|
|
|
70
68
|
def person_organization(node, suffix, xml)
|
|
71
|
-
xml
|
|
72
|
-
|
|
73
|
-
|
|
69
|
+
add_noko_elem(xml, "name", node.attr("affiliation#{suffix}"))
|
|
70
|
+
add_noko_elem(xml, "abbreviation",
|
|
71
|
+
node.attr("affiliation_abbrev#{suffix}"))
|
|
74
72
|
a = node.attr("affiliation_subdiv#{suffix}") and
|
|
75
73
|
subdivision(a, nil, xml)
|
|
76
74
|
person_address(node, suffix, xml)
|
|
@@ -80,9 +78,8 @@ module Metanorma
|
|
|
80
78
|
def person_address(node, suffix, xml)
|
|
81
79
|
if node.attr("address#{suffix}")
|
|
82
80
|
xml.address do |ad|
|
|
83
|
-
ad
|
|
84
|
-
|
|
85
|
-
end
|
|
81
|
+
add_noko_elem(ad, "formattedAddress",
|
|
82
|
+
node.attr("address#{suffix}").gsub(/ \+\n/, "<br/>"))
|
|
86
83
|
end
|
|
87
84
|
elsif node.attr("country#{suffix}") || node.attr("city#{suffix}")
|
|
88
85
|
person_address_components(node, suffix, xml)
|
|
@@ -92,7 +89,7 @@ module Metanorma
|
|
|
92
89
|
def person_address_components(node, suffix, xml)
|
|
93
90
|
xml.address do |ad|
|
|
94
91
|
%w(street city state country postcode).each do |k|
|
|
95
|
-
|
|
92
|
+
add_noko_elem(ad, k, node.attr("#{k}#{suffix}"))
|
|
96
93
|
end
|
|
97
94
|
end
|
|
98
95
|
end
|
|
@@ -128,9 +125,7 @@ module Metanorma
|
|
|
128
125
|
|
|
129
126
|
def org_contributor_role(xml, org)
|
|
130
127
|
xml.role type: org[:role] do |r|
|
|
131
|
-
org[:desc]
|
|
132
|
-
d << org[:desc]
|
|
133
|
-
end
|
|
128
|
+
add_noko_elem(r, "description", org[:desc])
|
|
134
129
|
end
|
|
135
130
|
end
|
|
136
131
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
require_relative "utils"
|
|
2
2
|
require_relative "regex"
|
|
3
|
+
require "json"
|
|
3
4
|
|
|
4
5
|
module Metanorma
|
|
5
6
|
module Standoc
|
|
@@ -41,6 +42,7 @@ module Metanorma
|
|
|
41
42
|
@embed_id = node.attr("embed_id")
|
|
42
43
|
@document_scheme = document_scheme(node)
|
|
43
44
|
@source_linenums = node.attr("source-linenums-option") == "true"
|
|
45
|
+
# feeds log
|
|
44
46
|
@semantic_headless = node.attr("semantic-metadata-headless") == "true"
|
|
45
47
|
@default_doctype = "standard"
|
|
46
48
|
end
|
|
@@ -53,22 +55,46 @@ module Metanorma
|
|
|
53
55
|
@smartquotes = node.attr("smartquotes") != "false"
|
|
54
56
|
@sourcecode_markup_start = node.attr("sourcecode-markup-start") || "{{{"
|
|
55
57
|
@sourcecode_markup_end = node.attr("sourcecode-markup-end") || "}}}"
|
|
56
|
-
@blockunnumbered = (node.attr("block-unnumbered")
|
|
57
|
-
.map(&:strip)
|
|
58
|
+
@blockunnumbered = csv_split(node.attr("block-unnumbered"), ",")
|
|
58
59
|
end
|
|
59
60
|
|
|
60
61
|
def init_log(node)
|
|
61
62
|
@log or return
|
|
63
|
+
@semantic_headless and return
|
|
62
64
|
severity = node.attr("log-filter-severity")&.to_i || 4
|
|
63
|
-
category = node.attr("log-filter-category")
|
|
64
|
-
|
|
65
|
-
|
|
65
|
+
category = csv_split(node.attr("log-filter-category"), ",")
|
|
66
|
+
error_ids = csv_split(node.attr("log-filter-error-ids"), ",")
|
|
67
|
+
locations = cleanup_log_filter_error_log(
|
|
68
|
+
extract_log_filter_error_loc(node),
|
|
69
|
+
)
|
|
70
|
+
@log.suppress_log = { severity:, category:, error_ids:, locations: }
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def extract_log_filter_error_loc(node)
|
|
74
|
+
locations = JSON.parse(node.attr("log-filter-error-loc") || "[]")
|
|
75
|
+
locations = [locations] unless locations.is_a?(Array)
|
|
76
|
+
locations.map { |loc| loc.transform_keys(&:to_sym) }
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def cleanup_log_filter_error_log(locations)
|
|
80
|
+
locations.each do |loc|
|
|
81
|
+
loc[:to] ||= loc[:from]
|
|
82
|
+
loc[:error_ids] ||= []
|
|
83
|
+
loc[:error_ids] &&= Array(loc[:error_ids])
|
|
84
|
+
end
|
|
66
85
|
end
|
|
67
86
|
|
|
68
87
|
def init_image(node)
|
|
69
88
|
@datauriimage = node.attr("data-uri-image") != "false"
|
|
70
89
|
@datauriattachment = node.attr("data-uri-attachment") != "false"
|
|
71
90
|
@dataurimaxsize = node.attr("data-uri-maxsize")&.to_i || 13981013
|
|
91
|
+
@svg_conform_profile =
|
|
92
|
+
node.attr("svg-conform-profile")&.sub(/^:/, "") ||
|
|
93
|
+
default_svg_conform_profile
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def default_svg_conform_profile
|
|
97
|
+
:metanorma
|
|
72
98
|
end
|
|
73
99
|
|
|
74
100
|
def init_reqt(node)
|
|
@@ -34,9 +34,7 @@ module Metanorma
|
|
|
34
34
|
results = Plurimath::Math.parse(lxm_input, "latex")
|
|
35
35
|
.to_mathml(display_style: block)
|
|
36
36
|
if results.nil?
|
|
37
|
-
@log.add("
|
|
38
|
-
"latexmlmath failed to process equation:\n#{lxm_input}",
|
|
39
|
-
severity: 1)
|
|
37
|
+
@log.add("STANDOC_51", nil, params: [lxm_input])
|
|
40
38
|
return
|
|
41
39
|
end
|
|
42
40
|
results.sub(%r{<math ([^>]+ )?display="block"}, "<math \\1")
|
|
@@ -51,7 +49,8 @@ module Metanorma
|
|
|
51
49
|
end
|
|
52
50
|
elsif style == :latexmath then latex_parse(text, xml, attrs)
|
|
53
51
|
else
|
|
54
|
-
xml.stem text&.gsub("&#", "&#")
|
|
52
|
+
xml.stem text&.gsub("&#", "&#") || "",
|
|
53
|
+
**attrs.merge(type: "AsciiMath")
|
|
55
54
|
end
|
|
56
55
|
end
|
|
57
56
|
|
|
@@ -81,9 +80,7 @@ module Metanorma
|
|
|
81
80
|
end
|
|
82
81
|
|
|
83
82
|
def highlight_parse(text, xml)
|
|
84
|
-
xml
|
|
85
|
-
s << text
|
|
86
|
-
end
|
|
83
|
+
add_noko_elem(xml, "span", text, class: "fmt-hi")
|
|
87
84
|
end
|
|
88
85
|
|
|
89
86
|
def inline_quoted(node)
|
|
@@ -181,16 +178,38 @@ module Metanorma
|
|
|
181
178
|
def inline_indexterm(node)
|
|
182
179
|
noko do |xml|
|
|
183
180
|
node.type == :visible and xml << node.text
|
|
184
|
-
terms = (node
|
|
185
|
-
inline_indexterm1(xml, terms)
|
|
181
|
+
terms, see, also = inline_indexterm_extract(node)
|
|
182
|
+
(see || also) or inline_indexterm1(xml, terms)
|
|
183
|
+
also and
|
|
184
|
+
inline_indexterm_see(xml, terms, also, true)
|
|
185
|
+
see and
|
|
186
|
+
inline_indexterm_see(xml, terms, [see], false)
|
|
186
187
|
end
|
|
187
188
|
end
|
|
188
189
|
|
|
190
|
+
def inline_indexterm_extract(node)
|
|
191
|
+
terms = (node.attr("terms") || [node.text]).map { |x| xml_encode(x) }
|
|
192
|
+
see = node.attr("see")
|
|
193
|
+
also = node.attr("see-also")
|
|
194
|
+
[terms, see, also]
|
|
195
|
+
end
|
|
196
|
+
|
|
189
197
|
def inline_indexterm1(xml, terms)
|
|
190
198
|
xml.index do |i|
|
|
191
|
-
i
|
|
192
|
-
|
|
193
|
-
|
|
199
|
+
add_noko_elem(i, "primary", terms[0])
|
|
200
|
+
add_noko_elem(i, "secondary", terms[1])
|
|
201
|
+
add_noko_elem(i, "tertiary", terms[2])
|
|
202
|
+
end
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
def inline_indexterm_see(xml, terms, ref, also)
|
|
206
|
+
ref.each do |r|
|
|
207
|
+
xml.index_xref also: also do |i|
|
|
208
|
+
add_noko_elem(i, "primary", terms[0])
|
|
209
|
+
add_noko_elem(i, "secondary", terms[1])
|
|
210
|
+
add_noko_elem(i, "tertiary", terms[2])
|
|
211
|
+
add_noko_elem(i, "target", r)
|
|
212
|
+
end
|
|
194
213
|
end
|
|
195
214
|
end
|
|
196
215
|
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
2
|
<grammar xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
|
|
3
|
-
<!-- VERSION v2.1.
|
|
3
|
+
<!-- VERSION v2.1.4 -->
|
|
4
4
|
|
|
5
5
|
<!--
|
|
6
6
|
ALERT: cannot have root comments, because of https://github.com/metanorma/metanorma/issues/437
|
|
@@ -905,15 +905,32 @@ titlecase, or lowercase</a:documentation>
|
|
|
905
905
|
</element>
|
|
906
906
|
</define>
|
|
907
907
|
<define name="image" combine="choice">
|
|
908
|
-
<
|
|
909
|
-
<
|
|
910
|
-
|
|
911
|
-
<
|
|
912
|
-
|
|
913
|
-
<
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
908
|
+
<choice>
|
|
909
|
+
<element name="image">
|
|
910
|
+
<ref name="RequiredId"/>
|
|
911
|
+
<ref name="ImageAttributes"/>
|
|
912
|
+
<optional>
|
|
913
|
+
<element name="svg">
|
|
914
|
+
<a:documentation>Allow svg in image/svg, for consistency</a:documentation>
|
|
915
|
+
<oneOrMore>
|
|
916
|
+
<choice>
|
|
917
|
+
<text/>
|
|
918
|
+
<ref name="AnyElement"/>
|
|
919
|
+
</choice>
|
|
920
|
+
</oneOrMore>
|
|
921
|
+
</element>
|
|
922
|
+
</optional>
|
|
923
|
+
</element>
|
|
924
|
+
<element name="svg">
|
|
925
|
+
<a:documentation>Add svg mark up to image</a:documentation>
|
|
926
|
+
<oneOrMore>
|
|
927
|
+
<choice>
|
|
928
|
+
<text/>
|
|
929
|
+
<ref name="AnyElement"/>
|
|
930
|
+
</choice>
|
|
931
|
+
</oneOrMore>
|
|
932
|
+
</element>
|
|
933
|
+
</choice>
|
|
917
934
|
</define>
|
|
918
935
|
<define name="ParagraphFnBody" combine="interleave">
|
|
919
936
|
<ref name="BlockSource">
|
|
@@ -48,24 +48,20 @@ module Metanorma
|
|
|
48
48
|
end
|
|
49
49
|
|
|
50
50
|
def file_error(config)
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
@parent.log.add("Bibliography", nil, msg, severity: 0)
|
|
51
|
+
@parent.log.add("STANDOC_54", nil,
|
|
52
|
+
params: [config["file"], config["key"]])
|
|
54
53
|
""
|
|
55
54
|
end
|
|
56
55
|
|
|
57
56
|
def format_error(config)
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
@parent.log.add("Bibliography", nil, msg, severity: 0)
|
|
57
|
+
@parent.log.add("STANDOC_37", nil,
|
|
58
|
+
params: [config["format"], config["key"]])
|
|
61
59
|
{}
|
|
62
60
|
end
|
|
63
61
|
|
|
64
62
|
def get(id, file = default)
|
|
65
63
|
ret = @file_bibdb.dig(file, id) and return ret
|
|
66
|
-
|
|
67
|
-
"data source #{file}"
|
|
68
|
-
@parent.log.add("Bibliography", nil, msg, severity: 0)
|
|
64
|
+
@parent.log.add("STANDOC_19", nil, params: [id, file])
|
|
69
65
|
Nokogiri::XML("<bibitem/>")
|
|
70
66
|
end
|
|
71
67
|
end
|