metanorma-generic 1.10.3 → 1.10.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/asciidoctor/generic/converter.rb +24 -20
- data/lib/asciidoctor/generic/isodoc.rng +28 -11
- data/lib/isodoc/generic/html/htmlstyle.scss +8 -0
- data/lib/metanorma/generic/version.rb +1 -1
- data/lib/metanorma/generic.rb +21 -17
- 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: fb399e7d7f6b0b778b49515a23b3c29297e0cf35b84b4da1837230ee014350fd
|
4
|
+
data.tar.gz: 4f8ae09e5df6c3385d7773f5c8a6bd489880d77955112223ce1dfbb073a66547
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0bfd36e3f4f82b021b0af8c8a318a39de2ee7af2b786f3b927523d209c10a24b49cd39bc5e34e3deb567f4b3428c4067fade47e6b3ebecf38cf4339cecc95b00
|
7
|
+
data.tar.gz: 41e61d3c2c8aa1ac1607bd0902a8ee7c6d784b4d6c354b8d543c763cec589dc9551c4264262430d96cb3a17b49ed133f7391c9256fb82bb88f2376cf3291755c
|
@@ -19,11 +19,13 @@ module Asciidoctor
|
|
19
19
|
configuration.document_namespace || XML_NAMESPACE
|
20
20
|
end
|
21
21
|
|
22
|
-
|
22
|
+
def baselocation(loc)
|
23
23
|
return nil if loc.nil?
|
24
|
+
|
24
25
|
return loc
|
25
26
|
File.expand_path(File.join(File.dirname(
|
26
|
-
|
27
|
+
self.class::_file || __FILE__,
|
28
|
+
), "..", "..", "..", loc))
|
27
29
|
end
|
28
30
|
|
29
31
|
def docidentifier_cleanup(xmldoc)
|
@@ -36,7 +38,7 @@ module Asciidoctor
|
|
36
38
|
|
37
39
|
def doctype(node)
|
38
40
|
d = super
|
39
|
-
configuration.doctypes or return d == "article" ?
|
41
|
+
configuration.doctypes or return d == "article" ?
|
40
42
|
(configuration.default_doctype || "standard") : d
|
41
43
|
type = configuration.default_doctype ||
|
42
44
|
configuration.doctypes.keys.dig(0) || "standard"
|
@@ -49,18 +51,18 @@ module Asciidoctor
|
|
49
51
|
end
|
50
52
|
|
51
53
|
def read_config_file(path_to_config_file)
|
52
|
-
Metanorma::Generic.configuration
|
53
|
-
set_default_values_from_yaml_file(path_to_config_file)
|
54
|
+
Metanorma::Generic.configuration
|
55
|
+
.set_default_values_from_yaml_file(path_to_config_file)
|
54
56
|
end
|
55
57
|
|
56
58
|
def sectiontype_streamline(ret)
|
57
|
-
if configuration&.termsdefs_titles&.map(&:downcase)&.include?
|
59
|
+
if configuration&.termsdefs_titles&.map(&:downcase)&.include? ret
|
58
60
|
"terms and definitions"
|
59
|
-
elsif configuration&.symbols_titles&.map(&:downcase)&.include?
|
61
|
+
elsif configuration&.symbols_titles&.map(&:downcase)&.include? ret
|
60
62
|
"symbols and abbreviated terms"
|
61
|
-
elsif configuration&.normref_titles&.map(&:downcase)&.include?
|
63
|
+
elsif configuration&.normref_titles&.map(&:downcase)&.include? ret
|
62
64
|
"normative references"
|
63
|
-
elsif configuration&.bibliography_titles&.map(&:downcase)&.include?
|
65
|
+
elsif configuration&.bibliography_titles&.map(&:downcase)&.include? ret
|
64
66
|
"bibliography"
|
65
67
|
else
|
66
68
|
ret
|
@@ -73,15 +75,14 @@ module Asciidoctor
|
|
73
75
|
end
|
74
76
|
|
75
77
|
def outputs(node, ret)
|
76
|
-
File.open(@filename
|
77
|
-
presentation_xml_converter(node)&.convert(@filename
|
78
|
-
html_converter(node)&.convert(@filename
|
78
|
+
File.open("#{@filename}.xml", "w:UTF-8") { |f| f.write(ret) }
|
79
|
+
presentation_xml_converter(node)&.convert("#{@filename}.xml")
|
80
|
+
html_converter(node)&.convert("#{@filename}.presentation.xml",
|
79
81
|
nil, false, "#{@filename}.html")
|
80
|
-
doc_converter(node)&.convert(@filename
|
82
|
+
doc_converter(node)&.convert("#{@filename}.presentation.xml",
|
81
83
|
nil, false, "#{@filename}.doc")
|
82
|
-
pdf_converter(node)&.convert(@filename
|
84
|
+
pdf_converter(node)&.convert("#{@filename}.presentation.xml",
|
83
85
|
nil, false, "#{@filename}.pdf")
|
84
|
-
|
85
86
|
end
|
86
87
|
|
87
88
|
def validate(doc)
|
@@ -106,7 +107,8 @@ module Asciidoctor
|
|
106
107
|
stages.empty? and return
|
107
108
|
stage = xmldoc&.at("//bibdata/status/stage")&.text
|
108
109
|
stages.include? stage or
|
109
|
-
@log.add("Document Attributes", nil,
|
110
|
+
@log.add("Document Attributes", nil,
|
111
|
+
"#{stage} is not a recognised status")
|
110
112
|
end
|
111
113
|
|
112
114
|
def committee_validate(xmldoc)
|
@@ -114,13 +116,14 @@ module Asciidoctor
|
|
114
116
|
committees.empty? and return
|
115
117
|
xmldoc.xpath("//bibdata/ext/editorialgroup/committee").each do |c|
|
116
118
|
committees.include? c.text or
|
117
|
-
@log.add("Document Attributes", nil,
|
119
|
+
@log.add("Document Attributes", nil,
|
120
|
+
"#{c.text} is not a recognised committee")
|
118
121
|
end
|
119
122
|
end
|
120
123
|
|
121
|
-
def sections_cleanup(
|
124
|
+
def sections_cleanup(xml)
|
122
125
|
super
|
123
|
-
|
126
|
+
xml.xpath("//*[@inline-header]").each do |h|
|
124
127
|
h.delete("inline-header")
|
125
128
|
end
|
126
129
|
end
|
@@ -132,7 +135,8 @@ module Asciidoctor
|
|
132
135
|
end
|
133
136
|
|
134
137
|
def presentation_xml_converter(node)
|
135
|
-
IsoDoc::Generic::PresentationXMLConvert
|
138
|
+
IsoDoc::Generic::PresentationXMLConvert
|
139
|
+
.new(html_extract_attributes(node))
|
136
140
|
end
|
137
141
|
|
138
142
|
alias_method :pdf_converter, :html_converter
|
@@ -170,15 +170,17 @@
|
|
170
170
|
<data type="boolean"/>
|
171
171
|
</attribute>
|
172
172
|
</optional>
|
173
|
-
<
|
174
|
-
<
|
175
|
-
<
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
173
|
+
<optional>
|
174
|
+
<attribute name="type">
|
175
|
+
<choice>
|
176
|
+
<value>roman</value>
|
177
|
+
<value>alphabet</value>
|
178
|
+
<value>arabic</value>
|
179
|
+
<value>roman_upper</value>
|
180
|
+
<value>alphabet_upper</value>
|
181
|
+
</choice>
|
182
|
+
</attribute>
|
183
|
+
</optional>
|
182
184
|
<oneOrMore>
|
183
185
|
<ref name="li"/>
|
184
186
|
</oneOrMore>
|
@@ -988,6 +990,16 @@
|
|
988
990
|
<data type="boolean"/>
|
989
991
|
</attribute>
|
990
992
|
</optional>
|
993
|
+
<optional>
|
994
|
+
<attribute name="linkmention">
|
995
|
+
<data type="boolean"/>
|
996
|
+
</attribute>
|
997
|
+
</optional>
|
998
|
+
<optional>
|
999
|
+
<attribute name="linkref">
|
1000
|
+
<data type="boolean"/>
|
1001
|
+
</attribute>
|
1002
|
+
</optional>
|
991
1003
|
<optional>
|
992
1004
|
<element name="refterm">
|
993
1005
|
<zeroOrMore>
|
@@ -1698,7 +1710,9 @@
|
|
1698
1710
|
<zeroOrMore>
|
1699
1711
|
<ref name="termgrammar"/>
|
1700
1712
|
</zeroOrMore>
|
1701
|
-
<
|
1713
|
+
<oneOrMore>
|
1714
|
+
<ref name="termdefinition"/>
|
1715
|
+
</oneOrMore>
|
1702
1716
|
<zeroOrMore>
|
1703
1717
|
<ref name="termnote"/>
|
1704
1718
|
</zeroOrMore>
|
@@ -1761,7 +1775,7 @@
|
|
1761
1775
|
</oneOrMore>
|
1762
1776
|
</element>
|
1763
1777
|
</define>
|
1764
|
-
<define name="
|
1778
|
+
<define name="termdefinition">
|
1765
1779
|
<element name="definition">
|
1766
1780
|
<oneOrMore>
|
1767
1781
|
<choice>
|
@@ -1770,6 +1784,9 @@
|
|
1770
1784
|
<ref name="formula"/>
|
1771
1785
|
</choice>
|
1772
1786
|
</oneOrMore>
|
1787
|
+
<zeroOrMore>
|
1788
|
+
<ref name="termsource"/>
|
1789
|
+
</zeroOrMore>
|
1773
1790
|
</element>
|
1774
1791
|
</define>
|
1775
1792
|
<define name="termnote">
|
data/lib/metanorma/generic.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
require "metanorma/generic/processor"
|
2
2
|
require "metanorma/generic/version"
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require "forwardable"
|
4
|
+
require "yaml"
|
5
5
|
|
6
6
|
module Metanorma
|
7
7
|
module Generic
|
8
8
|
ORGANIZATION_NAME_SHORT = "Acme"
|
9
9
|
ORGANIZATION_NAME_LONG = "Acme Corp."
|
10
10
|
DOCUMENT_NAMESPACE = "https://www.metanorma.org/ns/generic"
|
11
|
-
YAML_CONFIG_FILE =
|
11
|
+
YAML_CONFIG_FILE = "metanorma.yml"
|
12
12
|
|
13
13
|
class Configuration
|
14
14
|
CONFIG_ATTRS = %i[
|
@@ -63,7 +63,7 @@ module Metanorma
|
|
63
63
|
].freeze
|
64
64
|
|
65
65
|
def filepath_attrs
|
66
|
-
|
66
|
+
%i[
|
67
67
|
i18nyaml
|
68
68
|
boilerplate
|
69
69
|
logo_path
|
@@ -88,24 +88,26 @@ module Metanorma
|
|
88
88
|
attr_accessor :_file
|
89
89
|
end
|
90
90
|
|
91
|
-
def self.inherited(
|
92
|
-
|
91
|
+
def self.inherited(klass)
|
92
|
+
klass._file = caller_locations(1..1).first.absolute_path
|
93
93
|
end
|
94
94
|
|
95
95
|
def initialize(*args)
|
96
96
|
super
|
97
97
|
# Try to set config values from yaml file in current directory
|
98
|
-
@yaml = File.join(File.dirname(self.class::_file || __FILE__), "..",
|
98
|
+
@yaml = File.join(File.dirname(self.class::_file || __FILE__), "..",
|
99
|
+
"..", YAML_CONFIG_FILE)
|
99
100
|
set_default_values_from_yaml_file(@yaml) if File.file?(@yaml)
|
100
101
|
self.organization_name_short ||= ORGANIZATION_NAME_SHORT
|
101
102
|
self.organization_name_long ||= ORGANIZATION_NAME_LONG
|
102
103
|
self.document_namespace ||= DOCUMENT_NAMESPACE
|
103
|
-
self.termsdefs_titles ||=
|
104
|
+
self.termsdefs_titles ||=
|
104
105
|
["Terms and definitions", "Terms, definitions, symbols and abbreviated terms",
|
105
106
|
"Terms, definitions, symbols and abbreviations", "Terms, definitions and symbols",
|
106
107
|
"Terms, definitions and abbreviations", "Terms, definitions and abbreviated terms"]
|
107
108
|
self.symbols_titles ||=
|
108
|
-
["Symbols and abbreviated terms", "Symbols", "Abbreviated terms",
|
109
|
+
["Symbols and abbreviated terms", "Symbols", "Abbreviated terms",
|
110
|
+
"Abbreviations"]
|
109
111
|
self.normref_titles ||=
|
110
112
|
["Normative references"]
|
111
113
|
self.bibliography_titles ||= ["Bibliography"]
|
@@ -114,9 +116,11 @@ module Metanorma
|
|
114
116
|
def set_default_values_from_yaml_file(config_file)
|
115
117
|
root_path = File.dirname(self.class::_file || __FILE__)
|
116
118
|
default_config_options = YAML.load(File.read(config_file))
|
117
|
-
if default_config_options["doctypes"]
|
118
|
-
default_config_options["doctypes"] =
|
119
|
-
each_with_object({})
|
119
|
+
if default_config_options["doctypes"].is_a? Array
|
120
|
+
default_config_options["doctypes"] =
|
121
|
+
default_config_options["doctypes"].each_with_object({}) do |k, m|
|
122
|
+
m[k] = nil
|
123
|
+
end
|
120
124
|
end
|
121
125
|
CONFIG_ATTRS.each do |attr_name|
|
122
126
|
value = default_config_options[attr_name.to_s]
|
@@ -128,8 +132,8 @@ module Metanorma
|
|
128
132
|
end
|
129
133
|
end
|
130
134
|
|
131
|
-
def blank?(
|
132
|
-
|
135
|
+
def blank?(val)
|
136
|
+
val.nil? || val.respond_to?(:empty?) && val.empty?
|
133
137
|
end
|
134
138
|
|
135
139
|
def absolute_path(value, root_path)
|
@@ -145,14 +149,14 @@ module Metanorma
|
|
145
149
|
end
|
146
150
|
end
|
147
151
|
|
148
|
-
def absolute_path1(
|
149
|
-
|
152
|
+
def absolute_path1(hash, pref)
|
153
|
+
hash.reject { |_k, v| blank?(v) }
|
154
|
+
.each_with_object({}) do |(k, v), g|
|
150
155
|
g[k] = absolute_path(v, pref)
|
151
156
|
end
|
152
157
|
end
|
153
158
|
end
|
154
159
|
|
155
|
-
|
156
160
|
class << self
|
157
161
|
extend Forwardable
|
158
162
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metanorma-generic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.10.
|
4
|
+
version: 1.10.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-09-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: htmlentities
|