metanorma-standoc 2.3.1 → 2.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/isodoc/html/htmlstyle.css +5 -2
- data/lib/metanorma/standoc/base.rb +1 -0
- data/lib/metanorma/standoc/blocks.rb +2 -0
- data/lib/metanorma/standoc/cleanup_biblio.rb +13 -2
- data/lib/metanorma/standoc/cleanup_inline.rb +3 -3
- data/lib/metanorma/standoc/cleanup_ref.rb +9 -4
- data/lib/metanorma/standoc/cleanup_text.rb +6 -7
- data/lib/metanorma/standoc/isodoc.rng +11 -1
- data/lib/metanorma/standoc/macros_terms.rb +1 -1
- data/lib/metanorma/standoc/ref.rb +2 -1
- data/lib/metanorma/standoc/ref_sect.rb +2 -1
- data/lib/metanorma/standoc/render.rb +2 -1
- data/lib/metanorma/standoc/term_lookup_cleanup.rb +9 -7
- data/lib/metanorma/standoc/validate.rb +12 -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: 2d72f2951373ad8935a9c03fe0d06bbd4f76a77cfdd6d186aa80438f64dd6d66
|
4
|
+
data.tar.gz: 3bb9f924a50c9567b23d7807bc487de0eaa05ff87228d5f7a16d719239689156
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2160831ca83c2cd6be5b95b82cf99815770f50e819613377175af2640fc428a1765200af59c2110c6e3d36bc923211cbb59c6c867c9f0c5eab36bbeb2ed2d912
|
7
|
+
data.tar.gz: ee37fdf784424521cf87cd6318fd7531c28282383c66360bcce5b7107f5731575ebba832231e61ec5809b72ca235057490ddec989f9625aab79c20e4ee73e0e8
|
@@ -544,8 +544,11 @@ a:hover {
|
|
544
544
|
background: #C70039;
|
545
545
|
box-shadow: 3px 0 0 #C70039, -3px 0 0 #C70039; }
|
546
546
|
|
547
|
-
|
548
|
-
|
547
|
+
*::selection {
|
548
|
+
background: #C70039;
|
549
|
+
color: white; }
|
550
|
+
|
551
|
+
*::-moz-selection {
|
549
552
|
background: #C70039;
|
550
553
|
color: white; }
|
551
554
|
|
@@ -231,8 +231,10 @@ module Metanorma
|
|
231
231
|
end
|
232
232
|
|
233
233
|
def listing_attrs(node)
|
234
|
+
linenums = (node.option?("linenums") || @source_linenums)
|
234
235
|
attr_code(id_attr(node).merge(keep_attrs(node)
|
235
236
|
.merge(lang: node.attr("language"),
|
237
|
+
linenums: linenums ? "true" : nil,
|
236
238
|
unnumbered: node.option?("unnumbered") ? "true" : nil,
|
237
239
|
number: node.attr("number"),
|
238
240
|
filename: node.attr("filename"))))
|
@@ -87,7 +87,7 @@ module Metanorma
|
|
87
87
|
ret[:in][:contrib] =
|
88
88
|
spans_preprocess_org(span, ret[:in][:contrib])
|
89
89
|
else
|
90
|
-
warn "unrecognised `span:#{span[
|
90
|
+
warn "unrecognised `span:#{span['key']}`"
|
91
91
|
end
|
92
92
|
end
|
93
93
|
|
@@ -170,7 +170,7 @@ module Metanorma
|
|
170
170
|
ret = ""
|
171
171
|
spans[:uri].each { |s| ret += span_to_docid(s, "uri") }
|
172
172
|
spans[:docid].each { |s| ret += span_to_docid(s, "docidentifier") }
|
173
|
-
spans[:date].each { |s| ret +=
|
173
|
+
spans[:date].each { |s| ret += span_to_date(s) }
|
174
174
|
ret
|
175
175
|
end
|
176
176
|
|
@@ -201,6 +201,17 @@ module Metanorma
|
|
201
201
|
end
|
202
202
|
end
|
203
203
|
|
204
|
+
def span_to_date(span)
|
205
|
+
val = if /[-–](?=\d{4})/.match?(span[:val])
|
206
|
+
from, to = span[:val].split(/[-–](?=\d{4})/, 2)
|
207
|
+
"<from>#{from}</from><to>#{to}</to>"
|
208
|
+
else
|
209
|
+
"<on>#{span[:val]}</on>"
|
210
|
+
end
|
211
|
+
type = span[:type] ? " type='#{span[:type]}'" : ""
|
212
|
+
"<date#{type}>#{val}</date>"
|
213
|
+
end
|
214
|
+
|
204
215
|
def span_to_contrib(span, title)
|
205
216
|
e = if span[:entity] == "organization"
|
206
217
|
"<organization><name>#{span[:name]}</name></organization>"
|
@@ -77,7 +77,7 @@ module Metanorma
|
|
77
77
|
def related_cleanup(xmldoc)
|
78
78
|
xmldoc.xpath("//related[not(termxref)]").each do |x|
|
79
79
|
term = x.at("./refterm")
|
80
|
-
term.replace("<preferred>#{term_expr(term.children.to_xml)}"\
|
80
|
+
term.replace("<preferred>#{term_expr(term.children.to_xml)}" \
|
81
81
|
"</preferred>")
|
82
82
|
concept_cleanup1(x)
|
83
83
|
end
|
@@ -119,8 +119,8 @@ module Metanorma
|
|
119
119
|
"#{pref}##{suff}"
|
120
120
|
end
|
121
121
|
|
122
|
-
IDREF = "//*/@id | //review/@from | //review/@to | "\
|
123
|
-
"//callout/@target | //citation/@bibitemid | "\
|
122
|
+
IDREF = "//*/@id | //review/@from | //review/@to | " \
|
123
|
+
"//callout/@target | //citation/@bibitemid | " \
|
124
124
|
"//eref/@bibitemid".freeze
|
125
125
|
|
126
126
|
def anchor_cleanup(elem)
|
@@ -50,7 +50,7 @@ module Metanorma
|
|
50
50
|
# only numeric references are renumbered
|
51
51
|
def biblio_renumber(xmldoc)
|
52
52
|
i = 0
|
53
|
-
xmldoc.xpath("//references[not(@normative = 'true')]"\
|
53
|
+
xmldoc.xpath("//references[not(@normative = 'true')]" \
|
54
54
|
"[not(@hidden = 'true')]").each do |r|
|
55
55
|
r.xpath("./bibitem[not(@hidden = 'true')]").each do |b|
|
56
56
|
i += 1
|
@@ -139,6 +139,11 @@ module Metanorma
|
|
139
139
|
end
|
140
140
|
|
141
141
|
def format_ref(ref, type)
|
142
|
+
ret = Nokogiri::XML.fragment(ref)
|
143
|
+
ret.traverse do |x|
|
144
|
+
x.remove if x.name == "fn"
|
145
|
+
end
|
146
|
+
ref = to_xml(ret)
|
142
147
|
return @isodoc.docid_prefix(type, ref) if type != "metanorma"
|
143
148
|
return "[#{ref}]" if /^\d+$/.match(ref) && !/^\[.*\]$/.match(ref)
|
144
149
|
|
@@ -146,9 +151,9 @@ module Metanorma
|
|
146
151
|
end
|
147
152
|
|
148
153
|
ISO_PUBLISHER_XPATH =
|
149
|
-
"./contributor[role/@type = 'publisher']/"\
|
150
|
-
"organization[abbreviation = 'ISO' or abbreviation = 'IEC' or "\
|
151
|
-
"name = 'International Organization for Standardization' or "\
|
154
|
+
"./contributor[role/@type = 'publisher']/" \
|
155
|
+
"organization[abbreviation = 'ISO' or abbreviation = 'IEC' or " \
|
156
|
+
"name = 'International Organization for Standardization' or " \
|
152
157
|
"name = 'International Electrotechnical Commission']".freeze
|
153
158
|
|
154
159
|
def reference_names(xmldoc)
|
@@ -40,7 +40,7 @@ module Metanorma
|
|
40
40
|
|
41
41
|
def uninterrupt_quotes_around_xml_skip(elem)
|
42
42
|
!(/\A['"]/.match?(elem.text) &&
|
43
|
-
elem.previous.path.split(%r{/})[1..-2]
|
43
|
+
elem.previous.path.gsub(/\[\d+\]/, "").split(%r{/})[1..-2]
|
44
44
|
.intersection(IGNORE_QUOTES_ELEMENTS).empty? &&
|
45
45
|
((elem.previous.text.strip.empty? &&
|
46
46
|
!empty_tag_with_text_content?(elem.previous)) ||
|
@@ -82,12 +82,12 @@ module Metanorma
|
|
82
82
|
xmldoc.traverse do |x|
|
83
83
|
block?(x) and prev = ""
|
84
84
|
empty_tag_with_text_content?(x) and prev = "dummy"
|
85
|
-
|
85
|
+
x.text? or next
|
86
86
|
|
87
|
-
ancestors = x.path.split(%r{/})[1..-2]
|
88
|
-
ancestors.intersection(IGNORE_QUOTES_ELEMENTS).empty?
|
89
|
-
|
90
|
-
prev = x.text
|
87
|
+
ancestors = x.path.gsub(/\[\d+\]/, "").split(%r{/})[1..-2]
|
88
|
+
ancestors.intersection(IGNORE_QUOTES_ELEMENTS).empty? or next
|
89
|
+
dumb2smart_quotes1(x, prev)
|
90
|
+
prev = x.text
|
91
91
|
end
|
92
92
|
end
|
93
93
|
|
@@ -103,7 +103,6 @@ module Metanorma
|
|
103
103
|
xmldoc.traverse do |n|
|
104
104
|
next unless n.text? && /\u2019/.match?(n.text)
|
105
105
|
|
106
|
-
# n.replace(n.text.gsub(/(?<=\p{Alnum})\u2019(?=\p{Alpha})/, "'")) # .
|
107
106
|
n.replace(@c.encode(
|
108
107
|
@c.decode(n.text)
|
109
108
|
.gsub(/(?<=\p{Alnum})\u2019(?=\p{Alpha})/, "'"),
|
@@ -571,6 +571,11 @@
|
|
571
571
|
<ref name="MultilingualRenderingType"/>
|
572
572
|
</attribute>
|
573
573
|
</optional>
|
574
|
+
<optional>
|
575
|
+
<attribute name="linenums">
|
576
|
+
<data type="boolean"/>
|
577
|
+
</attribute>
|
578
|
+
</optional>
|
574
579
|
<optional>
|
575
580
|
<ref name="tname"/>
|
576
581
|
</optional>
|
@@ -1238,6 +1243,11 @@
|
|
1238
1243
|
</define>
|
1239
1244
|
<define name="concept">
|
1240
1245
|
<element name="concept">
|
1246
|
+
<optional>
|
1247
|
+
<attribute name="bold">
|
1248
|
+
<data type="boolean"/>
|
1249
|
+
</attribute>
|
1250
|
+
</optional>
|
1241
1251
|
<optional>
|
1242
1252
|
<attribute name="ital">
|
1243
1253
|
<data type="boolean"/>
|
@@ -2653,7 +2663,7 @@
|
|
2653
2663
|
<value>full</value>
|
2654
2664
|
<value>short</value>
|
2655
2665
|
<value>id</value>
|
2656
|
-
<
|
2666
|
+
<text/>
|
2657
2667
|
</choice>
|
2658
2668
|
</define>
|
2659
2669
|
<define name="erefTypeWithConnective">
|
@@ -129,7 +129,7 @@ module Metanorma
|
|
129
129
|
|
130
130
|
def generate_attrs(opts)
|
131
131
|
ret = ""
|
132
|
-
%w(ital ref linkmention linkref).each do |x|
|
132
|
+
%w(ital bold ref linkmention linkref).each do |x|
|
133
133
|
opts.include?("no#{x}") and ret += " #{x}='false'"
|
134
134
|
opts.include?(x) and ret += " #{x}='true'"
|
135
135
|
end
|
@@ -107,7 +107,8 @@ module Metanorma
|
|
107
107
|
end
|
108
108
|
|
109
109
|
def emend_biblio_id(xml, code)
|
110
|
-
unless xml.at("/bibitem/docidentifier[not(@type = 'DOI')][text()]")
|
110
|
+
unless xml.at("/bibitem/docidentifier[not(@type = 'DOI')][text()]") ||
|
111
|
+
/^doi:/.match?(code)
|
111
112
|
@log.add("Bibliography", nil,
|
112
113
|
"ERROR: No document identifier retrieved for #{code}")
|
113
114
|
xml.root << "<docidentifier>#{code}</docidentifier>"
|
@@ -20,7 +20,7 @@ module Metanorma
|
|
20
20
|
htmltoclevels: node.attr("htmltoclevels") || node.attr("toclevels"),
|
21
21
|
doctoclevels: node.attr("doctoclevels") || node.attr("toclevels"),
|
22
22
|
breakupurlsintables: node.attr("break-up-urls-in-tables"),
|
23
|
-
suppressasciimathdup: node.attr("suppress-asciimath-dup"),
|
23
|
+
suppressasciimathdup: node.attr("suppress-asciimath-dup") == "true",
|
24
24
|
bare: node.attr("bare"),
|
25
25
|
sectionsplit: node.attr("sectionsplit"),
|
26
26
|
baseassetpath: node.attr("base-asset-path"),
|
@@ -32,6 +32,7 @@ module Metanorma
|
|
32
32
|
fontlicenseagreement: node.attr("font-license-agreement"),
|
33
33
|
localizenumber: node.attr("localize-number"),
|
34
34
|
modspecidentifierbase: node.attr("modspec-identifier-base"),
|
35
|
+
sourcehighlighter: node.attr("source-highlighter") != "false",
|
35
36
|
}
|
36
37
|
end
|
37
38
|
|
@@ -16,6 +16,9 @@ module Metanorma
|
|
16
16
|
@log = log
|
17
17
|
@termlookup = { term: {}, symbol: {}, secondary2primary: {} }
|
18
18
|
@idhash = {}
|
19
|
+
@terms_tags = xmldoc.xpath("//terms").each_with_object({}) do |t, m|
|
20
|
+
m[t["id"]] = true
|
21
|
+
end
|
19
22
|
end
|
20
23
|
|
21
24
|
def call
|
@@ -42,8 +45,8 @@ module Metanorma
|
|
42
45
|
refterm = n.at("./refterm") or next
|
43
46
|
p = @termlookup[:secondary2primary][refterm.text] and
|
44
47
|
refterm.children = p
|
45
|
-
refterm.replace("<preferred><expression>"\
|
46
|
-
"<name>#{refterm.children.to_xml}"\
|
48
|
+
refterm.replace("<preferred><expression>" \
|
49
|
+
"<name>#{refterm.children.to_xml}" \
|
47
50
|
"</name></expression></preferred>")
|
48
51
|
end
|
49
52
|
end
|
@@ -90,10 +93,9 @@ module Metanorma
|
|
90
93
|
remove_missing_ref_msg1(node, target, ret)
|
91
94
|
end
|
92
95
|
|
93
|
-
def remove_missing_ref_msg1(
|
96
|
+
def remove_missing_ref_msg1(_node, target, ret)
|
94
97
|
target2 = "_#{target.downcase.gsub(/-/, '_')}"
|
95
|
-
if
|
96
|
-
node.document.at("//*[@id = '#{target2}']")&.name == "terms"
|
98
|
+
if @terms_tags[target] || @terms_tags[target2]
|
97
99
|
ret.strip!
|
98
100
|
ret += ". Did you mean to point to a subterm?"
|
99
101
|
end
|
@@ -106,7 +108,7 @@ module Metanorma
|
|
106
108
|
display = node.at("../renderterm")&.remove&.children
|
107
109
|
display = [] if display.nil? || display.to_xml == node.text
|
108
110
|
d = display.empty? ? "" : ", display <tt>#{display.to_xml}</tt>"
|
109
|
-
node.children = "term <tt>#{node.text}</tt>#{d} "\
|
111
|
+
node.children = "term <tt>#{node.text}</tt>#{d} " \
|
110
112
|
"not resolved via ID <tt>#{target}</tt>"
|
111
113
|
end
|
112
114
|
|
@@ -116,7 +118,7 @@ module Metanorma
|
|
116
118
|
display = node.at("../renderterm")&.remove&.children
|
117
119
|
display = [] if display.nil? || display.to_xml == node.text
|
118
120
|
d = display.empty? ? "" : ", display <tt>#{display.to_xml}</tt>"
|
119
|
-
node.children = "symbol <tt>#{node.text}</tt>#{d} "\
|
121
|
+
node.children = "symbol <tt>#{node.text}</tt>#{d} " \
|
120
122
|
"not resolved via ID <tt>#{target}</tt>"
|
121
123
|
end
|
122
124
|
|
@@ -72,10 +72,9 @@ module Metanorma
|
|
72
72
|
|
73
73
|
def concept_validate(doc, tag, refterm)
|
74
74
|
found = false
|
75
|
+
concept_validate_ids(doc)
|
75
76
|
doc.xpath("//#{tag}/xref").each do |x|
|
76
|
-
|
77
|
-
next if doc.at("//definitions//dt[@id = '#{x['target']}']")
|
78
|
-
|
77
|
+
@concept_ids[x["target"]] and next
|
79
78
|
@log.add("Anchors", x, concept_validate_msg(doc, tag, refterm, x))
|
80
79
|
found = true
|
81
80
|
end
|
@@ -83,11 +82,19 @@ module Metanorma
|
|
83
82
|
@fatalerror << "#{tag.capitalize} not cross-referencing term or symbol"
|
84
83
|
end
|
85
84
|
|
86
|
-
def
|
85
|
+
def concept_validate_ids(doc)
|
86
|
+
@concept_ids ||= doc.xpath("//term | //definitions//dt")
|
87
|
+
.each_with_object({}) { |x, m| m[x["id"]] = true }
|
88
|
+
@concept_terms_tags ||= doc.xpath("//terms")
|
89
|
+
.each_with_object({}) { |t, m| m[t["id"]] = true }
|
90
|
+
nil
|
91
|
+
end
|
92
|
+
|
93
|
+
def concept_validate_msg(_doc, tag, refterm, xref)
|
87
94
|
ret = <<~LOG
|
88
95
|
#{tag.capitalize} #{xref.at("../#{refterm}")&.text} is pointing to #{xref['target']}, which is not a term or symbol
|
89
96
|
LOG
|
90
|
-
if
|
97
|
+
if @concept_terms_tags[xref["target"]]
|
91
98
|
ret = ret.strip
|
92
99
|
ret += ". Did you mean to point to a subterm?"
|
93
100
|
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: 2.3.
|
4
|
+
version: 2.3.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: 2022-12-
|
11
|
+
date: 2022-12-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciidoctor
|