metanorma-standoc 3.1.1 → 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/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_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/isodoc.rng +7 -1
- 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 +0 -5
- data/lib/metanorma/standoc/version.rb +1 -1
- metadata +2 -2
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>
|
@@ -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,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
|
@@ -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
|
@@ -735,6 +735,12 @@ titlecase, or lowercase</a:documentation>
|
|
735
735
|
<ref name="BlockAttributes"/>
|
736
736
|
</define>
|
737
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>
|
738
744
|
<optional>
|
739
745
|
<attribute name="width">
|
740
746
|
<a:documentation>Width of the table block in rendering</a:documentation>
|
@@ -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
|
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-07-
|
11
|
+
date: 2025-07-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|