metanorma-standoc 3.1.0 → 3.1.2
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/basicdoc.rng +5 -5
- data/lib/metanorma/standoc/blocks_notes.rb +11 -14
- data/lib/metanorma/standoc/cleanup.rb +26 -18
- data/lib/metanorma/standoc/cleanup_block.rb +4 -4
- 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_review.rb +2 -2
- data/lib/metanorma/standoc/cleanup_section_names.rb +15 -22
- data/lib/metanorma/standoc/cleanup_terms_designations.rb +1 -1
- data/lib/metanorma/standoc/cleanup_text.rb +5 -12
- data/lib/metanorma/standoc/cleanup_xref.rb +1 -2
- data/lib/metanorma/standoc/converter.rb +1 -1
- data/lib/metanorma/standoc/front_organisation.rb +1 -1
- data/lib/metanorma/standoc/inline.rb +20 -9
- data/lib/metanorma/standoc/isodoc.rng +57 -6
- data/lib/metanorma/standoc/lists.rb +2 -1
- data/lib/metanorma/standoc/macros.rb +7 -4
- data/lib/metanorma/standoc/macros_inline.rb +4 -4
- data/lib/metanorma/standoc/macros_note.rb +2 -0
- data/lib/metanorma/standoc/render.rb +1 -1
- data/lib/metanorma/standoc/spans_to_bibitem.rb +6 -5
- data/lib/metanorma/standoc/table.rb +2 -0
- data/lib/metanorma/standoc/utils.rb +0 -5
- data/lib/metanorma/standoc/validate_section.rb +1 -1
- data/lib/metanorma/standoc/version.rb +1 -1
- data/metanorma-standoc.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe69b54cc4d7ab2744446c02c80d3e4bcfd5af8b098ab4f709f71269bfeed28e
|
4
|
+
data.tar.gz: d16ff11d49036801eb8d7a14b277d6d57b6079435682f4b4a07bf5b0140702d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6f68dceb7b3ab96e34b1b09f91b616b2b53e627ee6383cab0246ca1d429b975dee17f90118bae28a60ece153310c0fb78697c1ea863731c965d556b81fcab0f
|
7
|
+
data.tar.gz: 2613d30ba2e9bef9812787c5fc247205ca2c14929e5f50ba83138049c9cae7c1f0835bcc104127016516db61dc1477c911fb55f8161b9271c18251290f5684e2
|
@@ -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>
|
@@ -14,36 +14,33 @@ module Metanorma
|
|
14
14
|
.merge(type: node.attr("type"))))
|
15
15
|
end
|
16
16
|
|
17
|
-
def sidebar_attrs(node)
|
18
|
-
todo_attrs(node).merge(
|
19
|
-
attr_code(
|
20
|
-
from: node.attr("from"),
|
21
|
-
to: node.attr("to") || node.attr("from"),
|
22
|
-
type: node.attr("type") || nil,
|
23
|
-
),
|
24
|
-
)
|
25
|
-
end
|
26
|
-
|
27
17
|
def sidebar(node)
|
28
18
|
noko do |xml|
|
29
|
-
xml.
|
19
|
+
xml.annotation **sidebar_attrs(node) do |r|
|
30
20
|
wrap_in_para(node, r)
|
31
21
|
end
|
32
22
|
end
|
33
23
|
end
|
34
24
|
|
35
|
-
def
|
25
|
+
def sidebar_attrs(node)
|
36
26
|
date = node.attr("date") || Date.today.iso8601.gsub(/\+.*$/, "")
|
37
27
|
date += "T00:00:00Z" unless date.include?("T")
|
38
28
|
attr_code(id_attr(node)
|
39
29
|
.merge(reviewer: node.attr("reviewer") || node.attr("source") ||
|
40
30
|
"(Unknown)",
|
41
|
-
|
31
|
+
from: node.attr("from"),
|
32
|
+
to: node.attr("to") || node.attr("from"),
|
33
|
+
type: node.attr("type") || "review",
|
34
|
+
date:))
|
35
|
+
end
|
36
|
+
|
37
|
+
def todo_attrs(node)
|
38
|
+
sidebar_attrs(node).merge(type: "todo")
|
42
39
|
end
|
43
40
|
|
44
41
|
def todo(node)
|
45
42
|
noko do |xml|
|
46
|
-
xml.
|
43
|
+
xml.annotation **todo_attrs(node) do |r|
|
47
44
|
wrap_in_para(node, r)
|
48
45
|
end
|
49
46
|
end
|
@@ -160,33 +160,41 @@ module Metanorma
|
|
160
160
|
|
161
161
|
def variant_cleanup(xmldoc)
|
162
162
|
variant_space_cleanup(xmldoc)
|
163
|
-
xmldoc.xpath("//*[variant]").each do |c|
|
164
|
-
|
165
|
-
|
163
|
+
xmldoc.xpath("//*[lang-variant]").each do |c|
|
164
|
+
if only_langvariant_children?(c)
|
165
|
+
duplicate_langvariants(c, c.xpath("./lang-variant"))
|
166
|
+
else
|
167
|
+
c.xpath(".//lang-variant").each { |x| x.name = "span" }
|
166
168
|
end
|
169
|
+
end
|
170
|
+
end
|
167
171
|
|
168
|
-
|
172
|
+
def only_langvariant_children?(node)
|
173
|
+
node.children.none? do |n|
|
174
|
+
n.name != "lang-variant" && (!n.text? || !n.text.strip.empty?)
|
169
175
|
end
|
170
|
-
xmldoc.xpath("//variantwrap").each { |n| n.name = "variant" }
|
171
176
|
end
|
172
177
|
|
173
|
-
def
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
else
|
180
|
-
n.replace("<variantwrap/>").first << n
|
181
|
-
end
|
178
|
+
def duplicate_langvariants(container, variants)
|
179
|
+
lang_variant_to_node(variants.first, container)
|
180
|
+
variants[1..].reverse.each do |node|
|
181
|
+
new = container.dup
|
182
|
+
lang_variant_to_node(node, new)
|
183
|
+
container.next = new
|
182
184
|
end
|
183
185
|
end
|
184
186
|
|
185
|
-
def
|
186
|
-
|
187
|
-
|
187
|
+
def lang_variant_to_node(variant, node)
|
188
|
+
node.children = variant.children
|
189
|
+
node["lang"] = variant["lang"]
|
190
|
+
node.delete("script")
|
191
|
+
variant["script"] and node["script"] = variant["script"]
|
192
|
+
end
|
188
193
|
|
189
|
-
|
194
|
+
def variant_space_cleanup(xmldoc)
|
195
|
+
xmldoc.xpath("//*[lang-variant]").each do |c|
|
196
|
+
c.next.nil? || c.next.next.nil? and next
|
197
|
+
if c.next.text? && c.next.next.name == "lang-variant"
|
190
198
|
c.next.text.gsub(/\s/, "").empty? and
|
191
199
|
c.next.remove
|
192
200
|
end
|
@@ -121,7 +121,7 @@ module Metanorma
|
|
121
121
|
def align_callouts_to_annotations(xmldoc)
|
122
122
|
xmldoc.xpath("//sourcecode").each do |x|
|
123
123
|
callouts = x.xpath("./body/callout")
|
124
|
-
annotations = x.xpath("./annotation")
|
124
|
+
annotations = x.xpath("./callout-annotation")
|
125
125
|
callouts.size == annotations.size and
|
126
126
|
link_callouts_to_annotations(callouts, annotations)
|
127
127
|
end
|
@@ -129,7 +129,7 @@ module Metanorma
|
|
129
129
|
|
130
130
|
def merge_annotations_into_sourcecode(xmldoc)
|
131
131
|
xmldoc.xpath("//sourcecode").each do |x|
|
132
|
-
while x.next_element&.name == "annotation"
|
132
|
+
while x.next_element&.name == "callout-annotation"
|
133
133
|
x.next_element.parent = x
|
134
134
|
end
|
135
135
|
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"
|
@@ -2,9 +2,9 @@ module Metanorma
|
|
2
2
|
module Standoc
|
3
3
|
module Cleanup
|
4
4
|
def review_cleanup(xmldoc)
|
5
|
-
reviews = xmldoc.xpath("//
|
5
|
+
reviews = xmldoc.xpath("//annotation")
|
6
6
|
reviews.empty? and return
|
7
|
-
ctr = xmldoc.root.add_child("<
|
7
|
+
ctr = xmldoc.root.add_child("<annotation-container/>").first
|
8
8
|
reviews.each do |r|
|
9
9
|
review_set_location(r)
|
10
10
|
ctr << r
|
@@ -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
|
@@ -123,28 +117,28 @@ module Metanorma
|
|
123
117
|
end
|
124
118
|
end
|
125
119
|
|
126
|
-
def terms_subclause_type_tally(node,
|
127
|
-
|
128
|
-
|
129
|
-
|
120
|
+
def terms_subclause_type_tally(node, acc, parent)
|
121
|
+
hasterm = node.at(".//term")
|
122
|
+
sym = if (hasterm && !node.at(".//definitions")) ||
|
123
|
+
(node.name == "terms" && !hasterm)
|
124
|
+
unless acc[:parent] == :term # don't count Term > Term twice
|
130
125
|
:term
|
131
126
|
end
|
132
|
-
elsif
|
133
|
-
elsif
|
134
|
-
elsif
|
135
|
-
elsif
|
127
|
+
elsif hasterm && node.at("./self::*#{SYMnoABBR}") then :tsna
|
128
|
+
elsif hasterm && node.at("./self::*#{ABBRnoSYM}") then :tans
|
129
|
+
elsif hasterm && node.at("./self::*#{SYMABBR}") then :tsa
|
130
|
+
elsif hasterm && node.at("./self::*#{NO_SYMABBR}") then :tnsa
|
136
131
|
elsif node.at("./self::*#{SYMnoABBR}") then :sna
|
137
132
|
elsif node.at("./self::*#{ABBRnoSYM}") then :ans
|
138
133
|
elsif node.at("./self::*#{SYMABBR}") then :sa
|
139
134
|
elsif node.at("./self::*#{NO_SYMABBR}") then :nsa
|
140
135
|
elsif node.name == "definitions" # ignore
|
141
|
-
elsif node == parent && node.at(".//
|
142
|
-
node.at(".//definitions")
|
136
|
+
elsif node == parent && hasterm && node.at(".//definitions")
|
143
137
|
:termdef
|
144
138
|
else :other
|
145
139
|
end
|
146
|
-
node == parent and
|
147
|
-
sym and
|
140
|
+
node == parent and acc[:parent] = sym
|
141
|
+
sym and acc[sym] += 1
|
148
142
|
end
|
149
143
|
|
150
144
|
def sections_variant_title_cleanup(xml)
|
@@ -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)
|
@@ -107,7 +101,7 @@ module Metanorma
|
|
107
101
|
%w(pre sourcecode passthrough metanorma-extension stem).freeze
|
108
102
|
|
109
103
|
STRIP_LINEBREAK_ELEMENTS =
|
110
|
-
%w(title name variant-title figure example
|
104
|
+
%w(title name variant-title figure example annotation admonition
|
111
105
|
note li th td dt dd p quote label annotation
|
112
106
|
preferred admitted related deprecates field-of-application
|
113
107
|
usage-info expression pronunciation grammar-value domain
|
@@ -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
|
@@ -146,8 +139,8 @@ module Metanorma
|
|
146
139
|
quote label abstract preferred admitted related deprecates
|
147
140
|
field-of-application usage-info expression pronunciation
|
148
141
|
grammar-value domain definition termnote termexample modification
|
149
|
-
description newcontent floating-title tab
|
150
|
-
annotation).include? elem.name
|
142
|
+
description newcontent floating-title tab annotation admonition
|
143
|
+
callout-annotation).include? elem.name
|
151
144
|
end
|
152
145
|
|
153
146
|
def empty_tag_with_text_content?(elem)
|
@@ -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
|
@@ -56,7 +56,7 @@ module Metanorma
|
|
56
56
|
inline_macro Metanorma::Standoc::IdentifierInlineMacro
|
57
57
|
inline_macro Metanorma::Standoc::ConceptInlineMacro
|
58
58
|
inline_macro Metanorma::Standoc::AutonumberInlineMacro
|
59
|
-
inline_macro Metanorma::Standoc::
|
59
|
+
inline_macro Metanorma::Standoc::LangVariantInlineMacro
|
60
60
|
inline_macro Metanorma::Standoc::FootnoteBlockInlineMacro
|
61
61
|
inline_macro Metanorma::Standoc::TermRefInlineMacro
|
62
62
|
inline_macro Metanorma::Standoc::SymbolRefInlineMacro
|
@@ -134,29 +134,40 @@ module Metanorma
|
|
134
134
|
end
|
135
135
|
end
|
136
136
|
|
137
|
+
def image_mimetype(uri)
|
138
|
+
types = if /^data:/.match?(uri) then Vectory::Utils::datauri2mime(uri)
|
139
|
+
else MIME::Types.type_for(uri)
|
140
|
+
end
|
141
|
+
types.first.to_s
|
142
|
+
end
|
143
|
+
|
137
144
|
def image_attributes(node)
|
145
|
+
sourceuri = image_src_uri(node)
|
146
|
+
uri = sourceuri
|
147
|
+
type = image_mimetype(uri)
|
148
|
+
uri = uri.sub(%r{^data:image/\*;}, "data:#{type};")
|
149
|
+
image_attributes1(node, uri, sourceuri, type)
|
150
|
+
end
|
151
|
+
|
152
|
+
def image_src_uri(node)
|
138
153
|
nodetarget = node.attr("target") || node.target
|
139
154
|
if Gem.win_platform? && /^[a-zA-Z]:/.match?(nodetarget)
|
140
155
|
nodetarget.prepend("/")
|
141
156
|
end
|
142
|
-
uri = node.image_uri
|
157
|
+
uri = node.image_uri(nodetarget)
|
143
158
|
if Gem.win_platform? && /^\/[a-zA-Z]:/.match?(uri)
|
144
159
|
uri = uri[1..]
|
145
160
|
end
|
146
|
-
|
147
|
-
else MIME::Types.type_for(uri)
|
148
|
-
end
|
149
|
-
type = types.first.to_s
|
150
|
-
uri = uri.sub(%r{^data:image/\*;}, "data:#{type};")
|
151
|
-
image_attributes1(node, uri, type)
|
161
|
+
uri
|
152
162
|
end
|
153
163
|
|
154
|
-
def image_attributes1(node, uri, type)
|
164
|
+
def image_attributes1(node, uri, sourceuri, type)
|
165
|
+
/^data:/.match?(sourceuri) and sourceuri = nil
|
155
166
|
attr_code(id_attr(node)
|
156
167
|
.merge(src: uri, mimetype: type,
|
157
168
|
height: node.attr("height") || "auto",
|
158
169
|
width: node.attr("width") || "auto",
|
159
|
-
filename: node.attr("filename"),
|
170
|
+
filename: node.attr("filename") || sourceuri,
|
160
171
|
title: node.attr("titleattr"),
|
161
172
|
alt: node.alt == node.attr("default-alt") ? nil : node.alt))
|
162
173
|
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.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
|
@@ -72,6 +72,46 @@ but to `@anchor`, the user-supplied cross-reference</a:documentation>
|
|
72
72
|
</oneOrMore>
|
73
73
|
</element>
|
74
74
|
</define>
|
75
|
+
<define name="review">
|
76
|
+
<a:documentation>Generalise BasicDoc element from just review comments, to general annotations;
|
77
|
+
the type attribute defaults to `review` for reviews</a:documentation>
|
78
|
+
<element name="annotation">
|
79
|
+
<ref name="RequiredId"/>
|
80
|
+
<ref name="ReviewAttributes"/>
|
81
|
+
<oneOrMore>
|
82
|
+
<ref name="paragraph">
|
83
|
+
<a:documentation>Reviewer comments content</a:documentation>
|
84
|
+
</ref>
|
85
|
+
</oneOrMore>
|
86
|
+
</element>
|
87
|
+
</define>
|
88
|
+
<define name="ruby_pronunciation">
|
89
|
+
<a:documentation>Ruby annotation giving pronunciation of text: change tag from BasicDoc for disambiguation</a:documentation>
|
90
|
+
<element name="ruby-pronunciation">
|
91
|
+
<attribute name="value">
|
92
|
+
<a:documentation>Ruby annotation value</a:documentation>
|
93
|
+
</attribute>
|
94
|
+
<ref name="LocalizedStringAttributes"/>
|
95
|
+
</element>
|
96
|
+
</define>
|
97
|
+
<define name="ruby_annotation">
|
98
|
+
<a:documentation>Ruby annotation giving information other than pronunciation of text: change tag from BasicDoc for disambiguation</a:documentation>
|
99
|
+
<element name="ruby-annotation">
|
100
|
+
<attribute name="value">
|
101
|
+
<a:documentation>Ruby annotation value</a:documentation>
|
102
|
+
</attribute>
|
103
|
+
<ref name="LocalizedStringAttributes"/>
|
104
|
+
</element>
|
105
|
+
</define>
|
106
|
+
<define name="annotation">
|
107
|
+
<a:documentation>Source code annotation, corresponding to a callout</a:documentation>
|
108
|
+
<element name="callout-annotation">
|
109
|
+
<ref name="RequiredId"/>
|
110
|
+
<oneOrMore>
|
111
|
+
<ref name="paragraph"/>
|
112
|
+
</oneOrMore>
|
113
|
+
</element>
|
114
|
+
</define>
|
75
115
|
<define name="section-title">
|
76
116
|
<a:documentation>Title(s) of a clause</a:documentation>
|
77
117
|
<element name="title">
|
@@ -540,7 +580,7 @@ normative or informative references, some split references into sections organiz
|
|
540
580
|
<ref name="OptionalId"/>
|
541
581
|
<optional>
|
542
582
|
<attribute name="style">
|
543
|
-
<a:documentation>CSS style: only background-color supported</a:documentation>
|
583
|
+
<a:documentation>CSS style: only background-color, color, border supported</a:documentation>
|
544
584
|
</attribute>
|
545
585
|
</optional>
|
546
586
|
</define>
|
@@ -620,7 +660,7 @@ This is done if the footnote reference is already presented in some other form,
|
|
620
660
|
<ref name="RequiredId"/>
|
621
661
|
<optional>
|
622
662
|
<attribute name="style">
|
623
|
-
<a:documentation>CSS style: only background-color supported</a:documentation>
|
663
|
+
<a:documentation>CSS style: only background-color, color, border supported</a:documentation>
|
624
664
|
</attribute>
|
625
665
|
</optional>
|
626
666
|
</define>
|
@@ -695,11 +735,22 @@ titlecase, or lowercase</a:documentation>
|
|
695
735
|
<ref name="BlockAttributes"/>
|
696
736
|
</define>
|
697
737
|
<define name="TableAttributes" combine="interleave">
|
738
|
+
<optional>
|
739
|
+
<attribute name="plain">
|
740
|
+
<a:documentation>Render as a plain attribute, with no shading or borders</a:documentation>
|
741
|
+
<data type="boolean"/>
|
742
|
+
</attribute>
|
743
|
+
</optional>
|
698
744
|
<optional>
|
699
745
|
<attribute name="width">
|
700
746
|
<a:documentation>Width of the table block in rendering</a:documentation>
|
701
747
|
</attribute>
|
702
748
|
</optional>
|
749
|
+
<optional>
|
750
|
+
<attribute name="style">
|
751
|
+
<a:documentation>CSS style: only background-color, color, border supported</a:documentation>
|
752
|
+
</attribute>
|
753
|
+
</optional>
|
703
754
|
<ref name="BlockAttributes"/>
|
704
755
|
</define>
|
705
756
|
<define name="FigureAttributes" combine="interleave">
|
@@ -1417,7 +1468,7 @@ numbers</a:documentation>
|
|
1417
1468
|
</optional>
|
1418
1469
|
<ref name="DocumentBody"/>
|
1419
1470
|
<optional>
|
1420
|
-
<ref name="
|
1471
|
+
<ref name="annotation-container">
|
1421
1472
|
<a:documentation>Annotations to the document</a:documentation>
|
1422
1473
|
</ref>
|
1423
1474
|
</optional>
|
@@ -1461,8 +1512,8 @@ numbers</a:documentation>
|
|
1461
1512
|
</oneOrMore>
|
1462
1513
|
</element>
|
1463
1514
|
</define>
|
1464
|
-
<define name="
|
1465
|
-
<element name="
|
1515
|
+
<define name="annotation-container">
|
1516
|
+
<element name="annotation-container">
|
1466
1517
|
<oneOrMore>
|
1467
1518
|
<ref name="review"/>
|
1468
1519
|
</oneOrMore>
|
@@ -59,6 +59,7 @@ module Metanorma
|
|
59
59
|
def ol_attrs(node)
|
60
60
|
attr_code(id_attr(node).merge(keep_attrs(node)
|
61
61
|
.merge(type: olist_style(node.style),
|
62
|
+
start: node.attr("start"),
|
62
63
|
"explicit-type": olist_style(node.attributes[1]))))
|
63
64
|
end
|
64
65
|
|
@@ -114,7 +115,7 @@ module Metanorma
|
|
114
115
|
def colist(node)
|
115
116
|
noko do |xml|
|
116
117
|
node.items.each_with_index do |item, i|
|
117
|
-
xml.
|
118
|
+
xml.callout_annotation **attr_code(id: i + 1) do |xml_li|
|
118
119
|
xml_li.p { |p| p << item.text }
|
119
120
|
end
|
120
121
|
end
|
@@ -221,14 +221,17 @@ module Metanorma
|
|
221
221
|
# pass:[A] => pass-format:metanorma[++A++],
|
222
222
|
# so long as A doesn't already start with ++
|
223
223
|
# ditto pass-format:[A] => pass-format:[++A++]
|
224
|
+
# convert any \] in the ++...++ body to ]
|
224
225
|
def pass_convert(text)
|
225
226
|
text
|
226
|
-
.gsub(/pass-format:([^\[ ]*)\[(?!\+\+)(.+?)(?<!\\)\]
|
227
|
-
|
227
|
+
.gsub(/pass-format:([^\[ ]*)\[(?!\+\+)(.+?)(?<!\\)\]/) do |_m|
|
228
|
+
"pass-format:#{$1}[++#{$2.gsub(/\\\]/, ']')}++]"
|
229
|
+
end
|
228
230
|
.gsub(/pass:\[(?=\+\+)(.+?)(?<!\\)\]/,
|
229
231
|
"pass-format:metanorma[\\1]")
|
230
|
-
.gsub(/pass:\[(?!\+\+)(.+?)(?<!\\)\]
|
231
|
-
|
232
|
+
.gsub(/pass:\[(?!\+\+)(.+?)(?<!\\)\]/) do |_m|
|
233
|
+
"pass-format:metanorma[++#{$1.gsub(/\\\]/, ']')}++]"
|
234
|
+
end
|
232
235
|
end
|
233
236
|
|
234
237
|
def inlinelink(text)
|
@@ -43,7 +43,7 @@ module Metanorma
|
|
43
43
|
attrs = " value='#{target}'"
|
44
44
|
x = args[:lang] and attrs += " lang='#{x}'"
|
45
45
|
x = args[:script] and attrs += " script='#{x}'"
|
46
|
-
"<ruby
|
46
|
+
"<ruby><ruby-#{args[:type]} #{attrs}/>#{out}</ruby>"
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
@@ -82,7 +82,7 @@ module Metanorma
|
|
82
82
|
end
|
83
83
|
end
|
84
84
|
|
85
|
-
class
|
85
|
+
class LangVariantInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
86
86
|
use_dsl
|
87
87
|
named :lang
|
88
88
|
parse_content_as :text
|
@@ -91,9 +91,9 @@ module Metanorma
|
|
91
91
|
/^(?<lang>[^-]*)(?:-(?<script>.*))?$/ =~ target
|
92
92
|
out = Asciidoctor::Inline.new(parent, :quoted, attrs["text"]).convert
|
93
93
|
if script
|
94
|
-
%{<variant lang='#{lang}' script='#{script}'>#{out}</variant>}
|
94
|
+
%{<lang-variant lang='#{lang}' script='#{script}'>#{out}</lang-variant>}
|
95
95
|
else
|
96
|
-
%{<variant lang='#{lang}'>#{out}</variant>}
|
96
|
+
%{<lang-variant lang='#{lang}'>#{out}</lang-variant>}
|
97
97
|
end
|
98
98
|
end
|
99
99
|
end
|
@@ -8,6 +8,7 @@ module Metanorma
|
|
8
8
|
def process(parent, reader, attrs)
|
9
9
|
attrs["name"] = "todo"
|
10
10
|
attrs["caption"] = "TODO"
|
11
|
+
# these will be converted from admonition to annotation downstream
|
11
12
|
create_block(parent, :admonition, reader.lines, attrs,
|
12
13
|
content_model: :compound)
|
13
14
|
end
|
@@ -21,6 +22,7 @@ module Metanorma
|
|
21
22
|
para.set_attr("name", "todo")
|
22
23
|
para.set_attr("caption", "TODO")
|
23
24
|
para.lines[0].sub!(/^TODO: /, "")
|
25
|
+
# these will be converted from admonition to annotation downstream
|
24
26
|
para.context = :admonition
|
25
27
|
end
|
26
28
|
end
|
@@ -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
|
@@ -6,6 +6,8 @@ module Metanorma
|
|
6
6
|
.merge(id_unnum_attrs(node))
|
7
7
|
.merge(headerrows: node.attr("headerrows"),
|
8
8
|
alt: node.attr("alt"),
|
9
|
+
plain: node.option?("plain") ? "true" : nil,
|
10
|
+
style: node.attr("css-style"),
|
9
11
|
summary: node.attr("summary"),
|
10
12
|
width: node.attr("width"))
|
11
13
|
end
|
@@ -12,7 +12,7 @@ module Metanorma
|
|
12
12
|
def sourcecode_style(root)
|
13
13
|
root.xpath("//sourcecode").each do |x|
|
14
14
|
callouts = x.xpath("./body/callout")
|
15
|
-
annotations = x.xpath("./annotation")
|
15
|
+
annotations = x.xpath("./callout-annotation")
|
16
16
|
callouts_error(x, callouts, annotations)
|
17
17
|
end
|
18
18
|
end
|
data/metanorma-standoc.gemspec
CHANGED
@@ -32,7 +32,7 @@ Gem::Specification.new do |spec|
|
|
32
32
|
spec.add_dependency "asciidoctor", "~> 2.0.0"
|
33
33
|
spec.add_dependency "crass", "~> 1.0.0"
|
34
34
|
spec.add_dependency "iev", "~> 0.3.5"
|
35
|
-
spec.add_dependency "isodoc", "~> 3.
|
35
|
+
spec.add_dependency "isodoc", "~> 3.2.0"
|
36
36
|
spec.add_dependency "metanorma", ">= 1.6.0"
|
37
37
|
spec.add_dependency "metanorma-plugin-glossarist", "~> 0.2.3"
|
38
38
|
spec.add_dependency "metanorma-plugin-lutaml", "~> 0.7.31"
|
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.2
|
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-07-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 3.
|
75
|
+
version: 3.2.0
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 3.
|
82
|
+
version: 3.2.0
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: metanorma
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|