metanorma-standoc 3.1.1 → 3.1.3
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/README.adoc +1 -1
- data/lib/metanorma/standoc/base.rb +1 -1
- data/lib/metanorma/standoc/basicdoc.rng +6 -6
- data/lib/metanorma/standoc/blocks.rb +5 -2
- data/lib/metanorma/standoc/blocks_notes.rb +14 -0
- data/lib/metanorma/standoc/cleanup_bibitem.rb +7 -1
- data/lib/metanorma/standoc/cleanup_block.rb +2 -2
- data/lib/metanorma/standoc/cleanup_boilerplate.rb +4 -5
- data/lib/metanorma/standoc/cleanup_image.rb +1 -1
- data/lib/metanorma/standoc/cleanup_inline.rb +1 -6
- data/lib/metanorma/standoc/cleanup_maths.rb +10 -0
- data/lib/metanorma/standoc/cleanup_section_names.rb +3 -10
- data/lib/metanorma/standoc/cleanup_terms_designations.rb +1 -1
- data/lib/metanorma/standoc/cleanup_text.rb +2 -9
- data/lib/metanorma/standoc/cleanup_xref.rb +1 -2
- data/lib/metanorma/standoc/converter.rb +0 -2
- data/lib/metanorma/standoc/isodoc.rng +8 -60
- data/lib/metanorma/standoc/macros_inline.rb +1 -3
- data/lib/metanorma/standoc/macros_note.rb +0 -14
- data/lib/metanorma/standoc/ref.rb +7 -4
- data/lib/metanorma/standoc/ref_queue.rb +4 -2
- data/lib/metanorma/standoc/ref_utility.rb +56 -59
- data/lib/metanorma/standoc/render.rb +1 -1
- data/lib/metanorma/standoc/spans_to_bibitem.rb +6 -5
- data/lib/metanorma/standoc/table.rb +1 -0
- data/lib/metanorma/standoc/utils.rb +2 -5
- data/lib/metanorma/standoc/version.rb +1 -1
- data/metanorma-standoc.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b781bd30313479321cf23297d77787c8500bda06c74a76028853f9b28d30510
|
4
|
+
data.tar.gz: bbdf82ad80d7a6b9f1f21582d7ab6eeb58b365d4aea706a49046d74b4e6309ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 398ae3eaa49e8d22a4612adecf703cc4d3d7ae1b4a056f29289e5e9517be690253a1fadabf67ef1d030763992c5d97b405cc8296275df5a98eb5fc40386b93da
|
7
|
+
data.tar.gz: 994a1d4820b1a68e2768ca5c189788f89a7487c1e9dd63f09178aed9c1dfd558f416a1c8521834c5e8d39b294f9a488a61778f3490e5e3aad04b10d7b5bcc386
|
data/README.adoc
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
image:https://img.shields.io/gem/v/metanorma-standoc.svg["Gem Version", link="https://rubygems.org/gems/metanorma-standoc"]
|
4
4
|
image:https://github.com/metanorma/metanorma-standoc/workflows/rake/badge.svg["Build Status", link="https://github.com/metanorma/metanorma-standoc/actions?workflow=rake"]
|
5
|
-
image:https://codeclimate.com/github/metanorma/metanorma-standoc/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/metanorma/metanorma-standoc"]
|
5
|
+
// image:https://codeclimate.com/github/metanorma/metanorma-standoc/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/metanorma/metanorma-standoc"]
|
6
6
|
image:https://img.shields.io/github/issues-pr-raw/metanorma/metanorma-standoc.svg["Pull Requests", link="https://github.com/metanorma/metanorma-standoc/pulls"]
|
7
7
|
image:https://img.shields.io/github/commits-since/metanorma/metanorma-standoc/latest.svg["Commits since latest",link="https://github.com/metanorma/metanorma-standoc/releases"]
|
8
8
|
|
@@ -139,7 +139,7 @@ module Metanorma
|
|
139
139
|
%w(presentation semantic).each do |t|
|
140
140
|
/^#{t}-metadata-/.match?(k) or next
|
141
141
|
k = k.sub(/^#{t}-metadata-/, "")
|
142
|
-
quoted_csv_split(v)&.each do |c|
|
142
|
+
quoted_csv_split(v.gsub("&#", "&#"))&.each do |c|
|
143
143
|
ret << "<#{t}-metadata><#{k}>#{c}</#{k}></#{t}-metadata>"
|
144
144
|
end
|
145
145
|
end
|
@@ -198,14 +198,14 @@ Applicable to modify and delete</a:documentation>
|
|
198
198
|
</zeroOrMore>
|
199
199
|
</element>
|
200
200
|
</optional>
|
201
|
-
<
|
201
|
+
<zeroOrMore>
|
202
202
|
<element name="description">
|
203
|
-
<a:documentation>Description of the change described in this block</a:documentation>
|
204
|
-
<
|
203
|
+
<a:documentation>Description(s) of the change described in this block</a:documentation>
|
204
|
+
<oneOrMore>
|
205
205
|
<ref name="BasicBlock"/>
|
206
|
-
</
|
206
|
+
</oneOrMore>
|
207
207
|
</element>
|
208
|
-
</
|
208
|
+
</zeroOrMore>
|
209
209
|
<optional>
|
210
210
|
<element name="newcontent">
|
211
211
|
<a:documentation>New content to be added to the document; applicable to add and modify</a:documentation>
|
@@ -1291,13 +1291,13 @@ Restricted recursively to contain only other such inline elements with no identi
|
|
1291
1291
|
<ref name="pure_strike"/>
|
1292
1292
|
<ref name="pure_smallcap"/>
|
1293
1293
|
<ref name="br"/>
|
1294
|
+
<ref name="stem"/>
|
1294
1295
|
</choice>
|
1295
1296
|
</define>
|
1296
1297
|
<define name="NestedTextElement">
|
1297
1298
|
<a:documentation>Contents of TextElement tags: leaves out tags that should occur only at top level of block: bookmark image hr pagebreak</a:documentation>
|
1298
1299
|
<choice>
|
1299
1300
|
<ref name="PureTextElement"/>
|
1300
|
-
<ref name="stem"/>
|
1301
1301
|
<ref name="eref"/>
|
1302
1302
|
<ref name="xref"/>
|
1303
1303
|
<ref name="hyperlink"/>
|
@@ -161,12 +161,15 @@ module Metanorma
|
|
161
161
|
type: node.attr("type"))))
|
162
162
|
end
|
163
163
|
|
164
|
-
# term sources occasionally turning up as "source source"?
|
164
|
+
# TODO: term sources occasionally turning up as "source source"?
|
165
165
|
def paragraph(node)
|
166
166
|
node.role&.sub(/ .*$/, "") == "source" and return termsource(node)
|
167
|
+
content = node.content
|
168
|
+
content.start_with?("TODO: ") and return todo_prefixed_para(node)
|
169
|
+
content.start_with?("EDITOR: ") and return editor_prefixed_para(node)
|
167
170
|
noko do |xml|
|
168
171
|
xml.p **para_attrs(node) do |xml_t|
|
169
|
-
xml_t <<
|
172
|
+
xml_t << content
|
170
173
|
end
|
171
174
|
end
|
172
175
|
end
|
@@ -46,6 +46,20 @@ module Metanorma
|
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
|
+
# -TO-DO :
|
50
|
+
def todo_prefixed_para(node)
|
51
|
+
node.lines[0].sub!(/^TODO: /, "")
|
52
|
+
todo(node)
|
53
|
+
end
|
54
|
+
|
55
|
+
# EDITOR:
|
56
|
+
def editor_prefixed_para(node)
|
57
|
+
node.lines[0].sub!(/^EDITOR: /, "")
|
58
|
+
node.set_attr("type", "editorial")
|
59
|
+
node.assign_caption "EDITOR"
|
60
|
+
admonition(node)
|
61
|
+
end
|
62
|
+
|
49
63
|
def termnote(node)
|
50
64
|
noko do |xml|
|
51
65
|
xml.termnote **termnote_attrs(node) do |ex|
|
@@ -6,6 +6,9 @@ module Metanorma
|
|
6
6
|
ret = new_bibitem_from_formattedref_spans(b)
|
7
7
|
merge_bibitem_from_formattedref_spans(b, ret)
|
8
8
|
end
|
9
|
+
xmldoc.xpath("//bibitem[@amend]").each do |b|
|
10
|
+
b.delete("amend")
|
11
|
+
end
|
9
12
|
end
|
10
13
|
|
11
14
|
def new_bibitem_from_formattedref_spans(bib)
|
@@ -18,9 +21,12 @@ module Metanorma
|
|
18
21
|
|
19
22
|
def merge_bibitem_from_formattedref_spans(bib, new)
|
20
23
|
new["type"] and bib["type"] = new["type"]
|
21
|
-
if bib.at("./title")
|
24
|
+
if bib.at("./title") && bib["amend"]
|
25
|
+
# there already is a fetched record here: merge
|
22
26
|
bib.children = MergeBibitems
|
23
27
|
.new(bib.to_xml, new.to_xml).merge.to_noko.children
|
28
|
+
elsif bib.at("./title") # replace record
|
29
|
+
bib.children = new.children.to_xml
|
24
30
|
else bib << new.children.to_xml
|
25
31
|
end
|
26
32
|
end
|
@@ -211,8 +211,8 @@ module Metanorma
|
|
211
211
|
def para_index_cleanup1(para, prev, foll)
|
212
212
|
if include_indexterm?(prev)
|
213
213
|
prev << para.remove.children
|
214
|
-
elsif include_indexterm?(foll) && !foll.children.empty?
|
215
|
-
foll.
|
214
|
+
elsif include_indexterm?(foll) # && !foll.children.empty?
|
215
|
+
foll.add_first_child para.remove.children
|
216
216
|
end
|
217
217
|
end
|
218
218
|
|
@@ -48,11 +48,9 @@ module Metanorma
|
|
48
48
|
x = xmldoc.dup
|
49
49
|
x.root.add_namespace(nil, xml_namespace)
|
50
50
|
xml = Nokogiri::XML(x.to_xml)
|
51
|
-
#require "debug"; binding.b
|
52
51
|
@isodoc ||= isodoc(@lang, @script, @locale)
|
53
52
|
# initialise @isodoc.xrefs, for @isodoc.xrefs.info
|
54
53
|
@isodoc.bibdata(xml) # do i18n
|
55
|
-
#@isodoc.info(xml, nil)
|
56
54
|
@isodoc
|
57
55
|
end
|
58
56
|
|
@@ -156,7 +154,7 @@ module Metanorma
|
|
156
154
|
if user_add.at("./clause") then built_in << user_add.children
|
157
155
|
else
|
158
156
|
user_add.name = "clause"
|
159
|
-
if user_add["id"].nil? ||
|
157
|
+
if user_add["id"].nil? || Metanorma::Utils::guid_anchor?(user_add["id"])
|
160
158
|
user_add["anchor"] = "_boilerplate-#{statement}-statement-append"
|
161
159
|
add_id(user_add)
|
162
160
|
end
|
@@ -167,11 +165,12 @@ module Metanorma
|
|
167
165
|
# Asciidoc macro, e.g. span:publisher[...]
|
168
166
|
# May contain one or more {{ }} in target, with spaces in them
|
169
167
|
# Does not end in \]
|
170
|
-
ADOC_MACRO_START =
|
168
|
+
ADOC_MACRO_START =
|
169
|
+
'\S+:(?:[^\[\] ]+|\{\{[^{}]+\}\})*\[.*?(?<!\\\\)\]'.freeze
|
171
170
|
|
172
171
|
# Replace {{ ... }} with {{ pass:[...]}} to preserve any XML markup
|
173
172
|
# use pass:[...\] if {{}} is already inside an Asciidoc macro
|
174
|
-
# Do not use pass: if this is a macro target: mailto:{{x}}[]
|
173
|
+
# Do not use pass: if this is a macro target: mailto:{{x}}[]
|
175
174
|
# or body: mailto:[{{x}}]
|
176
175
|
def boilerplate_read(file)
|
177
176
|
ret = File.read(file, encoding: "UTF-8")
|
@@ -14,7 +14,7 @@ module Metanorma
|
|
14
14
|
xmldoc.xpath("//svgmap").each do |s|
|
15
15
|
f = s.at(".//figure") or next
|
16
16
|
(t = s.at("./name")) && !f.at("./name") and
|
17
|
-
f.
|
17
|
+
f.add_first_child t.remove
|
18
18
|
if s["anchor"] # && Metanorma::Utils::guid_anchor?(f["id"])
|
19
19
|
f["anchor"] = s["anchor"]
|
20
20
|
s.delete("anchor")
|
@@ -143,17 +143,12 @@ module Metanorma
|
|
143
143
|
doc.xpath("//*[@id]").each_with_object({}) do |x, m|
|
144
144
|
# should always be true
|
145
145
|
Metanorma::Utils::guid_anchor?(x["id"]) or next
|
146
|
-
m[x["id"]] = contenthash(x)
|
146
|
+
m[x["id"]] = Metanorma::Utils::contenthash(x)
|
147
147
|
x["anchor"] and m[x["anchor"]] = m[x["id"]]
|
148
148
|
x["id"] = m[x["id"]]
|
149
149
|
end
|
150
150
|
end
|
151
151
|
|
152
|
-
def contenthash(elem)
|
153
|
-
Digest::MD5.hexdigest("#{elem.path}////#{elem.text}")
|
154
|
-
.sub(/^(.{8})(.{4})(.{4})(.{4})(.{12})$/, "_\\1-\\2-\\3-\\4-\\5")
|
155
|
-
end
|
156
|
-
|
157
152
|
def passthrough_cleanup(doc)
|
158
153
|
doc.xpath("//passthrough-inline").each do |p|
|
159
154
|
p.name = "passthrough"
|
@@ -179,6 +179,7 @@ module Metanorma
|
|
179
179
|
end
|
180
180
|
|
181
181
|
def mathml_cleanup(xmldoc)
|
182
|
+
mathml_number_to_mathml(xmldoc)
|
182
183
|
xmldoc.xpath("//stem[@type = 'MathML'][not(@validate = 'false')]")
|
183
184
|
.each do |x|
|
184
185
|
mathml_xml_cleanup(x)
|
@@ -189,6 +190,15 @@ module Metanorma
|
|
189
190
|
mathml_unitsml(xmldoc)
|
190
191
|
end
|
191
192
|
|
193
|
+
def mathml_number_to_mathml(xmldoc)
|
194
|
+
xmldoc.xpath("//mathml-number").each do |n|
|
195
|
+
n.name = "stem"
|
196
|
+
n["type"] = "MathML"
|
197
|
+
n.children =
|
198
|
+
"<math xmlns='#{MATHML_NS}'><mn>#{n.children.to_xml}</mn></math>"
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
192
202
|
include ::Metanorma::Standoc::Regex
|
193
203
|
end
|
194
204
|
end
|
@@ -2,13 +2,7 @@ module Metanorma
|
|
2
2
|
module Standoc
|
3
3
|
module Cleanup
|
4
4
|
def get_or_make_title(node)
|
5
|
-
|
6
|
-
if node.children.empty?
|
7
|
-
node << "<title/>"
|
8
|
-
else
|
9
|
-
node.children.first.previous = "<title/>"
|
10
|
-
end
|
11
|
-
end
|
5
|
+
node.at("./title") or node.add_first_child "<title/>"
|
12
6
|
ret = node.at("./title")
|
13
7
|
add_id(ret)
|
14
8
|
ret
|
@@ -154,7 +148,7 @@ module Metanorma
|
|
154
148
|
p.delete("variant_title")
|
155
149
|
p.xpath("(#{path})[last()]").each do |sect|
|
156
150
|
(ins = sect.at("./title") and ins.next = p) or
|
157
|
-
sect.
|
151
|
+
sect.add_first_child(p)
|
158
152
|
end
|
159
153
|
end
|
160
154
|
end
|
@@ -180,8 +174,7 @@ module Metanorma
|
|
180
174
|
def floating_title_preface2sections(xmldoc)
|
181
175
|
t = xmldoc.at("//preface/floating-title") or return
|
182
176
|
s = xmldoc.at("//sections")
|
183
|
-
t.next_element or
|
184
|
-
s.children.first.previous = t.remove
|
177
|
+
t.next_element or s.add_first_child(t.remove)
|
185
178
|
end
|
186
179
|
end
|
187
180
|
end
|
@@ -3,13 +3,7 @@ module Metanorma
|
|
3
3
|
module Cleanup
|
4
4
|
def textcleanup(result)
|
5
5
|
text = result.flatten.map(&:rstrip) * "\n"
|
6
|
-
text
|
7
|
-
#@semantic_headless and return text
|
8
|
-
#%w(passthrough passthrough-inline).each do |v|
|
9
|
-
#text.gsub!(%r{<#{v}\s+formats="metanorma">([^<]*)
|
10
|
-
#</#{v}>}mx) { @c.decode($1) }
|
11
|
-
#end
|
12
|
-
text
|
6
|
+
text.gsub(/(?<!\s)\s+<fn /, "<fn ")
|
13
7
|
end
|
14
8
|
|
15
9
|
def ancestor_include?(elem, ancestors)
|
@@ -133,8 +127,7 @@ module Metanorma
|
|
133
127
|
prev.content = "#{prev.text}#{m[1]}"
|
134
128
|
end
|
135
129
|
|
136
|
-
IGNORE_TEXT_ELEMENTS =
|
137
|
-
%w(index fn).freeze
|
130
|
+
IGNORE_TEXT_ELEMENTS = %w(index fn).freeze
|
138
131
|
|
139
132
|
def ignoretext?(elem)
|
140
133
|
IGNORE_TEXT_ELEMENTS.include? elem.name
|
@@ -150,8 +150,7 @@ module Metanorma
|
|
150
150
|
def xref_compound_cleanup1(xref, locations)
|
151
151
|
xref.children.empty? and xref.children = "<sentinel/>"
|
152
152
|
xref_parse_compound_locations(locations).reverse_each do |y|
|
153
|
-
xref.
|
154
|
-
"<xref target='#{y[1]}' connective='#{y[0]}'/>"
|
153
|
+
xref.add_first_child "<xref target='#{y[1]}' connective='#{y[0]}'/>"
|
155
154
|
end
|
156
155
|
xref&.at("./sentinel")&.remove
|
157
156
|
end
|
@@ -80,8 +80,6 @@ module Metanorma
|
|
80
80
|
inline_macro Metanorma::Standoc::SourceIncludeInlineMacro
|
81
81
|
block Metanorma::Standoc::ToDoAdmonitionBlock
|
82
82
|
block Metanorma::Standoc::EditorAdmonitionBlock
|
83
|
-
treeprocessor Metanorma::Standoc::EditorInlineAdmonitionBlock
|
84
|
-
treeprocessor Metanorma::Standoc::ToDoInlineAdmonitionBlock
|
85
83
|
block Metanorma::Standoc::PlantUMLBlockMacro
|
86
84
|
block Metanorma::Standoc::PseudocodeBlockMacro
|
87
85
|
block_macro Metanorma::Standoc::ColumnBreakBlockMacro
|
@@ -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.0
|
3
|
+
<!-- VERSION v2.1.0 -->
|
4
4
|
|
5
5
|
<!--
|
6
6
|
ALERT: cannot have root comments, because of https://github.com/metanorma/metanorma/issues/437
|
@@ -42,36 +42,6 @@ All IdRefType instances point not to `@id` in Semantic XML, which is the Content
|
|
42
42
|
but to `@anchor`, the user-supplied cross-reference</a:documentation>
|
43
43
|
<text/>
|
44
44
|
</define>
|
45
|
-
<define name="index-primary">
|
46
|
-
<element name="primary">
|
47
|
-
<oneOrMore>
|
48
|
-
<choice>
|
49
|
-
<ref name="PureTextElement"/>
|
50
|
-
<ref name="stem"/>
|
51
|
-
</choice>
|
52
|
-
</oneOrMore>
|
53
|
-
</element>
|
54
|
-
</define>
|
55
|
-
<define name="index-secondary">
|
56
|
-
<element name="secondary">
|
57
|
-
<oneOrMore>
|
58
|
-
<choice>
|
59
|
-
<ref name="PureTextElement"/>
|
60
|
-
<ref name="stem"/>
|
61
|
-
</choice>
|
62
|
-
</oneOrMore>
|
63
|
-
</element>
|
64
|
-
</define>
|
65
|
-
<define name="index-tertiary">
|
66
|
-
<element name="tertiary">
|
67
|
-
<oneOrMore>
|
68
|
-
<choice>
|
69
|
-
<ref name="PureTextElement"/>
|
70
|
-
<ref name="stem"/>
|
71
|
-
</choice>
|
72
|
-
</oneOrMore>
|
73
|
-
</element>
|
74
|
-
</define>
|
75
45
|
<define name="review">
|
76
46
|
<a:documentation>Generalise BasicDoc element from just review comments, to general annotations;
|
77
47
|
the type attribute defaults to `review` for reviews</a:documentation>
|
@@ -592,28 +562,6 @@ normative or informative references, some split references into sections organiz
|
|
592
562
|
</oneOrMore>
|
593
563
|
</element>
|
594
564
|
</define>
|
595
|
-
<define name="sub">
|
596
|
-
<a:documentation>Subscript text. Corresponds to HTML `sub</a:documentation>
|
597
|
-
<element name="sub">
|
598
|
-
<zeroOrMore>
|
599
|
-
<choice>
|
600
|
-
<ref name="PureTextElement"/>
|
601
|
-
<ref name="stem"/>
|
602
|
-
</choice>
|
603
|
-
</zeroOrMore>
|
604
|
-
</element>
|
605
|
-
</define>
|
606
|
-
<define name="sup">
|
607
|
-
<a:documentation>Superscript text. Corresponds to HTML `sup`</a:documentation>
|
608
|
-
<element name="sup">
|
609
|
-
<zeroOrMore>
|
610
|
-
<choice>
|
611
|
-
<ref name="PureTextElement"/>
|
612
|
-
<ref name="stem"/>
|
613
|
-
</choice>
|
614
|
-
</zeroOrMore>
|
615
|
-
</element>
|
616
|
-
</define>
|
617
565
|
<define name="pagebreak">
|
618
566
|
<a:documentation>Page break. Only applicable in paged layouts (e.g. PDF, Word), and not flow layouts (e.g. HTML)</a:documentation>
|
619
567
|
<element name="pagebreak">
|
@@ -735,6 +683,12 @@ titlecase, or lowercase</a:documentation>
|
|
735
683
|
<ref name="BlockAttributes"/>
|
736
684
|
</define>
|
737
685
|
<define name="TableAttributes" combine="interleave">
|
686
|
+
<optional>
|
687
|
+
<attribute name="plain">
|
688
|
+
<a:documentation>Render as a plain attribute, with no shading or borders</a:documentation>
|
689
|
+
<data type="boolean"/>
|
690
|
+
</attribute>
|
691
|
+
</optional>
|
738
692
|
<optional>
|
739
693
|
<attribute name="width">
|
740
694
|
<a:documentation>Width of the table block in rendering</a:documentation>
|
@@ -1088,7 +1042,6 @@ That concept may be defined as a term within the current document, or it may be
|
|
1088
1042
|
<zeroOrMore>
|
1089
1043
|
<choice>
|
1090
1044
|
<ref name="PureTextElement"/>
|
1091
|
-
<ref name="stem"/>
|
1092
1045
|
<ref name="index"/>
|
1093
1046
|
<ref name="index-xref"/>
|
1094
1047
|
</choice>
|
@@ -1101,7 +1054,6 @@ That concept may be defined as a term within the current document, or it may be
|
|
1101
1054
|
<zeroOrMore>
|
1102
1055
|
<choice>
|
1103
1056
|
<ref name="PureTextElement"/>
|
1104
|
-
<ref name="stem"/>
|
1105
1057
|
<ref name="index"/>
|
1106
1058
|
<ref name="index-xref"/>
|
1107
1059
|
</choice>
|
@@ -2019,10 +1971,7 @@ used in document amendments</a:documentation>
|
|
2019
1971
|
<element name="name">
|
2020
1972
|
<a:documentation>The symbolic form of the designation</a:documentation>
|
2021
1973
|
<oneOrMore>
|
2022
|
-
<
|
2023
|
-
<ref name="PureTextElement"/>
|
2024
|
-
<ref name="stem"/>
|
2025
|
-
</choice>
|
1974
|
+
<ref name="PureTextElement"/>
|
2026
1975
|
</oneOrMore>
|
2027
1976
|
</element>
|
2028
1977
|
</element>
|
@@ -2075,7 +2024,6 @@ used in document amendments</a:documentation>
|
|
2075
2024
|
<zeroOrMore>
|
2076
2025
|
<choice>
|
2077
2026
|
<ref name="PureTextElement"/>
|
2078
|
-
<ref name="stem"/>
|
2079
2027
|
<ref name="index"/>
|
2080
2028
|
<ref name="index-xref"/>
|
2081
2029
|
</choice>
|
@@ -233,9 +233,7 @@ module Metanorma
|
|
233
233
|
fmt = format(out, target)
|
234
234
|
fmt.empty? and fmt = "default"
|
235
235
|
fmt = %( number-format="#{fmt}")
|
236
|
-
|
237
|
-
<stem type="MathML"#{fmt}><math xmlns='#{MATHML_NS}'><mn>#{number(target)}</mn></math></stem>
|
238
|
-
OUTPUT
|
236
|
+
"<mathml-number#{fmt}>#{number(target)}</mathml-number>"
|
239
237
|
end
|
240
238
|
end
|
241
239
|
end
|
@@ -14,20 +14,6 @@ module Metanorma
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
class ToDoInlineAdmonitionBlock < Asciidoctor::Extensions::Treeprocessor
|
18
|
-
def process(document)
|
19
|
-
(document.find_by context: :paragraph).each do |para|
|
20
|
-
next unless /^TODO: /.match? para.lines[0]
|
21
|
-
|
22
|
-
para.set_attr("name", "todo")
|
23
|
-
para.set_attr("caption", "TODO")
|
24
|
-
para.lines[0].sub!(/^TODO: /, "")
|
25
|
-
# these will be converted from admonition to annotation downstream
|
26
|
-
para.context = :admonition
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
17
|
class FootnoteBlockInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
32
18
|
use_dsl
|
33
19
|
named :footnoteblock
|
@@ -130,10 +130,7 @@ module Metanorma
|
|
130
130
|
end
|
131
131
|
|
132
132
|
def refitem_render(xml, match, code)
|
133
|
-
xml.bibitem **
|
134
|
-
anchor: match[:anchor], suppress_identifier: code[:dropid],
|
135
|
-
hidden: code[:hidden], id: "_#{UUIDTools::UUID.random_create}"
|
136
|
-
) do |t|
|
133
|
+
xml.bibitem **refitem_render_attrs(match, code) do |t|
|
137
134
|
refitem_render_formattedref(t, match[:text])
|
138
135
|
yr_match = refitem1yr(code[:id])
|
139
136
|
refitem_render1(match, code, t)
|
@@ -143,6 +140,12 @@ module Metanorma
|
|
143
140
|
end
|
144
141
|
end
|
145
142
|
|
143
|
+
def refitem_render_attrs(match, code)
|
144
|
+
attr_code(anchor: match[:anchor], suppress_identifier: code[:dropid],
|
145
|
+
amend: code[:amend], hidden: code[:hidden],
|
146
|
+
id: "_#{UUIDTools::UUID.random_create}")
|
147
|
+
end
|
148
|
+
|
146
149
|
def refitem_render_formattedref(bibitem, title)
|
147
150
|
(title.nil? || title.empty?) and title = @i18n.no_information_available
|
148
151
|
bibitem.formattedref format: "application/x-isodoc+xml" do |i|
|
@@ -42,8 +42,9 @@ module Metanorma
|
|
42
42
|
ref, i, doc = results.pop
|
43
43
|
m[i.to_i] = { ref: }
|
44
44
|
if doc.is_a?(RelatonBib::RequestError)
|
45
|
-
@log.add("Bibliography", nil,
|
46
|
-
|
45
|
+
@log.add("Bibliography", nil,
|
46
|
+
"Could not retrieve #{ref[:code]}: " \
|
47
|
+
"no access to online site", severity: 1)
|
47
48
|
else m[i.to_i][:doc] = doc end
|
48
49
|
end
|
49
50
|
end
|
@@ -206,6 +207,7 @@ module Metanorma
|
|
206
207
|
xml.parent.add_child(smart_render_xml(item[:doc], item[:ref][:code],
|
207
208
|
item[:ref]))
|
208
209
|
use_my_anchor(xml, item[:ref][:match][:anchor],
|
210
|
+
amend: item.dig(:ref, :analyse_code, :amend),
|
209
211
|
hidden: item.dig(:ref, :analyse_code, :hidden),
|
210
212
|
dropid: item.dig(:ref, :analyse_code, :dropid))
|
211
213
|
end
|
@@ -32,11 +32,12 @@ module Metanorma
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def use_my_anchor(ref, id, opt)
|
35
|
-
ref.parent.elements.last
|
36
|
-
|
37
|
-
|
38
|
-
a = opt[:
|
39
|
-
|
35
|
+
elem = ref.parent.elements.last
|
36
|
+
elem["anchor"] = id
|
37
|
+
add_id(elem)
|
38
|
+
a = opt[:hidden] and elem["hidden"] = a
|
39
|
+
a = opt[:amend] and elem["amend"] = a
|
40
|
+
a = opt[:dropid] and elem["suppress_identifier"] = a
|
40
41
|
ref
|
41
42
|
end
|
42
43
|
|
@@ -66,40 +67,20 @@ module Metanorma
|
|
66
67
|
.sub(/^hidden\((.+)\)$/, "\\1")
|
67
68
|
.sub(/^nofetch\((.+)\)$/, "\\1")
|
68
69
|
.sub(/^local-file\((.+)\)$/, "\\1")
|
69
|
-
|
70
|
-
|
71
|
-
def analyse_ref_localfile(ret)
|
72
|
-
m = /^local-file\((?:(?<source>[^,)]+),\s*)?(?<id>[^)]+)\)$/
|
73
|
-
.match(ret[:id])
|
74
|
-
m or return ret
|
75
|
-
ret.merge(id: m[:id], localfile: m[:source] || "default")
|
76
|
-
end
|
77
|
-
|
78
|
-
def analyse_ref_nofetch(ret)
|
79
|
-
m = /^nofetch\((?<id>.+)\)$/.match(ret[:id]) or return ret
|
80
|
-
ret.merge(id: m[:id], nofetch: true)
|
81
|
-
end
|
82
|
-
|
83
|
-
def analyse_ref_hidden(ret)
|
84
|
-
m = /^hidden\((?<id>.+)\)$/.match(ret[:id]) or return ret
|
85
|
-
ret.merge(id: m[:id], hidden: true)
|
86
|
-
end
|
87
|
-
|
88
|
-
def analyse_ref_dropid(ret)
|
89
|
-
m = /^dropid\((?<id>.+)\)$/.match(ret[:id]) or return ret
|
90
|
-
ret.merge(id: m[:id], dropid: true)
|
70
|
+
.sub(/^amend\((.+)\)$/, "\\1")
|
91
71
|
end
|
92
72
|
|
93
73
|
def analyse_ref_repo_path(ret)
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
end
|
101
|
-
|
102
|
-
|
74
|
+
%i(repo path attachment).each do |type|
|
75
|
+
ret[type] or next
|
76
|
+
id = if ret[:id].empty?
|
77
|
+
if type == :attachment then "(#{ret[type]})"
|
78
|
+
else ret[type].sub(%r{^[^/]+/}, "")
|
79
|
+
end
|
80
|
+
else ret[:id] end
|
81
|
+
ret.merge!(id: id, type: type.to_s, key: ret[type], nofetch: true)
|
82
|
+
end
|
83
|
+
ret
|
103
84
|
end
|
104
85
|
|
105
86
|
def analyse_ref_numeric(ret)
|
@@ -107,16 +88,6 @@ module Metanorma
|
|
107
88
|
ret.merge(numeric: true)
|
108
89
|
end
|
109
90
|
|
110
|
-
def analyse_ref_dual(ret)
|
111
|
-
m = /^(?<type>merge|dual)\((?<keys>.+)\)$/.match(ret[:id]) or
|
112
|
-
return ret
|
113
|
-
line = CSV.parse_line(m[:keys], liberal_parsing: true) or return ret
|
114
|
-
line.size > 1 or return ret
|
115
|
-
ret[:id] = line.first
|
116
|
-
ret[m[:type].to_sym] = line[1..].map(&:strip)
|
117
|
-
ret
|
118
|
-
end
|
119
|
-
|
120
91
|
def analyse_ref_code(code)
|
121
92
|
ret = { id: code }
|
122
93
|
code.nil? || code.empty? and return ret
|
@@ -166,23 +137,49 @@ module Metanorma
|
|
166
137
|
end
|
167
138
|
end
|
168
139
|
|
140
|
+
def analyse_ref_code_nested(ret)
|
141
|
+
opts, id = parse_ref_code_nested({}, ret[:id])
|
142
|
+
ret[:id] = id
|
143
|
+
ret.merge!(opts)
|
144
|
+
analyse_ref_numeric(ret)
|
145
|
+
analyse_ref_repo_path(ret)
|
146
|
+
ret
|
147
|
+
end
|
148
|
+
|
169
149
|
# ref id = (usrlbl)code[:-]year
|
170
150
|
# code = \[? number \]? | ident | nofetch(code) | hidden(code) |
|
171
|
-
# dropid(code) |
|
151
|
+
# dropid(code) | amend(code) | (repo|path|attachment):(key,code) |
|
172
152
|
# local-file(source,? key) |
|
173
153
|
# merge(code, code) | dual(code, code)
|
174
|
-
def
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
154
|
+
def parse_ref_code_nested(ret, ident)
|
155
|
+
keys = %w(nofetch hidden dropid local-file repo path attachment merge
|
156
|
+
dual amend)
|
157
|
+
if (m = /^(?<key>[a-z-]+):?\((?<val>.*)\)$/.match(ident)) &&
|
158
|
+
keys.include?(m[:key])
|
159
|
+
case m[:key]
|
160
|
+
when "nofetch", "hidden", "dropid", "amend"
|
161
|
+
ret[m[:key].to_sym] = true
|
162
|
+
parse_ref_code_nested(ret, m[:val])
|
163
|
+
when "repo", "path", "attachment"
|
164
|
+
kv = m[:val].split(",", 2).map(&:strip)
|
165
|
+
ret[m[:key].to_sym] = kv[0]
|
166
|
+
parse_ref_code_nested(ret, kv.size == 1 ? "" : kv[1])
|
167
|
+
when "local-file"
|
168
|
+
kv = m[:val].split(",", 2).map(&:strip)
|
169
|
+
source = kv.size == 1 ? "default" : kv[0]
|
170
|
+
ret[:localfile] = source
|
171
|
+
parse_ref_code_nested(ret, kv[-1])
|
172
|
+
when "merge", "dual"
|
173
|
+
line = CSV.parse_line(m[:val],
|
174
|
+
liberal_parsing: true) or return [ret, ident]
|
175
|
+
line.size > 1 or return [ret, ident]
|
176
|
+
ret[:id] = line.first
|
177
|
+
ret[m[:key].to_sym] = line[1..].map(&:strip)
|
178
|
+
[ret, ret[:id]]
|
179
|
+
end
|
180
|
+
|
181
|
+
else [ret, ident]
|
182
|
+
end
|
186
183
|
end
|
187
184
|
|
188
185
|
# if no year is supplied, interpret as no_year reference
|
@@ -12,7 +12,7 @@ module Metanorma
|
|
12
12
|
scope: node.attr("scope"),
|
13
13
|
htmlstylesheet: node.attr("htmlstylesheet") || node.attr("html-stylesheet"),
|
14
14
|
htmlstylesheet_override: node.attr("htmlstylesheet-override") || node.attr("html-stylesheet-override"),
|
15
|
-
htmlcoverpage: node.attr("htmlcoverpage") || node.attr("
|
15
|
+
htmlcoverpage: node.attr("htmlcoverpage") || node.attr("html-coverpage"),
|
16
16
|
htmlintropage: node.attr("htmlintropage") || node.attr("html-intropage"),
|
17
17
|
scripts: node.attr("scripts"),
|
18
18
|
scripts_override: node.attr("scripts-override"),
|
@@ -58,7 +58,7 @@ module Metanorma
|
|
58
58
|
end
|
59
59
|
|
60
60
|
def spans_to_bibitem_host(spans)
|
61
|
-
spans[:in].empty? and return ""
|
61
|
+
spans[:in].nil? || spans[:in].empty? and return ""
|
62
62
|
ret =
|
63
63
|
"<relation type='includedIn'><bibitem type='#{spans[:in][:type]}'>"
|
64
64
|
spans[:in].delete(:type)
|
@@ -67,9 +67,9 @@ module Metanorma
|
|
67
67
|
|
68
68
|
def spans_to_bibitem_docid(spans)
|
69
69
|
ret = ""
|
70
|
-
spans[:uri]
|
71
|
-
spans[:docid]
|
72
|
-
spans[:date]
|
70
|
+
spans[:uri]&.each { |s| ret += span_to_docid(s, "uri") }
|
71
|
+
spans[:docid]&.each { |s| ret += span_to_docid(s, "docidentifier") }
|
72
|
+
spans[:date]&.each { |s| ret += span_to_date(s) }
|
73
73
|
ret
|
74
74
|
end
|
75
75
|
|
@@ -84,6 +84,7 @@ module Metanorma
|
|
84
84
|
end
|
85
85
|
|
86
86
|
def spans_to_bibitem_extent(spans)
|
87
|
+
spans.nil? and return ""
|
87
88
|
ret = ""
|
88
89
|
{ volume: "volume", issue: "issue", pages: "page" }.each do |k, v|
|
89
90
|
spans[k]&.each { |s| ret += span_to_extent(s, v) }
|
@@ -120,7 +121,7 @@ module Metanorma
|
|
120
121
|
|
121
122
|
def spans_to_contribs(spans)
|
122
123
|
ret = ""
|
123
|
-
spans[:contrib]
|
124
|
+
spans[:contrib]&.each do |s|
|
124
125
|
ret += span_to_contrib(s, spans[:title])
|
125
126
|
end
|
126
127
|
ret
|
@@ -87,8 +87,10 @@ module Metanorma
|
|
87
87
|
conv = presentation_xml_converter(EmptyAttr.new)
|
88
88
|
i18n = conv.i18n_init(lang, script, locale, i18nyaml)
|
89
89
|
conv.metadata_init(lang, script, locale, i18n)
|
90
|
+
conv.meta.localdir = @localdir
|
90
91
|
conv.xref_init(lang, script, nil, i18n, {})
|
91
92
|
conv.xrefs.klass.meta = conv.meta
|
93
|
+
conv.xrefs.klass.localdir = @localdir
|
92
94
|
conv
|
93
95
|
end
|
94
96
|
|
@@ -178,11 +180,6 @@ module Metanorma
|
|
178
180
|
@refids.include? ref
|
179
181
|
end
|
180
182
|
|
181
|
-
def uuid?(ref)
|
182
|
-
/^_[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/
|
183
|
-
.match?(ref)
|
184
|
-
end
|
185
|
-
|
186
183
|
module_function :adoc2xml
|
187
184
|
|
188
185
|
class EmptyAttr
|
data/metanorma-standoc.gemspec
CHANGED
@@ -57,6 +57,6 @@ Gem::Specification.new do |spec|
|
|
57
57
|
spec.add_development_dependency "timecop", "~> 0.9"
|
58
58
|
spec.add_development_dependency "vcr", "~> 6.1.0"
|
59
59
|
spec.add_development_dependency "webmock"
|
60
|
-
spec.add_development_dependency "
|
60
|
+
spec.add_development_dependency "canon"
|
61
61
|
# spec.metadata["rubygems_mfa_required"] = "true"
|
62
62
|
end
|
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: 3.1.
|
4
|
+
version: 3.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-08-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -389,7 +389,7 @@ dependencies:
|
|
389
389
|
- !ruby/object:Gem::Version
|
390
390
|
version: '0'
|
391
391
|
- !ruby/object:Gem::Dependency
|
392
|
-
name:
|
392
|
+
name: canon
|
393
393
|
requirement: !ruby/object:Gem::Requirement
|
394
394
|
requirements:
|
395
395
|
- - ">="
|