metanorma-standoc 3.0.5 → 3.0.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/blocks.rb +4 -3
- data/lib/metanorma/standoc/cleanup_maths.rb +1 -2
- data/lib/metanorma/standoc/cleanup_review.rb +35 -19
- data/lib/metanorma/standoc/lists.rb +1 -0
- data/lib/metanorma/standoc/regex.rb +1 -1
- data/lib/metanorma/standoc/utils.rb +11 -9
- 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: 982e6533abd03671b4c76ba32204915843cdc0c644b06ec0e8a34798a5d50d1d
|
4
|
+
data.tar.gz: c12cb3a77574fef2d8aa219dae15470ed14ee50e3d7ca55c527f54dc73242a4e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eec8efe148aeef9f65007f135aed6ad0a91c7c8c0a94749d75c1946d53e0877a3c8840c32679e20d01048fee434d35949453dcfd7335417f049f225eab31afdf
|
7
|
+
data.tar.gz: 8e2dc0a69568e2f460dcf39fa081756ed0d5610b00c02516c02ffd14bb84682a03dc07a29dc261651f65576175c36561d53a80cea8889c9519b8053c3051c612
|
@@ -211,12 +211,13 @@ module Metanorma
|
|
211
211
|
end
|
212
212
|
|
213
213
|
def pass(node)
|
214
|
+
format = node.attr("format") || "metanorma"
|
214
215
|
noko do |xml|
|
215
|
-
xml.passthrough **attr_code(formats:
|
216
|
-
node.attr("format") || "metanorma") do |p|
|
216
|
+
xml.passthrough **attr_code(formats: format) do |p|
|
217
217
|
content = @c.encode(node.content, :basic, :hexadecimal)
|
218
218
|
p << content
|
219
|
-
|
219
|
+
format == "metanorma" and
|
220
|
+
passthrough_validate(node, node.content, content)
|
220
221
|
end
|
221
222
|
end
|
222
223
|
end
|
@@ -166,8 +166,7 @@ module Metanorma
|
|
166
166
|
return
|
167
167
|
end
|
168
168
|
f == "default" or return f
|
169
|
-
if @numberfmt_default.empty?
|
170
|
-
"notation='basic'"
|
169
|
+
if @numberfmt_default.empty? then "notation='basic'"
|
171
170
|
else @numberfmt_default&.map { |k, v| "#{k}='#{v}'" }&.join(",")
|
172
171
|
end
|
173
172
|
end
|
@@ -15,36 +15,52 @@ module Metanorma
|
|
15
15
|
parent = review.parent
|
16
16
|
children = parent.children
|
17
17
|
index = children.index(review)
|
18
|
-
x =
|
19
|
-
|
20
|
-
ins =
|
21
|
-
else review.before("<p> </p>").previous.at(".//text()")
|
22
|
-
end
|
18
|
+
x = find_review_sibling(children, index, :previous) ||
|
19
|
+
find_review_sibling(children, index, :following)
|
20
|
+
ins = x || review.before("<p> </p>").previous.at(".//text()")
|
23
21
|
ins.previous = "<bookmark id='#{id}'/>"
|
24
22
|
end
|
25
23
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
24
|
+
# we know node is a block: dig for a place bookmark can go
|
25
|
+
def available_bookmark_destination(node)
|
26
|
+
ret = case node.name
|
27
|
+
when "title", "name", "p" then node
|
28
|
+
when "sourcecode" then node.at(".//name")
|
29
|
+
when "admonition", "note", "example", "li", "quote", "dt", "dd",
|
30
|
+
"permission", "requirement", "recommendation"
|
31
|
+
node.at(".//p | .//name") || node
|
32
|
+
when "formula"
|
33
|
+
node.at(".//p | .//name | .//dt")
|
34
|
+
when "ol", "ul" then node.at(".//p | .//name") || node.at("./li")
|
35
|
+
when "dl" then node.at(".//p | .//name") || node.at("./dt | ./dd")
|
36
|
+
when "table" then node.at(".//td[text()] | .//th[text()]")
|
37
|
+
end or return nil
|
38
|
+
first_non_stem_text(ret)
|
39
|
+
end
|
40
|
+
|
41
|
+
def first_non_stem_text(ret)
|
42
|
+
first_non_stem_text = nil
|
43
|
+
ret.traverse do |n|
|
44
|
+
if n.text? && n.ancestors("stem").empty? && !n.text.strip.empty?
|
45
|
+
first_non_stem_text = n
|
32
46
|
break
|
33
47
|
end
|
34
48
|
end
|
35
|
-
|
49
|
+
first_non_stem_text
|
36
50
|
end
|
37
51
|
|
38
|
-
def
|
39
|
-
|
40
|
-
|
52
|
+
def find_review_sibling(children, index, direction = :previous)
|
53
|
+
range = if direction == :previous then (index - 1).downto(0)
|
54
|
+
else (index + 1).upto(children.size - 1)
|
55
|
+
end
|
56
|
+
range.each do |i|
|
41
57
|
node = children[i]
|
42
|
-
if node.element? && node.
|
43
|
-
|
44
|
-
|
58
|
+
if node.element? && !node.text.empty? && node.text.strip != "" &&
|
59
|
+
ret = available_bookmark_destination(node)
|
60
|
+
return ret
|
45
61
|
end
|
46
62
|
end
|
47
|
-
|
63
|
+
nil
|
48
64
|
end
|
49
65
|
|
50
66
|
def review_set_location(review)
|
@@ -2,7 +2,7 @@ module Metanorma
|
|
2
2
|
module Standoc
|
3
3
|
module Regex
|
4
4
|
# https://medium.com/@rickwang_wxc/in-ruby-given-a-string-detect-if-it-is-valid-numeric-c58275eace60
|
5
|
-
NUMERIC_REGEX = %r{
|
5
|
+
NUMERIC_REGEX = %r{\A((\+|-)?\d*\.?\d+)([eE](\+|-){1}\d+)?\Z}
|
6
6
|
|
7
7
|
# extending localities to cover ISO referencing
|
8
8
|
CONN_REGEX_STR = "(?<conn>and|or|from|to)!".freeze
|
@@ -40,16 +40,18 @@ module Metanorma
|
|
40
40
|
.map { |x| @c.encode(x, :basic, :hexadecimal) }
|
41
41
|
end
|
42
42
|
|
43
|
+
# quoted strings: key="va,lue",
|
43
44
|
def quoted_csv_split(text, delim = ",", eql = "=")
|
44
|
-
# quoted strings: key="va,lue",
|
45
45
|
c = HTMLEntities.new
|
46
|
-
text = c.decode(text).gsub(/([a-zA-Z_]+)#{eql}(["'])(
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
46
|
+
text = c.decode(text).gsub(/([a-zA-Z_]+)#{eql}(["'])(.*?)\2/) do |_|
|
47
|
+
key = Regexp.last_match(1)
|
48
|
+
value = Regexp.last_match(3).gsub(" ", " ")
|
49
|
+
"\"#{key}#{eql}#{value}\""
|
50
|
+
end
|
51
|
+
Metanorma::Utils::csv_split(text, delim).map do |x|
|
52
|
+
c.encode(x.sub(/^(["'])(.*?)\1$/, "\\2"),
|
53
|
+
:basic, :hexadecimal)
|
54
|
+
end
|
53
55
|
end
|
54
56
|
|
55
57
|
def kv_parse(text, delim = ",", eql = "=")
|
@@ -118,7 +120,7 @@ module Metanorma
|
|
118
120
|
|
119
121
|
SECTION_CONTAINERS =
|
120
122
|
%w(foreword introduction acknowledgements abstract
|
121
|
-
clause references terms definitions annex appendix indexsect
|
123
|
+
clause references terms definitions annex appendix indexsect
|
122
124
|
executivesummary).freeze
|
123
125
|
|
124
126
|
def section_containers
|
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.0.
|
4
|
+
version: 3.0.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: 2025-04-
|
11
|
+
date: 2025-04-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|