metanorma-standoc 2.3.4 → 2.3.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 62a2a480483e6cad337d48919668d1276a587c0c6173ffc7ea8cb773f605b1fb
4
- data.tar.gz: 5a9bf620c79d8ec2993a96727f7b8c2874ee8d8c3865a5efd71941fb83ed8fc1
3
+ metadata.gz: d7c637a8a2cab495ee675be427ab80dbfa3268f7630cc1161ca3f1b75c40688c
4
+ data.tar.gz: db253ce3dde5b476d87a404d6de2d99606410262ad091edacea453c18476910c
5
5
  SHA512:
6
- metadata.gz: 226d8eaa68590e2dbf12917371afe5f2c4c60242397e459543da0ec3471a7a0abc7f5736e92b43f053854329f460bbc70155040bd0ae1df89efa0a62f8765d8e
7
- data.tar.gz: 65a7c4e9794199fd48f3d18f3009a41d02ae837753d9e9e9cd41f755384f7b89f3376f5a6c9182de5f184eb4934a9fc9682b8ea708037aa315d9e243f83485bf
6
+ metadata.gz: 1ba632dd7ca73b0c6314212c57d9a56ed2da84f52b4ab2cd32c46d53a1a994d096d2b6a43cdc4dd161f2ddfff19a2ac7d4c113e6181054631cb3494421ff02b0
7
+ data.tar.gz: bc6cf925cc3bd5aa0777044a2568368600adcffe486e164d1ca7d0dd31370c729e45eafc62e0d3dd64d0238d618efdf9a2fc4405dddfe5af25d982f93de69966
@@ -42,12 +42,11 @@ module Metanorma
42
42
  end
43
43
 
44
44
  def content_validate(doc)
45
- nested_asset_validate_basic(doc)
46
- nested_note_validate(doc)
47
- xref_validate(doc)
45
+ repeat_id_validate(doc.root) # feeds xref_validate
46
+ xref_validate(doc) # feeds nested_asset_validate
47
+ nested_asset_validate(doc)
48
48
  section_validate(doc)
49
49
  norm_ref_validate(doc)
50
- repeat_id_validate(doc.root)
51
50
  iev_validate(doc.root)
52
51
  concept_validate(doc, "concept", "refterm")
53
52
  concept_validate(doc, "related", "preferred//name")
@@ -58,6 +57,11 @@ module Metanorma
58
57
  clean_abort(@fatalerror.join("\n"), doc)
59
58
  end
60
59
 
60
+ def nested_asset_validate(doc)
61
+ nested_asset_validate_basic(doc)
62
+ nested_note_validate(doc)
63
+ end
64
+
61
65
  def nested_asset_validate_basic(doc)
62
66
  a = "//formula | //example | //figure | //termnote | //termexample | " \
63
67
  "//table"
@@ -76,11 +80,21 @@ module Metanorma
76
80
  end
77
81
  end
78
82
 
79
- def nested_asset_report(outer, inner, _doc)
83
+ def nested_asset_report(outer, inner, doc)
80
84
  outer.name == "figure" && inner.name == "figure" and return
81
- err = "There is an instance of #{inner.name} nested within #{outer.name}"
85
+ outer.name != "formula" && inner.name == "formula" and return
86
+ err =
87
+ "There is an instance of #{inner.name} nested within #{outer.name}"
82
88
  @log.add("Syntax", inner, err)
83
- @fatalerror << "#{err}:\n#{inner.to_xml}"
89
+ nested_asset_xref_report(outer, inner, doc)
90
+ end
91
+
92
+ def nested_asset_xref_report(outer, inner, _doc)
93
+ i = @doc_xrefs[inner["id"]] or return
94
+ err2 = "There is a crossreference to an instance of #{inner.name} " \
95
+ "nested within #{outer.name}: #{i.to_xml}"
96
+ @log.add("Style", i, err2)
97
+ @fatalerror << err2
84
98
  end
85
99
 
86
100
  def norm_ref_validate(doc)
@@ -103,8 +117,8 @@ module Metanorma
103
117
  @log.add("Anchors", x, concept_validate_msg(doc, tag, refterm, x))
104
118
  found = true
105
119
  end
106
- found and
107
- @fatalerror << "#{tag.capitalize} not cross-referencing term or symbol"
120
+ found and @fatalerror << "#{tag.capitalize} not cross-referencing " \
121
+ "term or symbol"
108
122
  end
109
123
 
110
124
  def concept_validate_ids(doc)
@@ -126,20 +140,19 @@ module Metanorma
126
140
  ret
127
141
  end
128
142
 
129
- def repeat_id_validate1(ids, elem)
130
- if ids[elem["id"]]
143
+ def repeat_id_validate1(elem)
144
+ if @doc_ids[elem["id"]]
131
145
  @log.add("Anchors", elem, "Anchor #{elem['id']} has already been " \
132
- "used at line #{ids[elem['id']]}")
146
+ "used at line #{@doc_ids[elem['id']]}")
133
147
  @fatalerror << "Multiple instances of same ID: #{elem['id']}"
134
- else ids[elem["id"]] = elem.line
135
148
  end
136
- ids
149
+ @doc_ids[elem["id"]] = elem.line
137
150
  end
138
151
 
139
152
  def repeat_id_validate(doc)
140
- ids = {}
153
+ @doc_ids = {}
141
154
  doc.xpath("//*[@id]").each do |x|
142
- ids = repeat_id_validate1(ids, x)
155
+ repeat_id_validate1(x)
143
156
  end
144
157
  end
145
158
 
@@ -188,11 +201,12 @@ module Metanorma
188
201
 
189
202
  # manually check for xref/@target, xref/@to integrity
190
203
  def xref_validate(doc)
191
- ids = doc.xpath("//*/@id").each_with_object({}) { |x, m| m[x.text] = 1 }
192
- doc.xpath("//xref/@target | //xref/@to").each do |x|
193
- ids[x.text] and next
204
+ @doc_xrefs = doc.xpath("//xref/@target | //xref/@to")
205
+ .each_with_object({}) do |x, m|
206
+ m[x.text] = x
207
+ @doc_ids[x] and next
194
208
  @log.add("Anchors", x.parent,
195
- "Crossreference target #{x.text} is undefined")
209
+ "Crossreference target #{x} is undefined")
196
210
  end
197
211
  end
198
212
 
@@ -19,6 +19,6 @@ module Metanorma
19
19
  end
20
20
 
21
21
  module Standoc
22
- VERSION = "2.3.4".freeze
22
+ VERSION = "2.3.6".freeze
23
23
  end
24
24
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-standoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.4
4
+ version: 2.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.