metanorma-standoc 2.8.4 → 2.8.6
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 +24 -14
- data/lib/metanorma/standoc/base.rb +13 -110
- data/lib/metanorma/standoc/biblio.rng +24 -8
- data/lib/metanorma/standoc/blocks_image.rb +2 -1
- data/lib/metanorma/standoc/cleanup_image.rb +45 -23
- data/lib/metanorma/standoc/cleanup_section.rb +6 -10
- data/lib/metanorma/standoc/cleanup_section_names.rb +18 -11
- data/lib/metanorma/standoc/cleanup_xref.rb +5 -10
- data/lib/metanorma/standoc/front.rb +1 -1
- data/lib/metanorma/standoc/init.rb +114 -0
- data/lib/metanorma/standoc/inline.rb +1 -1
- data/lib/metanorma/standoc/isodoc.rng +67 -55
- data/lib/metanorma/standoc/macros_inline.rb +8 -2
- data/lib/metanorma/standoc/ref_queue.rb +1 -2
- data/lib/metanorma/standoc/section.rb +21 -28
- data/lib/metanorma/standoc/term_lookup_cleanup.rb +5 -9
- data/lib/metanorma/standoc/validate.rb +2 -2
- data/lib/metanorma/standoc/validate_section.rb +3 -3
- data/lib/metanorma/standoc/version.rb +1 -1
- data/metanorma-standoc.gemspec +1 -0
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26ef7eeadddd66ca86125ae72f91a3e920057ad5ed1e8f0e1e5670f831355d0b
|
4
|
+
data.tar.gz: e1d1e42f6d4962d11ab86421fec3fc2877480e33fdac9aabcc4bd478fd3cc2df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a014a7cbc4f3665f07322713d0edad6dbd42301eb3b0e548a78efd116f7c6da4b7359db4f26e3cbc50315cdbdad99169997493fa792000b6f36e63c49c8ace1
|
7
|
+
data.tar.gz: 25f39be9f0df10ecdfaea29ecdf2e1cf8a50789f80fce1cf6fa71cd23beb1a69f6b890e2ca69527bc486091631281cce5926f3b3ec743bdbbfb24b9c7d195264
|
@@ -31,10 +31,11 @@ module Metanorma
|
|
31
31
|
|
32
32
|
def inline_anchor_xref_attrs(node)
|
33
33
|
text = concatenate_attributes_to_xref_text(node)
|
34
|
-
m = inline_anchor_xref_match(text)
|
35
34
|
t = node.target.gsub(/^#/, "").gsub(%r{(\.xml|\.adoc)(#.*$)}, "\\2")
|
36
|
-
|
37
|
-
|
35
|
+
attrs, text = inline_anchor_xref_match(text)
|
36
|
+
attrs.empty? and
|
37
|
+
return { target: t, type: "inline", text: text, style: @xrefstyle }
|
38
|
+
inline_anchor_xref_attrs1(attrs, t, text)
|
38
39
|
end
|
39
40
|
|
40
41
|
def concatenate_attributes_to_xref_text(node)
|
@@ -44,20 +45,29 @@ module Metanorma
|
|
44
45
|
end.map { |x| x.sub(/%+/, "%") }.join + (node.text || "")
|
45
46
|
end
|
46
47
|
|
47
|
-
def inline_anchor_xref_attrs1(
|
48
|
-
{ target: target, hidden:
|
49
|
-
type:
|
50
|
-
case:
|
51
|
-
|
52
|
-
|
53
|
-
|
48
|
+
def inline_anchor_xref_attrs1(attrs, target, text)
|
49
|
+
{ target: target, hidden: attrs["hidden"],
|
50
|
+
type: attrs.key?("fn") ? "footnote" : "inline",
|
51
|
+
case: %w(capital lowercase).detect { |x| attrs.key?(x) },
|
52
|
+
label: attrs["label"],
|
53
|
+
style: attrs["style"] || @xrefstyle,
|
54
|
+
droploc: attrs.key?("droploc") ? true : nil,
|
55
|
+
text: text }.compact
|
54
56
|
end
|
55
57
|
|
58
|
+
XREF_ATTRS = "hidden|style|droploc|capital|lowercase|label".freeze
|
59
|
+
|
56
60
|
def inline_anchor_xref_match(text)
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
(
|
61
|
+
attrs = {}
|
62
|
+
while m = /^(#{XREF_ATTRS})(=[^%]+)?%(.*)$/o.match(text)
|
63
|
+
text = m[3]
|
64
|
+
attrs[m[1]] = m[2]&.sub(/^=/, "")
|
65
|
+
end
|
66
|
+
if m = /^(fn:?\s*)(\S.*)?$/.match(text)
|
67
|
+
text = m[2]
|
68
|
+
attrs["fn"] = ""
|
69
|
+
end
|
70
|
+
[attrs, text]
|
61
71
|
end
|
62
72
|
|
63
73
|
def inline_anchor_xref_text(match, text)
|
@@ -8,6 +8,7 @@ require "fileutils"
|
|
8
8
|
require "metanorma-utils"
|
9
9
|
require_relative "render"
|
10
10
|
require_relative "localbib"
|
11
|
+
require_relative "init"
|
11
12
|
require "mn-requirements"
|
12
13
|
|
13
14
|
module Metanorma
|
@@ -27,115 +28,6 @@ module Metanorma
|
|
27
28
|
self.class::XML_NAMESPACE
|
28
29
|
end
|
29
30
|
|
30
|
-
def init(node)
|
31
|
-
init_vars
|
32
|
-
init_misc(node)
|
33
|
-
init_processing(node)
|
34
|
-
init_reqt(node)
|
35
|
-
init_toc(node)
|
36
|
-
init_output(node) # feeds init_biblio
|
37
|
-
init_i18n(node)
|
38
|
-
init_biblio(node)
|
39
|
-
@metadata_attrs = metadata_attrs(node)
|
40
|
-
end
|
41
|
-
|
42
|
-
def init_vars
|
43
|
-
@fn_number ||= 0
|
44
|
-
@refids = Set.new
|
45
|
-
@anchor_alias = {}
|
46
|
-
@anchors = {}
|
47
|
-
@internal_eref_namespaces = []
|
48
|
-
@seen_headers = []
|
49
|
-
@seen_headers_canonical = []
|
50
|
-
@embed_hdr = []
|
51
|
-
@reqt_model = nil
|
52
|
-
@preface = true
|
53
|
-
end
|
54
|
-
|
55
|
-
def init_misc(node)
|
56
|
-
@doctype = doctype(node)
|
57
|
-
@draft = node.attributes.has_key?("draft")
|
58
|
-
@index_terms = node.attr("index-terms")
|
59
|
-
@boilerplateauthority = node.attr("boilerplate-authority")
|
60
|
-
@embed_hdr = node.attr("embed_hdr")
|
61
|
-
@embed_id = node.attr("embed_id")
|
62
|
-
@document_scheme = node.attr("document-scheme")
|
63
|
-
@xrefstyle = node.attr("xrefstyle")
|
64
|
-
@source_linenums = node.attr("source-linenums-option") == "true"
|
65
|
-
end
|
66
|
-
|
67
|
-
def init_processing(node)
|
68
|
-
@novalid = node.attr("novalid")
|
69
|
-
@smartquotes = node.attr("smartquotes") != "false"
|
70
|
-
@keepasciimath = node.attr("mn-keep-asciimath") &&
|
71
|
-
node.attr("mn-keep-asciimath") != "false"
|
72
|
-
@sourcecode_markup_start = node.attr("sourcecode-markup-start") || "{{{"
|
73
|
-
@sourcecode_markup_end = node.attr("sourcecode-markup-end") || "}}}"
|
74
|
-
@datauriimage = node.attr("data-uri-image") != "false"
|
75
|
-
@blockunnumbered = (node.attr("block-unnumbered") || "").split(",")
|
76
|
-
.map(&:strip)
|
77
|
-
end
|
78
|
-
|
79
|
-
def init_reqt(node)
|
80
|
-
@default_requirement_model = node.attr("requirements-model") ||
|
81
|
-
default_requirement_model
|
82
|
-
@reqt_models = requirements_processor
|
83
|
-
.new({ default: @default_requirement_model })
|
84
|
-
end
|
85
|
-
|
86
|
-
def init_toc(node)
|
87
|
-
@htmltoclevels = node.attr("toclevels-html") ||
|
88
|
-
node.attr("htmltoclevels") ||
|
89
|
-
node.attr("toclevels") || toc_default[:html_levels]
|
90
|
-
@doctoclevels = node.attr("toclevels-doc") ||
|
91
|
-
node.attr("doctoclevels") || node.attr("toclevels") ||
|
92
|
-
toc_default[:word_levels]
|
93
|
-
@pdftoclevels = node.attr("toclevels-pdf") ||
|
94
|
-
node.attr("toclevels") || toc_default[:pdf_levels]
|
95
|
-
@toclevels = node.attr("toclevels") || toc_default[:html_levels]
|
96
|
-
@tocfigures = node.attr("toc-figures")
|
97
|
-
@toctables = node.attr("toc-tables")
|
98
|
-
@tocrecommendations = node.attr("toc-recommendations")
|
99
|
-
end
|
100
|
-
|
101
|
-
def toc_default
|
102
|
-
{ word_levels: 2, html_levels: 2, pdf_levels: 2 }
|
103
|
-
end
|
104
|
-
|
105
|
-
def init_output(node)
|
106
|
-
@fontheader = default_fonts(node)
|
107
|
-
@files_to_delete = []
|
108
|
-
@filename = if node.attr("docfile")
|
109
|
-
File.basename(node.attr("docfile"))&.gsub(/\.adoc$/, "")
|
110
|
-
else ""
|
111
|
-
end
|
112
|
-
@localdir = Metanorma::Utils::localdir(node)
|
113
|
-
@output_dir = outputdir node
|
114
|
-
end
|
115
|
-
|
116
|
-
def init_i18n(node)
|
117
|
-
@lang = node.attr("language") || "en"
|
118
|
-
@script = node.attr("script") ||
|
119
|
-
Metanorma::Utils.default_script(node.attr("language"))
|
120
|
-
@locale = node.attr("locale")
|
121
|
-
@isodoc = isodoc(@lang, @script, @locale, node.attr("i18nyaml"))
|
122
|
-
@i18n = @isodoc.i18n
|
123
|
-
end
|
124
|
-
|
125
|
-
def init_biblio(node)
|
126
|
-
@no_isobib_cache = node.attr("no-isobib-cache")
|
127
|
-
@no_isobib = node.attr("no-isobib")
|
128
|
-
@bibdb = nil
|
129
|
-
init_bib_caches(node)
|
130
|
-
init_iev_caches(node)
|
131
|
-
@local_bibdb =
|
132
|
-
::Metanorma::Standoc::LocalBiblio.new(node, @localdir, self)
|
133
|
-
end
|
134
|
-
|
135
|
-
def requirements_processor
|
136
|
-
Metanorma::Requirements
|
137
|
-
end
|
138
|
-
|
139
31
|
def document(node)
|
140
32
|
ret = document1(node)
|
141
33
|
clean_exit
|
@@ -233,7 +125,7 @@ module Metanorma
|
|
233
125
|
end
|
234
126
|
|
235
127
|
def metadata_attrs(node)
|
236
|
-
node.attributes.each_with_object([]) do |(k, v), ret|
|
128
|
+
out = node.attributes.each_with_object([]) do |(k, v), ret|
|
237
129
|
%w(presentation semantic).each do |t|
|
238
130
|
/^#{t}-metadata-/.match?(k) or next
|
239
131
|
k = k.sub(/^#{t}-metadata-/, "")
|
@@ -242,6 +134,17 @@ module Metanorma
|
|
242
134
|
end
|
243
135
|
end
|
244
136
|
end.join
|
137
|
+
out + document_scheme_metadata(node)
|
138
|
+
end
|
139
|
+
|
140
|
+
def document_scheme_metadata(node)
|
141
|
+
a = document_scheme(node) or return ""
|
142
|
+
"<presentation-metadata><name>document-scheme</name>" \
|
143
|
+
"<value>#{a}</value></presentation-metadata>"
|
144
|
+
end
|
145
|
+
|
146
|
+
def document_scheme(node)
|
147
|
+
node.attr("document-scheme")
|
245
148
|
end
|
246
149
|
|
247
150
|
private
|
@@ -208,7 +208,9 @@
|
|
208
208
|
</define>
|
209
209
|
<define name="roledescription">
|
210
210
|
<element name="description">
|
211
|
-
<
|
211
|
+
<oneOrMore>
|
212
|
+
<ref name="TextElement"/>
|
213
|
+
</oneOrMore>
|
212
214
|
</element>
|
213
215
|
</define>
|
214
216
|
<define name="person">
|
@@ -333,7 +335,9 @@
|
|
333
335
|
</define>
|
334
336
|
<define name="affiliationdescription">
|
335
337
|
<element name="description">
|
336
|
-
<
|
338
|
+
<oneOrMore>
|
339
|
+
<ref name="TextElement"/>
|
340
|
+
</oneOrMore>
|
337
341
|
</element>
|
338
342
|
</define>
|
339
343
|
<define name="organization">
|
@@ -897,7 +901,9 @@
|
|
897
901
|
</define>
|
898
902
|
<define name="formattedref">
|
899
903
|
<element name="formattedref">
|
900
|
-
<
|
904
|
+
<oneOrMore>
|
905
|
+
<ref name="TextElement"/>
|
906
|
+
</oneOrMore>
|
901
907
|
</element>
|
902
908
|
</define>
|
903
909
|
<define name="license">
|
@@ -942,7 +948,9 @@
|
|
942
948
|
<optional>
|
943
949
|
<attribute name="type"/>
|
944
950
|
</optional>
|
945
|
-
<
|
951
|
+
<zeroOrMore>
|
952
|
+
<ref name="TextElement"/>
|
953
|
+
</zeroOrMore>
|
946
954
|
</define>
|
947
955
|
<!-- TitleType = ( "alternative" | "original" | "unofficial" | "subtitle" | "main" ) -->
|
948
956
|
<define name="TypedUri">
|
@@ -1042,7 +1050,9 @@
|
|
1042
1050
|
<optional>
|
1043
1051
|
<attribute name="script"/>
|
1044
1052
|
</optional>
|
1045
|
-
<
|
1053
|
+
<oneOrMore>
|
1054
|
+
<ref name="TextElement"/>
|
1055
|
+
</oneOrMore>
|
1046
1056
|
</element>
|
1047
1057
|
</define>
|
1048
1058
|
<define name="docnumber">
|
@@ -1267,12 +1277,16 @@
|
|
1267
1277
|
<optional>
|
1268
1278
|
<attribute name="type"/>
|
1269
1279
|
</optional>
|
1270
|
-
<
|
1280
|
+
<oneOrMore>
|
1281
|
+
<ref name="TextElement"/>
|
1282
|
+
</oneOrMore>
|
1271
1283
|
</element>
|
1272
1284
|
</define>
|
1273
1285
|
<define name="bibabstract">
|
1274
1286
|
<element name="abstract">
|
1275
|
-
<
|
1287
|
+
<oneOrMore>
|
1288
|
+
<ref name="TextElement"/>
|
1289
|
+
</oneOrMore>
|
1276
1290
|
</element>
|
1277
1291
|
</define>
|
1278
1292
|
<define name="copyright">
|
@@ -1377,7 +1391,9 @@
|
|
1377
1391
|
</attribute>
|
1378
1392
|
<optional>
|
1379
1393
|
<element name="description">
|
1380
|
-
<
|
1394
|
+
<oneOrMore>
|
1395
|
+
<ref name="TextElement"/>
|
1396
|
+
</oneOrMore>
|
1381
1397
|
</element>
|
1382
1398
|
</optional>
|
1383
1399
|
<element name="bibitem">
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require "vectory"
|
2
|
+
require "crass"
|
2
3
|
|
3
4
|
module Metanorma
|
4
5
|
module Standoc
|
5
6
|
module Cleanup
|
6
7
|
def svgmap_cleanup(xmldoc)
|
7
|
-
svg_uniqueids(xmldoc)
|
8
8
|
svgmap_moveattrs(xmldoc)
|
9
9
|
svgmap_populate(xmldoc)
|
10
10
|
Vectory::SvgMapping.new(xmldoc, @localdir).call
|
@@ -31,8 +31,7 @@ module Metanorma
|
|
31
31
|
def svgmap_moveattrs1(svgmap, figure)
|
32
32
|
%w(unnumbered number subsequence keep-with-next
|
33
33
|
keep-lines-together tag multilingual-rendering).each do |a|
|
34
|
-
|
35
|
-
|
34
|
+
figure[a] || !svgmap[a] and next
|
36
35
|
figure[a] = svgmap[a]
|
37
36
|
svgmap.delete(a)
|
38
37
|
end
|
@@ -44,7 +43,7 @@ module Metanorma
|
|
44
43
|
s.children.remove
|
45
44
|
f = s1.at(".//figure") and s << f
|
46
45
|
s1.xpath(".//li").each do |li|
|
47
|
-
t = li
|
46
|
+
t = li.at(".//eref | .//link | .//xref") or next
|
48
47
|
href = t.xpath("./following-sibling::node()")
|
49
48
|
href.empty? or
|
50
49
|
s << %[<target href="#{svgmap_target(href)}">#{t.to_xml}</target>]
|
@@ -54,8 +53,7 @@ module Metanorma
|
|
54
53
|
|
55
54
|
def svgmap_target(nodeset)
|
56
55
|
nodeset.each do |n|
|
57
|
-
|
58
|
-
|
56
|
+
n.name == "link" or next
|
59
57
|
n.children = n["target"]
|
60
58
|
end
|
61
59
|
nodeset.text.sub(/^[,; ]/, "").strip
|
@@ -70,22 +68,51 @@ module Metanorma
|
|
70
68
|
end
|
71
69
|
end
|
72
70
|
end
|
73
|
-
|
71
|
+
svg_cleanup(xmldoc)
|
74
72
|
xmldoc
|
75
73
|
end
|
76
74
|
|
77
|
-
def
|
78
|
-
|
75
|
+
def svg_cleanup(xmldoc)
|
76
|
+
svg_uniqueids(xmldoc)
|
77
|
+
svg_classupdate(xmldoc)
|
78
|
+
end
|
79
79
|
|
80
|
+
def read_in_if_svg(img, localdir)
|
81
|
+
img["src"] or return false
|
80
82
|
path = Vectory::Utils.svgmap_rewrite0_path(img["src"], localdir)
|
81
83
|
File.file?(path) or return false
|
82
84
|
types = MIME::Types.type_for(path) or return false
|
83
85
|
types.first == "image/svg+xml" or return false
|
84
86
|
svg = File.read(path, encoding: "utf-8") or return false
|
85
|
-
img.
|
87
|
+
img.children = (Nokogiri::XML(svg).root)
|
86
88
|
true
|
87
89
|
end
|
88
90
|
|
91
|
+
def svg_classupdate(xmldoc)
|
92
|
+
xmldoc.xpath("//m:svg[m:style]", "m" => SVG_NS)
|
93
|
+
.each_with_index do |s, i|
|
94
|
+
svg_classupdate1(s, s.at("./m:style", "m" => SVG_NS), i)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def svg_classupdate1(svg, style, idx)
|
99
|
+
tree = Crass.parse(style.text)
|
100
|
+
tree.each { |n| svg_suffix_css_style(n, idx) }
|
101
|
+
style.children = Crass::Parser.stringify(tree)
|
102
|
+
svg.xpath(".//*[@class]").each do |n|
|
103
|
+
n["class"] = n["class"].split(/\s+/)
|
104
|
+
.map { |x| "#{x}_inject_#{idx}" }.join(" ")
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
def svg_suffix_css_style(node, idx)
|
109
|
+
node[:node] == :style_rule && /\./.match?(node[:selector][:value]) or
|
110
|
+
return
|
111
|
+
v = node[:selector][:value]
|
112
|
+
.gsub(/([^.\s]*\.\S+)/, "\\1_inject_#{idx}")
|
113
|
+
node[:selector] = Crass.parse("#{v} {}").first[:selector]
|
114
|
+
end
|
115
|
+
|
89
116
|
IRI_TAG_PROPERTIES_MAP = {
|
90
117
|
clipPath: ["clip-path"],
|
91
118
|
"color-profile": nil,
|
@@ -112,13 +139,12 @@ module Metanorma
|
|
112
139
|
|
113
140
|
def svg_iri_properties(id_elems)
|
114
141
|
iri_tag_names = id_elems.each_with_object([]) do |e, m|
|
115
|
-
IRI_TAG_PROPERTIES_MAP.key?(e.name.to_sym) and m
|
142
|
+
IRI_TAG_PROPERTIES_MAP.key?(e.name.to_sym) and m << e.name
|
116
143
|
end.uniq
|
117
144
|
iri_properties = iri_tag_names.each_with_object([]) do |t, m|
|
118
145
|
(IRI_TAG_PROPERTIES_MAP[t.to_sym] || [t]).each { |t1| m = m << t1 }
|
119
146
|
end.uniq
|
120
|
-
return []
|
121
|
-
|
147
|
+
iri_properties.empty? and return []
|
122
148
|
iri_properties << "style"
|
123
149
|
end
|
124
150
|
|
@@ -133,8 +159,7 @@ module Metanorma
|
|
133
159
|
|
134
160
|
def svg_uniqueids2(svg, iri_properties, idx, ids)
|
135
161
|
svg.traverse do |e|
|
136
|
-
|
137
|
-
|
162
|
+
e.element? or next
|
138
163
|
if e.name == "style"
|
139
164
|
svg_styleupdate(e, idx, ids)
|
140
165
|
elsif !e.attributes.empty?
|
@@ -159,8 +184,7 @@ module Metanorma
|
|
159
184
|
|
160
185
|
def svg_attrupdate(elem, iri_properties, idx, ids)
|
161
186
|
iri_properties.each do |p|
|
162
|
-
|
163
|
-
|
187
|
+
elem[p] or next
|
164
188
|
elem[p] = svg_update_url(elem[p], idx, ids)
|
165
189
|
end
|
166
190
|
end
|
@@ -168,17 +192,15 @@ module Metanorma
|
|
168
192
|
def svg_linkupdate(elem, idx, ids)
|
169
193
|
%w(xlink:href href).each do |ref|
|
170
194
|
iri = elem[ref]&.strip
|
171
|
-
|
172
|
-
|
173
|
-
|
195
|
+
/^#/.match?(iri) or next
|
196
|
+
ids[iri.sub(/^#/, "")] or next
|
174
197
|
elem[ref] += "_inject_#{idx}"
|
175
198
|
end
|
176
199
|
end
|
177
200
|
|
178
201
|
def svg_idupdate(elem, idx, ids)
|
179
|
-
|
180
|
-
|
181
|
-
|
202
|
+
elem["id"] or return
|
203
|
+
ids[elem["id"]] or return
|
182
204
|
elem["id"] += "_inject_#{idx}"
|
183
205
|
end
|
184
206
|
end
|
@@ -97,8 +97,7 @@ module Metanorma
|
|
97
97
|
def make_annexes(xml)
|
98
98
|
xml.xpath("//*[@annex]").each do |y|
|
99
99
|
y.delete("annex")
|
100
|
-
|
101
|
-
|
100
|
+
y.name == "annex" || !y.ancestors("annex").empty? and next
|
102
101
|
y.wrap("<annex/>")
|
103
102
|
y.parent["id"] = "_#{UUIDTools::UUID.random_create}"
|
104
103
|
y.parent["obligation"] = y["obligation"]
|
@@ -117,8 +116,7 @@ module Metanorma
|
|
117
116
|
|
118
117
|
def sections_level_cleanup(xml)
|
119
118
|
m = maxlevel(xml)
|
120
|
-
|
121
|
-
|
119
|
+
m < 6 and return
|
122
120
|
m.downto(6).each do |l|
|
123
121
|
xml.xpath("//clause[@level = '#{l}']").each do |c|
|
124
122
|
c.delete("level")
|
@@ -173,7 +171,7 @@ module Metanorma
|
|
173
171
|
r["obligation"] = "normative" unless r["obligation"]
|
174
172
|
end
|
175
173
|
xml.xpath(Utils::SUBCLAUSE_XPATH).each do |r|
|
176
|
-
o = r
|
174
|
+
o = r.at("./ancestor::*/@obligation")&.text and r["obligation"] = o
|
177
175
|
end
|
178
176
|
end
|
179
177
|
|
@@ -183,8 +181,7 @@ module Metanorma
|
|
183
181
|
end
|
184
182
|
|
185
183
|
def preface_clausebefore_cleanup(xmldoc)
|
186
|
-
|
187
|
-
|
184
|
+
xmldoc.at("//preface") or return
|
188
185
|
ins = insert_before(xmldoc, "//preface")
|
189
186
|
xmldoc.xpath("//preface//*[@beforeclauses = 'true']").each do |x|
|
190
187
|
x.delete("beforeclauses")
|
@@ -232,9 +229,8 @@ module Metanorma
|
|
232
229
|
loop do
|
233
230
|
found = false
|
234
231
|
xmldoc.xpath("//floating-title").each do |t|
|
235
|
-
|
236
|
-
|
237
|
-
|
232
|
+
t.next_element.nil? or next
|
233
|
+
%w(sections annex preface).include? t.parent.name and next
|
238
234
|
t.parent.next = t
|
239
235
|
found = true
|
240
236
|
end
|
@@ -16,22 +16,32 @@ module Metanorma
|
|
16
16
|
text or return
|
17
17
|
doc.xpath(xpath).each_with_index do |node, i|
|
18
18
|
first && !i.zero? and next
|
19
|
+
node["keeptitle"] == "true" and next
|
19
20
|
title = get_or_make_title(node)
|
20
|
-
|
21
|
-
fn.each(&:remove)
|
22
|
-
title.children = text
|
23
|
-
fn.each { |n| title << n }
|
21
|
+
set_title_with_footnotes(title, text)
|
24
22
|
end
|
25
23
|
end
|
26
24
|
|
25
|
+
def set_title_with_footnotes(title, text)
|
26
|
+
fn = title.xpath("./fn | ./bookmark | ./index")
|
27
|
+
fn.each(&:remove)
|
28
|
+
title.children = text
|
29
|
+
fn.each { |n| title << n }
|
30
|
+
end
|
31
|
+
|
27
32
|
def sections_names_cleanup(xml)
|
28
33
|
replace_title(xml, "//clause[@type = 'scope']", @i18n&.scope)
|
34
|
+
sections_names_pref_cleanup(xml)
|
35
|
+
section_names_refs_cleanup(xml)
|
36
|
+
section_names_terms_cleanup(xml)
|
37
|
+
xml.xpath("//*[@keeptitle]").each { |s| s.delete("keeptitle") }
|
38
|
+
end
|
39
|
+
|
40
|
+
def sections_names_pref_cleanup(xml)
|
29
41
|
replace_title(xml, "//preface//abstract", @i18n&.abstract)
|
30
42
|
replace_title(xml, "//foreword", @i18n&.foreword)
|
31
43
|
replace_title(xml, "//introduction", @i18n&.introduction)
|
32
44
|
replace_title(xml, "//acknowledgements", @i18n&.acknowledgements)
|
33
|
-
section_names_refs_cleanup(xml)
|
34
|
-
section_names_terms_cleanup(xml)
|
35
45
|
end
|
36
46
|
|
37
47
|
def section_names_refs_cleanup(xml)
|
@@ -82,11 +92,8 @@ module Metanorma
|
|
82
92
|
@i18n&.termsdefsymbolsabbrev, true)
|
83
93
|
replace_title(xml, "//terms#{NO_SYMABBR} | //clause[.//terms]#{NO_SYMABBR}",
|
84
94
|
@i18n&.termsdefsymbolsabbrev, true)
|
85
|
-
replace_title(
|
86
|
-
|
87
|
-
"//terms[not(.//definitions)] | //clause[.//terms][not(.//definitions)]",
|
88
|
-
@i18n&.termsdef, true
|
89
|
-
)
|
95
|
+
replace_title(xml, "//terms[not(.//definitions)] | //clause[.//terms][not(.//definitions)]",
|
96
|
+
@i18n&.termsdef, true)
|
90
97
|
end
|
91
98
|
|
92
99
|
# do not auto-name terms sections if there are terms subclauses
|
@@ -76,9 +76,8 @@ module Metanorma
|
|
76
76
|
def extract_localities_update_text(match)
|
77
77
|
ret = match[:text]
|
78
78
|
re = to_regex(LOCALITY_REGEX_VALUE_ONLY_STR)
|
79
|
-
|
79
|
+
re.match?(ret) && match[:punct] == ";" and
|
80
80
|
ret.sub!(%r{^(#{CONN_REGEX_STR})}o, "\\1#{match[:locality]}=")
|
81
|
-
end
|
82
81
|
ret
|
83
82
|
end
|
84
83
|
|
@@ -93,15 +92,13 @@ module Metanorma
|
|
93
92
|
end
|
94
93
|
|
95
94
|
def fill_in_eref_connectives(elem)
|
96
|
-
|
97
|
-
|
95
|
+
elem.xpath("./localityStack").size < 2 and return
|
98
96
|
elem.xpath("./localityStack[not(@connective)]").each do |l|
|
99
97
|
n = l.next_element
|
100
98
|
l["connective"] = if n && n.name == "localityStack" &&
|
101
99
|
n["connective"] == "to"
|
102
100
|
"from"
|
103
|
-
else "and"
|
104
|
-
end
|
101
|
+
else "and" end
|
105
102
|
end
|
106
103
|
end
|
107
104
|
|
@@ -193,9 +190,8 @@ module Metanorma
|
|
193
190
|
def xref_parse_compound_locations(locations)
|
194
191
|
l = locations.map { |y| y.split("!", 2) }
|
195
192
|
l.map.with_index do |y, i|
|
196
|
-
|
193
|
+
y.size == 1 and
|
197
194
|
y.unshift(l.dig(i + 1, 0) == "to" ? "from" : "and")
|
198
|
-
end
|
199
195
|
y
|
200
196
|
end
|
201
197
|
end
|
@@ -209,8 +205,7 @@ module Metanorma
|
|
209
205
|
def xref_cleanup1(xmldoc)
|
210
206
|
xmldoc.xpath("//xref").each do |x|
|
211
207
|
%r{:(?!//)}.match?(x["target"]) and xref_to_internal_eref(x)
|
212
|
-
|
213
|
-
|
208
|
+
x.name == "xref" or next
|
214
209
|
if refid? x["target"]
|
215
210
|
xref_to_eref(x, "eref")
|
216
211
|
elsif @anchor_alias[x["target"]] then xref_alias(x)
|
@@ -0,0 +1,114 @@
|
|
1
|
+
module Metanorma
|
2
|
+
module Standoc
|
3
|
+
module Base
|
4
|
+
def init(node)
|
5
|
+
init_vars
|
6
|
+
init_misc(node)
|
7
|
+
init_processing(node)
|
8
|
+
init_reqt(node)
|
9
|
+
init_toc(node)
|
10
|
+
init_output(node) # feeds init_biblio
|
11
|
+
init_i18n(node)
|
12
|
+
init_biblio(node)
|
13
|
+
@metadata_attrs = metadata_attrs(node)
|
14
|
+
end
|
15
|
+
|
16
|
+
def init_vars
|
17
|
+
@fn_number ||= 0
|
18
|
+
@refids = Set.new
|
19
|
+
@anchor_alias = {}
|
20
|
+
@anchors = {}
|
21
|
+
@internal_eref_namespaces = []
|
22
|
+
@seen_headers = []
|
23
|
+
@seen_headers_canonical = []
|
24
|
+
@embed_hdr = []
|
25
|
+
@reqt_model = nil
|
26
|
+
@preface = true
|
27
|
+
end
|
28
|
+
|
29
|
+
def init_misc(node)
|
30
|
+
@doctype = doctype(node)
|
31
|
+
@draft = node.attributes.has_key?("draft")
|
32
|
+
@index_terms = node.attr("index-terms")
|
33
|
+
@boilerplateauthority = node.attr("boilerplate-authority")
|
34
|
+
@embed_hdr = node.attr("embed_hdr")
|
35
|
+
@embed_id = node.attr("embed_id")
|
36
|
+
@document_scheme = node.attr("document-scheme")
|
37
|
+
@xrefstyle = node.attr("xrefstyle")
|
38
|
+
@source_linenums = node.attr("source-linenums-option") == "true"
|
39
|
+
end
|
40
|
+
|
41
|
+
def init_processing(node)
|
42
|
+
@novalid = node.attr("novalid")
|
43
|
+
@smartquotes = node.attr("smartquotes") != "false"
|
44
|
+
@keepasciimath = node.attr("mn-keep-asciimath") &&
|
45
|
+
node.attr("mn-keep-asciimath") != "false"
|
46
|
+
@sourcecode_markup_start = node.attr("sourcecode-markup-start") || "{{{"
|
47
|
+
@sourcecode_markup_end = node.attr("sourcecode-markup-end") || "}}}"
|
48
|
+
@datauriimage = node.attr("data-uri-image") != "false"
|
49
|
+
@blockunnumbered = (node.attr("block-unnumbered") || "").split(",")
|
50
|
+
.map(&:strip)
|
51
|
+
end
|
52
|
+
|
53
|
+
def init_reqt(node)
|
54
|
+
@default_requirement_model = node.attr("requirements-model") ||
|
55
|
+
default_requirement_model
|
56
|
+
@reqt_models = requirements_processor
|
57
|
+
.new({ default: @default_requirement_model })
|
58
|
+
end
|
59
|
+
|
60
|
+
def init_toc(node)
|
61
|
+
@htmltoclevels = node.attr("toclevels-html") ||
|
62
|
+
node.attr("htmltoclevels") ||
|
63
|
+
node.attr("toclevels") || toc_default[:html_levels]
|
64
|
+
@doctoclevels = node.attr("toclevels-doc") ||
|
65
|
+
node.attr("doctoclevels") || node.attr("toclevels") ||
|
66
|
+
toc_default[:word_levels]
|
67
|
+
@pdftoclevels = node.attr("toclevels-pdf") ||
|
68
|
+
node.attr("toclevels") || toc_default[:pdf_levels]
|
69
|
+
@toclevels = node.attr("toclevels") || toc_default[:html_levels]
|
70
|
+
@tocfigures = node.attr("toc-figures")
|
71
|
+
@toctables = node.attr("toc-tables")
|
72
|
+
@tocrecommendations = node.attr("toc-recommendations")
|
73
|
+
end
|
74
|
+
|
75
|
+
def toc_default
|
76
|
+
{ word_levels: 2, html_levels: 2, pdf_levels: 2 }
|
77
|
+
end
|
78
|
+
|
79
|
+
def init_output(node)
|
80
|
+
@fontheader = default_fonts(node)
|
81
|
+
@files_to_delete = []
|
82
|
+
@filename = if node.attr("docfile")
|
83
|
+
File.basename(node.attr("docfile"))&.gsub(/\.adoc$/, "")
|
84
|
+
else ""
|
85
|
+
end
|
86
|
+
@localdir = Metanorma::Utils::localdir(node)
|
87
|
+
@output_dir = outputdir node
|
88
|
+
end
|
89
|
+
|
90
|
+
def init_i18n(node)
|
91
|
+
@lang = node.attr("language") || "en"
|
92
|
+
@script = node.attr("script") ||
|
93
|
+
Metanorma::Utils.default_script(node.attr("language"))
|
94
|
+
@locale = node.attr("locale")
|
95
|
+
@isodoc = isodoc(@lang, @script, @locale, node.attr("i18nyaml"))
|
96
|
+
@i18n = @isodoc.i18n
|
97
|
+
end
|
98
|
+
|
99
|
+
def init_biblio(node)
|
100
|
+
@no_isobib_cache = node.attr("no-isobib-cache")
|
101
|
+
@no_isobib = node.attr("no-isobib")
|
102
|
+
@bibdb = nil
|
103
|
+
init_bib_caches(node)
|
104
|
+
init_iev_caches(node)
|
105
|
+
@local_bibdb =
|
106
|
+
::Metanorma::Standoc::LocalBiblio.new(node, @localdir, self)
|
107
|
+
end
|
108
|
+
|
109
|
+
def requirements_processor
|
110
|
+
Metanorma::Requirements
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
@@ -30,7 +30,7 @@ module Metanorma
|
|
30
30
|
results = Plurimath::Math.parse(lxm_input, "latex")
|
31
31
|
.to_mathml(display_style: block)
|
32
32
|
if results.nil?
|
33
|
-
@log.add("
|
33
|
+
@log.add("Maths", nil,
|
34
34
|
"latexmlmath failed to process equation:\n#{lxm_input}",
|
35
35
|
severity: 1)
|
36
36
|
return
|
@@ -156,44 +156,7 @@
|
|
156
156
|
</define>
|
157
157
|
<define name="xref">
|
158
158
|
<element name="xref">
|
159
|
-
<
|
160
|
-
<data type="string">
|
161
|
-
<param name="pattern">\i\c*|\c+#\c+</param>
|
162
|
-
</data>
|
163
|
-
</attribute>
|
164
|
-
<optional>
|
165
|
-
<attribute name="to">
|
166
|
-
<data type="string">
|
167
|
-
<param name="pattern">\i\c*|\c+#\c+</param>
|
168
|
-
</data>
|
169
|
-
</attribute>
|
170
|
-
</optional>
|
171
|
-
<optional>
|
172
|
-
<attribute name="type">
|
173
|
-
<ref name="ReferenceFormat"/>
|
174
|
-
</attribute>
|
175
|
-
</optional>
|
176
|
-
<optional>
|
177
|
-
<attribute name="alt"/>
|
178
|
-
</optional>
|
179
|
-
<optional>
|
180
|
-
<attribute name="case">
|
181
|
-
<choice>
|
182
|
-
<value>capital</value>
|
183
|
-
<value>lowercase</value>
|
184
|
-
</choice>
|
185
|
-
</attribute>
|
186
|
-
</optional>
|
187
|
-
<optional>
|
188
|
-
<attribute name="droploc">
|
189
|
-
<data type="boolean"/>
|
190
|
-
</attribute>
|
191
|
-
</optional>
|
192
|
-
<optional>
|
193
|
-
<attribute name="style">
|
194
|
-
<ref name="XrefStyleType"/>
|
195
|
-
</attribute>
|
196
|
-
</optional>
|
159
|
+
<ref name="XrefAttributes"/>
|
197
160
|
<ref name="XrefBody"/>
|
198
161
|
</element>
|
199
162
|
</define>
|
@@ -407,23 +370,7 @@
|
|
407
370
|
</define>
|
408
371
|
<define name="figure">
|
409
372
|
<element name="figure">
|
410
|
-
<
|
411
|
-
<data type="ID"/>
|
412
|
-
</attribute>
|
413
|
-
<optional>
|
414
|
-
<attribute name="unnumbered">
|
415
|
-
<data type="boolean"/>
|
416
|
-
</attribute>
|
417
|
-
</optional>
|
418
|
-
<optional>
|
419
|
-
<attribute name="number"/>
|
420
|
-
</optional>
|
421
|
-
<optional>
|
422
|
-
<attribute name="subsequence"/>
|
423
|
-
</optional>
|
424
|
-
<optional>
|
425
|
-
<attribute name="class"/>
|
426
|
-
</optional>
|
373
|
+
<ref name="FigureAttributes"/>
|
427
374
|
<ref name="BlockAttributes"/>
|
428
375
|
<optional>
|
429
376
|
<ref name="tname"/>
|
@@ -2450,6 +2397,49 @@
|
|
2450
2397
|
</zeroOrMore>
|
2451
2398
|
</element>
|
2452
2399
|
</define>
|
2400
|
+
<define name="XrefAttributes">
|
2401
|
+
<attribute name="target">
|
2402
|
+
<data type="string">
|
2403
|
+
<param name="pattern">\i\c*|\c+#\c+</param>
|
2404
|
+
</data>
|
2405
|
+
</attribute>
|
2406
|
+
<optional>
|
2407
|
+
<attribute name="to">
|
2408
|
+
<data type="string">
|
2409
|
+
<param name="pattern">\i\c*|\c+#\c+</param>
|
2410
|
+
</data>
|
2411
|
+
</attribute>
|
2412
|
+
</optional>
|
2413
|
+
<optional>
|
2414
|
+
<attribute name="type">
|
2415
|
+
<ref name="ReferenceFormat"/>
|
2416
|
+
</attribute>
|
2417
|
+
</optional>
|
2418
|
+
<optional>
|
2419
|
+
<attribute name="alt"/>
|
2420
|
+
</optional>
|
2421
|
+
<optional>
|
2422
|
+
<attribute name="case">
|
2423
|
+
<choice>
|
2424
|
+
<value>capital</value>
|
2425
|
+
<value>lowercase</value>
|
2426
|
+
</choice>
|
2427
|
+
</attribute>
|
2428
|
+
</optional>
|
2429
|
+
<optional>
|
2430
|
+
<attribute name="droploc">
|
2431
|
+
<data type="boolean"/>
|
2432
|
+
</attribute>
|
2433
|
+
</optional>
|
2434
|
+
<optional>
|
2435
|
+
<attribute name="style">
|
2436
|
+
<ref name="XrefStyleType"/>
|
2437
|
+
</attribute>
|
2438
|
+
</optional>
|
2439
|
+
<optional>
|
2440
|
+
<attribute name="label"/>
|
2441
|
+
</optional>
|
2442
|
+
</define>
|
2453
2443
|
<define name="XrefBody">
|
2454
2444
|
<zeroOrMore>
|
2455
2445
|
<ref name="XrefTarget"/>
|
@@ -2528,6 +2518,28 @@
|
|
2528
2518
|
<attribute name="columns"/>
|
2529
2519
|
</optional>
|
2530
2520
|
</define>
|
2521
|
+
<define name="FigureAttributes">
|
2522
|
+
<attribute name="id">
|
2523
|
+
<data type="ID"/>
|
2524
|
+
</attribute>
|
2525
|
+
<optional>
|
2526
|
+
<attribute name="unnumbered">
|
2527
|
+
<data type="boolean"/>
|
2528
|
+
</attribute>
|
2529
|
+
</optional>
|
2530
|
+
<optional>
|
2531
|
+
<attribute name="number"/>
|
2532
|
+
</optional>
|
2533
|
+
<optional>
|
2534
|
+
<attribute name="subsequence"/>
|
2535
|
+
</optional>
|
2536
|
+
<optional>
|
2537
|
+
<attribute name="class"/>
|
2538
|
+
</optional>
|
2539
|
+
<optional>
|
2540
|
+
<attribute name="width"/>
|
2541
|
+
</optional>
|
2542
|
+
</define>
|
2531
2543
|
<start>
|
2532
2544
|
<ref name="standard-document"/>
|
2533
2545
|
</start>
|
@@ -27,7 +27,7 @@ module Metanorma
|
|
27
27
|
attrs.size > 1 && attrs.size < 5 and return true
|
28
28
|
e = "invalid index \"#{target}\" cross-reference: wrong number of " \
|
29
29
|
"attributes in `index:#{target}[#{attrs.values.join(',')}]`"
|
30
|
-
parent.converter.log.add("
|
30
|
+
parent.converter.log.add("Crossreferences", parent, e, severity: 0)
|
31
31
|
false
|
32
32
|
end
|
33
33
|
|
@@ -201,7 +201,13 @@ module Metanorma
|
|
201
201
|
using_format :short
|
202
202
|
|
203
203
|
def process(parent, _target, attrs)
|
204
|
-
|
204
|
+
t = attrs["text"]
|
205
|
+
t = if /,/.match?(t)
|
206
|
+
t.sub(/,/, "%")
|
207
|
+
else
|
208
|
+
"#{t}%"
|
209
|
+
end
|
210
|
+
create_anchor(parent, "hidden=#{t}",
|
205
211
|
type: :xref, target: "_#{UUIDTools::UUID.random_create}")
|
206
212
|
end
|
207
213
|
end
|
@@ -213,8 +213,7 @@ module Metanorma
|
|
213
213
|
end
|
214
214
|
|
215
215
|
def init_bib_caches(node)
|
216
|
-
|
217
|
-
|
216
|
+
@no_isobib and return
|
218
217
|
global = !@no_isobib_cache && !node.attr("local-cache-only")
|
219
218
|
local = node.attr("local-cache") || node.attr("local-cache-only")
|
220
219
|
local = nil if @no_isobib_cache
|
@@ -10,9 +10,8 @@ module Metanorma
|
|
10
10
|
@norm_ref = false
|
11
11
|
|
12
12
|
def sectiontype1(node)
|
13
|
-
|
14
|
-
|
15
|
-
node&.attr("heading")&.downcase ||
|
13
|
+
node.attr("style") == "abstract" and return "abstract"
|
14
|
+
node.attr("heading")&.downcase ||
|
16
15
|
node.title
|
17
16
|
.gsub(%r{<index>.*?</index>}m, "")
|
18
17
|
.gsub(%r{<fn[^>]*>.*?</fn>}m, "")
|
@@ -25,7 +24,7 @@ module Metanorma
|
|
25
24
|
ret = sectiontype1(node)
|
26
25
|
ret1 = preface_main_filter(sectiontype_streamline(ret), node)
|
27
26
|
ret1 == "symbols and abbreviated terms" and return ret1
|
28
|
-
!level || node.level == 1 or return nil
|
27
|
+
!level || node.level == 1 || node.attr("heading") or return nil
|
29
28
|
@seen_headers.include? ret and return nil
|
30
29
|
@seen_headers << ret unless ret1.nil?
|
31
30
|
@seen_headers_canonical << ret1 unless ret1.nil?
|
@@ -59,9 +58,12 @@ module Metanorma
|
|
59
58
|
["normative references", "terms and definitions", "scope",
|
60
59
|
"symbols and abbreviated terms", "clause", "bibliography"].freeze
|
61
60
|
|
62
|
-
def
|
63
|
-
|
61
|
+
def role_style(node, value)
|
62
|
+
node.role == value || node.attr("style") == value
|
63
|
+
end
|
64
64
|
|
65
|
+
def start_main_section(ret, node)
|
66
|
+
role_style(node, "preface") and return
|
65
67
|
@preface = false if self.class::MAIN_CLAUSE_NAMES.include?(ret)
|
66
68
|
@preface = false if self.class::PREFACE_CLAUSE_NAMES
|
67
69
|
.intersection(@seen_headers_canonical + [ret]).empty?
|
@@ -79,29 +81,20 @@ module Metanorma
|
|
79
81
|
end
|
80
82
|
|
81
83
|
def section_attributes(node)
|
82
|
-
ret =
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
tag: node&.attr("tag"),
|
94
|
-
"multilingual-rendering": node&.attr("multilingual-rendering"),
|
95
|
-
colophon: (if node.role == "colophon" ||
|
96
|
-
node.attr("style") == "colophon"
|
97
|
-
true
|
98
|
-
end),
|
99
|
-
preface: (if node.role == "preface" ||
|
100
|
-
node.attr("style") == "preface"
|
101
|
-
true
|
102
|
-
end) }
|
103
|
-
return ret unless node.attributes["change"]
|
84
|
+
ret =
|
85
|
+
{ id: Metanorma::Utils::anchor_or_uuid(node),
|
86
|
+
annex: role_style(node, "appendix") && node.level == 1 ? true : nil,
|
87
|
+
colophon: role_style(node, "colophon") ? true : nil,
|
88
|
+
preface: role_style(node, "preface") ? true : nil }
|
89
|
+
%w(language script number branch-number type tag keeptitle
|
90
|
+
multilingual-rendering).each do |k|
|
91
|
+
a = node.attr(k) and ret[k.to_sym] = a
|
92
|
+
end
|
93
|
+
section_attributes_change(node, ret).compact
|
94
|
+
end
|
104
95
|
|
96
|
+
def section_attributes_change(node, ret)
|
97
|
+
node.attributes["change"] or return ret
|
105
98
|
ret.merge(change: node.attributes["change"],
|
106
99
|
path: node.attributes["path"],
|
107
100
|
path_end: node.attributes["path_end"],
|
@@ -5,8 +5,6 @@ module Metanorma
|
|
5
5
|
# Intelligent term lookup xml modifier
|
6
6
|
class TermLookupCleanup
|
7
7
|
AUTO_GEN_ID_REGEXP = /\A_/.freeze
|
8
|
-
EXISTING_TERM_REGEXP = /\Aterm-/.freeze
|
9
|
-
EXISTING_SYMBOL_REGEXP = /\Asymbol-/.freeze
|
10
8
|
|
11
9
|
attr_reader :xmldoc, :lookup, :log
|
12
10
|
|
@@ -61,13 +59,12 @@ module Metanorma
|
|
61
59
|
def related_cleanup
|
62
60
|
xmldoc.xpath("//related").each do |n|
|
63
61
|
refterm = n.at("./refterm") or next
|
62
|
+
repl = "<preferred><expression>" \
|
63
|
+
"<name>#{refterm.children.to_xml}</name></expression></preferred>"
|
64
64
|
lookup = norm_ref_id_text(refterm.text.strip)
|
65
65
|
p = @lookup[:sec2prim][lookup] and refterm.children = @c.encode(p)
|
66
66
|
p || @lookup[:term][lookup] and
|
67
|
-
refterm.replace(
|
68
|
-
<preferred><expression><name>#{refterm.children.to_xml}</name></expression></preferred>
|
69
|
-
XML
|
70
|
-
)
|
67
|
+
refterm.replace(repl)
|
71
68
|
end
|
72
69
|
end
|
73
70
|
|
@@ -96,7 +93,7 @@ module Metanorma
|
|
96
93
|
def remove_missing_ref?(node)
|
97
94
|
node.at("../eref | ../termref") and return false
|
98
95
|
xref = node.at("../xref") or return true
|
99
|
-
xref["target"] && !xref["target"]
|
96
|
+
xref["target"] && !xref["target"].empty? and return false
|
100
97
|
xref.remove # if xref supplied by user, we won't delete
|
101
98
|
true
|
102
99
|
end
|
@@ -251,8 +248,7 @@ module Metanorma
|
|
251
248
|
end
|
252
249
|
|
253
250
|
def unique_text_id(text, prefix)
|
254
|
-
@idhash["#{prefix}-#{text}"] or
|
255
|
-
return "#{prefix}-#{text}"
|
251
|
+
@idhash["#{prefix}-#{text}"] or return "#{prefix}-#{text}"
|
256
252
|
(1..Float::INFINITY).lazy.each do |index|
|
257
253
|
@idhash["#{prefix}-#{text}-#{index}"] or
|
258
254
|
break("#{prefix}-#{text}-#{index}")
|
@@ -53,7 +53,7 @@ module Metanorma
|
|
53
53
|
orig = ""
|
54
54
|
a and orig += "\n\tAsciimath original: #{@c.decode(a.children.to_xml)}"
|
55
55
|
l and orig += "\n\tLatexmath original: #{@c.decode(l.children.to_xml)}"
|
56
|
-
@log.add("
|
56
|
+
@log.add("Maths", elem,
|
57
57
|
"Invalid MathML: #{math}\n #{error}#{orig}", severity: 0)
|
58
58
|
end
|
59
59
|
|
@@ -83,7 +83,7 @@ module Metanorma
|
|
83
83
|
outer.name == "figure" && inner.name == "figure" and return
|
84
84
|
err =
|
85
85
|
"There is an instance of #{inner.name} nested within #{outer.name}"
|
86
|
-
@log.add("
|
86
|
+
@log.add("Style", inner, err)
|
87
87
|
nested_asset_xref_report(outer, inner, doc)
|
88
88
|
end
|
89
89
|
|
@@ -21,14 +21,14 @@ module Metanorma
|
|
21
21
|
if callouts.size != annotations.size && !annotations.empty?
|
22
22
|
err = "mismatch of callouts (#{callouts.size}) and annotations " \
|
23
23
|
"(#{annotations.size})"
|
24
|
-
@log.add("
|
24
|
+
@log.add("Crossreferences", elem, err, severity: 0)
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
28
|
def style_warning(node, msg, text = nil)
|
29
29
|
w = msg
|
30
30
|
w += ": #{text}" if text
|
31
|
-
@log.add("
|
31
|
+
@log.add("Style", node, w)
|
32
32
|
end
|
33
33
|
|
34
34
|
def asset_title_style(root)
|
@@ -61,7 +61,7 @@ module Metanorma
|
|
61
61
|
docid = b.at("./docidentifier[@type = 'metanorma']") or next
|
62
62
|
/^\[\d+\]$/.match?(docid.text) or next
|
63
63
|
@log.add("Bibliography", b,
|
64
|
-
"Numeric reference in normative references", severity:
|
64
|
+
"Numeric reference in normative references", severity: 1)
|
65
65
|
end
|
66
66
|
end
|
67
67
|
end
|
data/metanorma-standoc.gemspec
CHANGED
@@ -30,6 +30,7 @@ Gem::Specification.new do |spec|
|
|
30
30
|
|
31
31
|
spec.add_dependency "addressable", "~> 2.8.0"
|
32
32
|
spec.add_dependency "asciidoctor", "~> 2.0.0"
|
33
|
+
spec.add_dependency "crass", "~> 1.0.0"
|
33
34
|
spec.add_dependency "iev", "~> 0.3.0"
|
34
35
|
spec.add_dependency "isodoc", "~> 2.9.0"
|
35
36
|
spec.add_dependency "metanorma", ">= 1.6.0"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metanorma-standoc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.8.
|
4
|
+
version: 2.8.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-03-
|
11
|
+
date: 2024-03-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 2.0.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: crass
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.0.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.0.0
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: iev
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -503,6 +517,7 @@ files:
|
|
503
517
|
- lib/metanorma/standoc/front.rb
|
504
518
|
- lib/metanorma/standoc/front_contributor.rb
|
505
519
|
- lib/metanorma/standoc/front_organisation.rb
|
520
|
+
- lib/metanorma/standoc/init.rb
|
506
521
|
- lib/metanorma/standoc/inline.rb
|
507
522
|
- lib/metanorma/standoc/isodoc-compile.rng
|
508
523
|
- lib/metanorma/standoc/isodoc.rng
|