metanorma-standoc 2.8.0 → 2.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/metanorma/standoc/anchor.rb +19 -10
- data/lib/metanorma/standoc/basicdoc.rng +3 -0
- data/lib/metanorma/standoc/blocks_notes.rb +10 -7
- data/lib/metanorma/standoc/cleanup.rb +1 -0
- data/lib/metanorma/standoc/cleanup_inline.rb +9 -4
- data/lib/metanorma/standoc/cleanup_terms.rb +0 -1
- data/lib/metanorma/standoc/isodoc.rng +4 -1
- data/lib/metanorma/standoc/section.rb +16 -18
- data/lib/metanorma/standoc/term_lookup_cleanup.rb +4 -3
- 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: 6a5e5f1a3e1674d8e9cc0b3cdc0979195595b187e972e498616b30955cbc4512
|
4
|
+
data.tar.gz: 81b45e23e6ece67cd6a6d8d6bd747c439264faca7ee26daf58b6cbdc42dcd93d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 33d2ba8ae3a9b5ed18bf30193c507bcc6da280054dcc5c6c22e0f87288e6d229fb2bbcc62175826918d2b25935f1b6fc84f7d68f64e925a438c1d20fe6845f77
|
7
|
+
data.tar.gz: acab296d523a22e518a64ef1d1109706bfe4e3b164366f237b09a42e804ac371bf3387cd40122ea1f9eb0e42f9fa86796140826fd0013b44417b9d792cc3751a
|
@@ -48,14 +48,14 @@ module Metanorma
|
|
48
48
|
{ target: target, hidden: match[:hidden],
|
49
49
|
type: match[:fn].nil? ? "inline" : "footnote",
|
50
50
|
case: match[:case]&.sub(/%$/, ""),
|
51
|
-
style: match[:style]
|
51
|
+
style: match[:style] || @xrefstyle,
|
52
52
|
droploc: match[:drop].nil? && match[:drop2].nil? ? nil : true,
|
53
53
|
text: inline_anchor_xref_text(match, text) }
|
54
54
|
end
|
55
55
|
|
56
56
|
def inline_anchor_xref_match(text)
|
57
57
|
/^(?:hidden%(?<hidden>[^,]+),?)?
|
58
|
-
(?<style>
|
58
|
+
(?:style=(?<style>[^%]+)%)?
|
59
59
|
(?<drop>droploc%)?(?<case>capital%|lowercase%)?(?<drop2>droploc%)?
|
60
60
|
(?<fn>fn:?\s*)?(?<text>.*)$/x.match text
|
61
61
|
end
|
@@ -68,11 +68,7 @@ module Metanorma
|
|
68
68
|
end
|
69
69
|
|
70
70
|
def inline_anchor_link(node)
|
71
|
-
contents = node
|
72
|
-
contents = "" if node.target.gsub(%r{^mailto:}, "") == node.text
|
73
|
-
attributes = { target: node.target, alt: node.attr("title"),
|
74
|
-
"update-type": node.attr("updatetype") ||
|
75
|
-
node.attr("update-type") }
|
71
|
+
contents, attributes = inline_anchor_link_attrs(node)
|
76
72
|
noko do |xml|
|
77
73
|
xml.link **attr_code(attributes) do |l|
|
78
74
|
l << contents
|
@@ -80,10 +76,18 @@ module Metanorma
|
|
80
76
|
end.join
|
81
77
|
end
|
82
78
|
|
79
|
+
def inline_anchor_link_attrs(node)
|
80
|
+
contents = node.text
|
81
|
+
contents = "" if node.target.gsub(%r{^mailto:}, "") == node.text
|
82
|
+
attributes = { target: node.target, alt: node.attr("title"),
|
83
|
+
style: node.attr("style")&.sub(/%$/, ""),
|
84
|
+
"update-type": node.attr("updatetype") ||
|
85
|
+
node.attr("update-type") }
|
86
|
+
[contents, attributes]
|
87
|
+
end
|
88
|
+
|
83
89
|
def inline_anchor_bibref(node)
|
84
|
-
eref_contents =
|
85
|
-
@c.decode(node.text || node.target || node.id)
|
86
|
-
&.sub(/^\[?([^\[\]]+?)\]?$/, "[\\1]")
|
90
|
+
eref_contents = inline_anchor_bibref_contents(node)
|
87
91
|
@refids << (node.target || node.id)
|
88
92
|
noko do |xml|
|
89
93
|
xml.ref **attr_code(id: node.target || node.id) do |r|
|
@@ -92,6 +96,11 @@ module Metanorma
|
|
92
96
|
end.join
|
93
97
|
end
|
94
98
|
|
99
|
+
def inline_anchor_bibref_contents(node)
|
100
|
+
@c.decode(node.text || node.target || node.id)
|
101
|
+
&.sub(/^\[?([^\[\]]+?)\]?$/, "[\\1]")
|
102
|
+
end
|
103
|
+
|
95
104
|
def inline_callout(node)
|
96
105
|
noko do |xml|
|
97
106
|
xml.callout node.text
|
@@ -22,13 +22,12 @@ module Metanorma
|
|
22
22
|
attr_code(
|
23
23
|
from: node.attr("from"),
|
24
24
|
to: node.attr("to") || node.attr("from"),
|
25
|
+
type: node.attr("type") || nil,
|
25
26
|
),
|
26
27
|
)
|
27
28
|
end
|
28
29
|
|
29
30
|
def sidebar(node)
|
30
|
-
return unless draft?
|
31
|
-
|
32
31
|
noko do |xml|
|
33
32
|
xml.review **sidebar_attrs(node) do |r|
|
34
33
|
wrap_in_para(node, r)
|
@@ -42,7 +41,7 @@ module Metanorma
|
|
42
41
|
attr_code(id_attr(node)
|
43
42
|
.merge(reviewer: node.attr("reviewer") || node.attr("source") ||
|
44
43
|
"(Unknown)",
|
45
|
-
date: date))
|
44
|
+
date: date, type: "todo"))
|
46
45
|
end
|
47
46
|
|
48
47
|
def todo(node)
|
@@ -96,10 +95,7 @@ module Metanorma
|
|
96
95
|
end
|
97
96
|
|
98
97
|
def admonition(node)
|
99
|
-
|
100
|
-
return note(node) if node.attr("name") == "note"
|
101
|
-
return todo(node) if node.attr("name") == "todo"
|
102
|
-
|
98
|
+
ret = admonition_alternatives(node) and return ret
|
103
99
|
noko do |xml|
|
104
100
|
xml.admonition **admonition_attrs(node) do |a|
|
105
101
|
node.title.nil? or a.name { |name| name << node.title }
|
@@ -107,6 +103,13 @@ module Metanorma
|
|
107
103
|
end
|
108
104
|
end.join("\n")
|
109
105
|
end
|
106
|
+
|
107
|
+
def admonition_alternatives(node)
|
108
|
+
in_terms? && node.attr("name") == "note" and return termnote(node)
|
109
|
+
node.attr("name") == "note" and return note(node)
|
110
|
+
node.attr("name") == "todo" and return todo(node)
|
111
|
+
nil
|
112
|
+
end
|
110
113
|
end
|
111
114
|
end
|
112
115
|
end
|
@@ -29,6 +29,7 @@ module Metanorma
|
|
29
29
|
element_name_cleanup(xmldoc)
|
30
30
|
passthrough_cleanup(xmldoc)
|
31
31
|
unnumbered_blocks_cleanup(xmldoc)
|
32
|
+
termdocsource_cleanup(xmldoc) # feeds: metadata_cleanup
|
32
33
|
metadata_cleanup(xmldoc) # feeds: boilerplate_cleanup
|
33
34
|
sections_cleanup(xmldoc) # feeds: obligations_cleanup, toc_cleanup,
|
34
35
|
# floatingtitle_cleanup
|
@@ -14,11 +14,12 @@ module Metanorma
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def strip_initial_space(elem)
|
17
|
-
elem.children[0]
|
18
|
-
|
19
|
-
|
17
|
+
a = elem.children[0]
|
18
|
+
a.text? or return
|
19
|
+
if /\S/.match?(a.text)
|
20
|
+
a.content = a.text.lstrip
|
20
21
|
else
|
21
|
-
|
22
|
+
a.remove
|
22
23
|
end
|
23
24
|
end
|
24
25
|
|
@@ -208,6 +209,10 @@ module Metanorma
|
|
208
209
|
end
|
209
210
|
|
210
211
|
def link_cleanup(xmldoc)
|
212
|
+
uri_cleanup(xmldoc)
|
213
|
+
end
|
214
|
+
|
215
|
+
def uri_cleanup(xmldoc)
|
211
216
|
xmldoc.xpath("//link[@target]").each do |l|
|
212
217
|
l["target"] = Addressable::URI.parse(l["target"]).to_s
|
213
218
|
rescue Addressable::URI::InvalidURIError
|
@@ -17,7 +17,7 @@
|
|
17
17
|
these elements; we just want one namespace for any child grammars
|
18
18
|
of this.
|
19
19
|
-->
|
20
|
-
<!-- VERSION v1.
|
20
|
+
<!-- VERSION v1.3.0 -->
|
21
21
|
<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">
|
22
22
|
<include href="reqt.rng"/>
|
23
23
|
<include href="basicdoc.rng">
|
@@ -146,6 +146,9 @@
|
|
146
146
|
<data type="boolean"/>
|
147
147
|
</attribute>
|
148
148
|
</optional>
|
149
|
+
<optional>
|
150
|
+
<attribute name="style"/>
|
151
|
+
</optional>
|
149
152
|
<oneOrMore>
|
150
153
|
<ref name="PureTextElement"/>
|
151
154
|
</oneOrMore>
|
@@ -24,10 +24,9 @@ module Metanorma
|
|
24
24
|
def sectiontype(node, level = true)
|
25
25
|
ret = sectiontype1(node)
|
26
26
|
ret1 = preface_main_filter(sectiontype_streamline(ret), node)
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
27
|
+
ret1 == "symbols and abbreviated terms" and return ret1
|
28
|
+
!level || node.level == 1 or return nil
|
29
|
+
@seen_headers.include? ret and return nil
|
31
30
|
@seen_headers << ret unless ret1.nil?
|
32
31
|
@seen_headers_canonical << ret1 unless ret1.nil?
|
33
32
|
ret1
|
@@ -95,8 +94,8 @@ module Metanorma
|
|
95
94
|
"multilingual-rendering": node&.attr("multilingual-rendering"),
|
96
95
|
colophon: (if node.role == "colophon" ||
|
97
96
|
node.attr("style") == "colophon"
|
98
|
-
|
99
|
-
|
97
|
+
true
|
98
|
+
end),
|
100
99
|
preface: (if node.role == "preface" ||
|
101
100
|
node.attr("style") == "preface"
|
102
101
|
true
|
@@ -152,13 +151,13 @@ module Metanorma
|
|
152
151
|
end
|
153
152
|
|
154
153
|
def set_obligation(attrs, node)
|
155
|
-
attrs[:obligation] =
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
154
|
+
attrs[:obligation] =
|
155
|
+
if node.attributes.has_key?("obligation")
|
156
|
+
node.attr("obligation")
|
157
|
+
elsif node.parent.attributes.has_key?("obligation")
|
158
|
+
node.parent.attr("obligation")
|
159
|
+
else "normative"
|
160
|
+
end
|
162
161
|
end
|
163
162
|
|
164
163
|
def preamble(node)
|
@@ -167,8 +166,7 @@ module Metanorma
|
|
167
166
|
xml_abstract.title do |t|
|
168
167
|
t << (node.blocks[0].title || @i18n.foreword)
|
169
168
|
end
|
170
|
-
|
171
|
-
xml_abstract << content
|
169
|
+
xml_abstract << node.content
|
172
170
|
end
|
173
171
|
end.join("\n")
|
174
172
|
end
|
@@ -241,9 +239,9 @@ module Metanorma
|
|
241
239
|
end
|
242
240
|
|
243
241
|
def floating_title_attrs(node)
|
244
|
-
attr_code(id_attr(node)
|
245
|
-
|
246
|
-
|
242
|
+
attr_code(id_attr(node)
|
243
|
+
.merge(align: node.attr("align"), depth: node.level,
|
244
|
+
type: "floating-title"))
|
247
245
|
end
|
248
246
|
|
249
247
|
def floating_title(node)
|
@@ -64,9 +64,10 @@ module Metanorma
|
|
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
|
-
|
69
|
-
|
67
|
+
refterm.replace(<<~XML,
|
68
|
+
<preferred><expression><name>#{refterm.children.to_xml}</name></expression></preferred>
|
69
|
+
XML
|
70
|
+
)
|
70
71
|
end
|
71
72
|
end
|
72
73
|
|
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.1
|
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-
|
11
|
+
date: 2024-02-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|