metanorma-standoc 3.2.3 → 3.2.4
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/biblio.rng +14 -4
- data/lib/metanorma/standoc/init.rb +12 -4
- data/lib/metanorma/standoc/isodoc.rng +1 -1
- data/lib/metanorma/standoc/log.rb +3 -0
- data/lib/metanorma/standoc/render.rb +4 -0
- data/lib/metanorma/standoc/validate_image.rb +48 -16
- data/lib/metanorma/standoc/validate_schema.rb +18 -6
- 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: ec17f7140bc90f4bf870ab2ecf47e42adacc489e4e5dfc8802dbbea87a31973f
|
|
4
|
+
data.tar.gz: 3da2d1e8a995ebc3d5fb5fe10694cd1094343261e58667007250ed07dde5ea1b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 44afc48d384a6c8685b223feaa5905a56cc1d3ee9b572abd221b839be690698d73bb253539abe8f4ece2810185ebd6dc64321a0aa7335007a6384ad4fbea2f18
|
|
7
|
+
data.tar.gz: dc1ef34776bca5944dec22bad965498970de309848b4fb9c9370dfe303490d57b5dceedae26bac8f0b5cce7642318a607c613fa0044ba10e5fd6b58972ed9a3e
|
|
@@ -466,11 +466,11 @@ Editorial and advisory groups are represented as consecutive subdivisions of the
|
|
|
466
466
|
<a:documentation>Contact information for the organization, including address, phone number, and email</a:documentation>
|
|
467
467
|
</ref>
|
|
468
468
|
</optional>
|
|
469
|
-
<
|
|
469
|
+
<zeroOrMore>
|
|
470
470
|
<ref name="logo">
|
|
471
471
|
<a:documentation>A logo for the organization</a:documentation>
|
|
472
472
|
</ref>
|
|
473
|
-
</
|
|
473
|
+
</zeroOrMore>
|
|
474
474
|
</define>
|
|
475
475
|
<define name="orgname">
|
|
476
476
|
<element name="name">
|
|
@@ -502,6 +502,11 @@ Editorial and advisory groups are represented as consecutive subdivisions of the
|
|
|
502
502
|
</define>
|
|
503
503
|
<define name="logo">
|
|
504
504
|
<element name="logo">
|
|
505
|
+
<optional>
|
|
506
|
+
<attribute name="type">
|
|
507
|
+
<a:documentation>The type of logo</a:documentation>
|
|
508
|
+
</attribute>
|
|
509
|
+
</optional>
|
|
505
510
|
<ref name="image-no-id"/>
|
|
506
511
|
</element>
|
|
507
512
|
</define>
|
|
@@ -513,6 +518,11 @@ Editorial and advisory groups are represented as consecutive subdivisions of the
|
|
|
513
518
|
<a:documentation>Description of what is being depicted</a:documentation>
|
|
514
519
|
</attribute>
|
|
515
520
|
</optional>
|
|
521
|
+
<optional>
|
|
522
|
+
<attribute name="type">
|
|
523
|
+
<a:documentation>Description of what kind of depiction this</a:documentation>
|
|
524
|
+
</attribute>
|
|
525
|
+
</optional>
|
|
516
526
|
<zeroOrMore>
|
|
517
527
|
<ref name="image-no-id">
|
|
518
528
|
<a:documentation>A visual depiction of the bibliographic item</a:documentation>
|
|
@@ -1236,9 +1246,9 @@ Refer to `BibliographicItem` for definitions</a:documentation>
|
|
|
1236
1246
|
<optional>
|
|
1237
1247
|
<ref name="validity"/>
|
|
1238
1248
|
</optional>
|
|
1239
|
-
<
|
|
1249
|
+
<zeroOrMore>
|
|
1240
1250
|
<ref name="depiction"/>
|
|
1241
|
-
</
|
|
1251
|
+
</zeroOrMore>
|
|
1242
1252
|
</define>
|
|
1243
1253
|
<define name="btitle">
|
|
1244
1254
|
<a:documentation>A title of a bibliographic item, associated with a type of title</a:documentation>
|
|
@@ -134,11 +134,19 @@ module Metanorma
|
|
|
134
134
|
end
|
|
135
135
|
|
|
136
136
|
def i18nyaml_path(node)
|
|
137
|
-
if
|
|
138
|
-
(Pathname.new
|
|
139
|
-
|
|
137
|
+
if ret = node.attr("i18nyaml")
|
|
138
|
+
(Pathname.new ret).absolute? or
|
|
139
|
+
ret = File.join(@localdir, ret)
|
|
140
140
|
end
|
|
141
|
-
|
|
141
|
+
ret
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
def relaton_render_path(node)
|
|
145
|
+
if ret = node.attr("relaton-render-config")
|
|
146
|
+
(Pathname.new ret).absolute? or
|
|
147
|
+
ret = File.join(@localdir, ret)
|
|
148
|
+
end
|
|
149
|
+
ret
|
|
142
150
|
end
|
|
143
151
|
|
|
144
152
|
def init_i18n(node)
|
|
@@ -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.1.
|
|
3
|
+
<!-- VERSION v2.1.5 -->
|
|
4
4
|
|
|
5
5
|
<!--
|
|
6
6
|
ALERT: cannot have root comments, because of https://github.com/metanorma/metanorma/issues/437
|
|
@@ -180,6 +180,9 @@ module Metanorma
|
|
|
180
180
|
"STANDOC_58": { category: "Images",
|
|
181
181
|
error: "Corrupt SVG image detected, fix attempted: %s %s: %s %s, Node: %s",
|
|
182
182
|
severity: 2 },
|
|
183
|
+
"STANDOC_59": { category: "Images",
|
|
184
|
+
error: "SVG unresolved internal reference: %s line %s",
|
|
185
|
+
severity: 3 },
|
|
183
186
|
"RELATON_1": { category: "Relaton",
|
|
184
187
|
error: "(Error from Relaton) %s",
|
|
185
188
|
severity: 0 },
|
|
@@ -3,12 +3,14 @@ module Metanorma
|
|
|
3
3
|
module Base
|
|
4
4
|
def html_extract_attributes(node)
|
|
5
5
|
i18nyaml = i18nyaml_path(node)
|
|
6
|
+
relaton_render_config = relaton_render_path(node)
|
|
6
7
|
{
|
|
7
8
|
script: node.attr("script"),
|
|
8
9
|
bodyfont: node.attr("body-font"),
|
|
9
10
|
headerfont: node.attr("header-font"),
|
|
10
11
|
monospacefont: node.attr("monospace-font"),
|
|
11
12
|
i18nyaml: i18nyaml,
|
|
13
|
+
relatonrenderconfig: relaton_render_config,
|
|
12
14
|
scope: node.attr("scope"),
|
|
13
15
|
htmlstylesheet: node.attr("htmlstylesheet") || node.attr("html-stylesheet"),
|
|
14
16
|
htmlstylesheet_override: node.attr("htmlstylesheet-override") || node.attr("html-stylesheet-override"),
|
|
@@ -50,12 +52,14 @@ module Metanorma
|
|
|
50
52
|
|
|
51
53
|
def doc_extract_attributes(node)
|
|
52
54
|
i18nyaml = i18nyaml_path(node)
|
|
55
|
+
relaton_render_config = relaton_render_path(node)
|
|
53
56
|
attrs = {
|
|
54
57
|
script: node.attr("script"),
|
|
55
58
|
bodyfont: node.attr("body-font"),
|
|
56
59
|
headerfont: node.attr("header-font"),
|
|
57
60
|
monospacefont: node.attr("monospace-font"),
|
|
58
61
|
i18nyaml: i18nyaml,
|
|
62
|
+
relatonrenderconfig: relaton_render_config,
|
|
59
63
|
scope: node.attr("scope"),
|
|
60
64
|
wordstylesheet: node.attr("wordstylesheet") || node.attr("word-stylesheet"),
|
|
61
65
|
wordstylesheet_override: node.attr("wordstylesheet-override") || node.attr("word-stylesheet-override"),
|
|
@@ -8,8 +8,7 @@ module Metanorma
|
|
|
8
8
|
image_exists(doc)
|
|
9
9
|
image_toobig(doc)
|
|
10
10
|
png_validate(doc)
|
|
11
|
-
|
|
12
|
-
# svg_validate(doc)
|
|
11
|
+
svg_validate(doc)
|
|
13
12
|
end
|
|
14
13
|
|
|
15
14
|
def image_exists(doc)
|
|
@@ -55,31 +54,62 @@ module Metanorma
|
|
|
55
54
|
end
|
|
56
55
|
end
|
|
57
56
|
|
|
57
|
+
# Use SAX for fast validation
|
|
58
58
|
def svg_validate(doc)
|
|
59
59
|
profile = SvgConform::Profiles.get(@svg_conform_profile)
|
|
60
|
-
|
|
60
|
+
validator = SvgConform::Validator.new(mode: :sax)
|
|
61
61
|
engine = SvgConform::RemediationEngine.new(profile)
|
|
62
|
-
doc.xpath("//m:svg", "m" => SVG_NS).each do |
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
svg_validate_fix(profile, engine,
|
|
62
|
+
doc.xpath("//m:svg", "m" => SVG_NS).each do |svg_element|
|
|
63
|
+
result = svg_validate1(validator, profile, svg_element)
|
|
64
|
+
if profile.remediation_count.positive? && !result.valid?
|
|
65
|
+
svg_validate_fix(validator, profile, engine, svg_element, result)
|
|
66
|
+
end
|
|
66
67
|
end
|
|
67
68
|
end
|
|
68
69
|
|
|
69
|
-
def svg_validate1(profile, svg)
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
svg_error("STANDOC_55", svg,
|
|
73
|
-
svg_error("STANDOC_57", svg,
|
|
74
|
-
|
|
70
|
+
def svg_validate1(validator, profile, svg)
|
|
71
|
+
# require "debug"; binding.b
|
|
72
|
+
result = validator.validate(svg, profile: profile)
|
|
73
|
+
svg_error("STANDOC_55", svg, result.errors)
|
|
74
|
+
svg_error("STANDOC_57", svg, result.warnings)
|
|
75
|
+
svg_reference_violations(svg, result)
|
|
76
|
+
result
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# we are ignoring external references as out of our scope to resolve;
|
|
80
|
+
# example code just in case this comes up
|
|
81
|
+
#
|
|
82
|
+
# manifest = result.reference_manifest
|
|
83
|
+
# if result.has_external_references?
|
|
84
|
+
# puts "External references found: #{result.external_references.size}"
|
|
85
|
+
# result.external_references.each do |ref|
|
|
86
|
+
# puts "#{ref.class.name}: #{ref.value}"
|
|
87
|
+
# puts " Element: #{ref.element_name} at line #{ref.line_number}"
|
|
88
|
+
# end
|
|
89
|
+
# end
|
|
90
|
+
# puts "IDs defined: #{result.available_ids.map(&:id_value).join(', ')}"
|
|
91
|
+
|
|
92
|
+
# Check for unresolved internal references
|
|
93
|
+
def svg_reference_violations(svg, result)
|
|
94
|
+
result.unresolved_internal_references&.each do |ref|
|
|
95
|
+
val = ref.value.sub(/^#/, "")
|
|
96
|
+
@doc_ids.include?(val) and next
|
|
97
|
+
@doc_anchors.include?(val) and next
|
|
98
|
+
@log.add("STANDOC_59", svg, params: [ref.value, ref.line_number])
|
|
99
|
+
end
|
|
75
100
|
end
|
|
76
101
|
|
|
77
|
-
|
|
102
|
+
# Apply remediation if needed
|
|
103
|
+
def svg_validate_fix(validator, profile, engine, svg, result)
|
|
104
|
+
# Load DOM only for remediation
|
|
105
|
+
doc = SvgConform::Document.from_content(svg.to_xml)
|
|
78
106
|
remeds = engine.apply_remediations(doc, result)
|
|
79
107
|
svg_remed_log(remeds, svg)
|
|
80
|
-
|
|
108
|
+
# Use root to avoid processing instructions that may break SAX parser
|
|
109
|
+
remediated_xml = doc.root.to_xml
|
|
110
|
+
result = validator.validate(remediated_xml, profile: profile)
|
|
81
111
|
svg_error("STANDOC_56", svg, result.errors) # we still have errors
|
|
82
|
-
svg.replace(
|
|
112
|
+
svg.replace(remediated_xml)
|
|
83
113
|
end
|
|
84
114
|
|
|
85
115
|
def svg_remed_log(remeds, svg)
|
|
@@ -94,6 +124,8 @@ module Metanorma
|
|
|
94
124
|
|
|
95
125
|
def svg_error(id, svg, errors)
|
|
96
126
|
errors.each do |err|
|
|
127
|
+
# reference violations are handled separately
|
|
128
|
+
err.violation_type == :reference_violation and next
|
|
97
129
|
err.respond_to?(:element) && err.element and
|
|
98
130
|
elem = " Element: #{err.element}"
|
|
99
131
|
err.respond_to?(:location) && err.location and
|
|
@@ -27,12 +27,24 @@ module Metanorma
|
|
|
27
27
|
def schema_validate1(file, doc, schema)
|
|
28
28
|
file.write(to_xml(doc))
|
|
29
29
|
file.close
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
30
|
+
|
|
31
|
+
# Force UTF-8 encoding for Java console output to fix Japanese Windows issue
|
|
32
|
+
# See: https://github.com/metanorma/mn-samples-plateau/issues/248
|
|
33
|
+
# The -Dsun.jnu.encoding parameter controls Java's native interface encoding (console I/O)
|
|
34
|
+
old_java_opts = ENV["_JAVA_OPTIONS"]
|
|
35
|
+
ENV["_JAVA_OPTIONS"] = "-Dfile.encoding=UTF-8 -Dsun.jnu.encoding=UTF-8"
|
|
36
|
+
|
|
37
|
+
begin
|
|
38
|
+
errors = Jing.new(schema, encoding: "UTF-8").validate(file.path)
|
|
39
|
+
warn "Syntax Valid!" if errors.none?
|
|
40
|
+
errors.each do |e|
|
|
41
|
+
@log.add("STANDOC_7",
|
|
42
|
+
"XML Line #{'%06d' % e[:line]}:#{e[:column]}",
|
|
43
|
+
params: [e[:message]])
|
|
44
|
+
end
|
|
45
|
+
ensure
|
|
46
|
+
# Restore original _JAVA_OPTIONS
|
|
47
|
+
ENV["_JAVA_OPTIONS"] = old_java_opts
|
|
36
48
|
end
|
|
37
49
|
end
|
|
38
50
|
|
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.2.
|
|
4
|
+
version: 3.2.4
|
|
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-
|
|
11
|
+
date: 2025-12-01 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: addressable
|