metanorma-generic 2.6.5 → 2.7.1

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: 362b19c7415032ba198d240f6c5a68be9b78940805adf49dc2a326c367ef5b85
4
- data.tar.gz: 75c6592984d97612670ea424b475497a5d0b63e13c05971944cf7cf476b9ba9d
3
+ metadata.gz: bd710f710d4ac3b76fed5d6f647c2fec15372b84f2d86e01380a310b5d772db5
4
+ data.tar.gz: bf48530b643adc2078b880f6913df915bc8c6696d727e792baac2014f7605bb7
5
5
  SHA512:
6
- metadata.gz: d700d636ee17e775efa41fe6b3ffca21c1ebee6cc3e05b88854836ae8ca3209ce5aef30cc0163091e0b34dc8bf7d41d7530b43f9df168369bc7fc9e4c0aac818
7
- data.tar.gz: 71b1247e84c43031bb4ff5dae8a9a44bb8b7d717b8a512f8e9b6f6541746f252b953876a3c4bbe4a1cf070405ac77e8e3340650015cccc4b5071b0d5b5880e7d
6
+ metadata.gz: 8d45aca2e37d6987437b9cb12f287740d05a5c209c3f01f249b3ffa266995303cf62db2e391d10904344271da4058fb8b21ba6dcb228d600a88bb7dc134aeed6
7
+ data.tar.gz: c4f75e08a3ffe7f68dde7076fa94cb7209f1345a41fe423750e6110aebf5efd7676913998576dd594a72008157e2545d8e25c847ca19ba873330173f9edb878f
@@ -0,0 +1,21 @@
1
+ require_relative "base_convert"
2
+ require "metanorma-generic"
3
+ require "isodoc"
4
+
5
+ module IsoDoc
6
+ module Generic
7
+ class PdfConvert < IsoDoc::XslfoPdfConvert
8
+ def initialize(options)
9
+ @libdir = File.dirname(__FILE__)
10
+ super
11
+ end
12
+
13
+ def pdf_stylesheet(docxml)
14
+ configuration.pdf_stylesheet
15
+ end
16
+
17
+ include BaseConvert
18
+ include Init
19
+ end
20
+ end
21
+ end
@@ -1,6 +1,7 @@
1
1
  require "isodoc/generic/metadata"
2
2
  require "isodoc/generic/html_convert"
3
3
  require "isodoc/generic/word_convert"
4
+ require "isodoc/generic/pdf_convert"
4
5
  require "isodoc/generic/presentation_xml_convert"
5
6
 
6
7
  module IsoDoc
@@ -1000,14 +1000,14 @@
1000
1000
  <define name="PureTextElement">
1001
1001
  <choice>
1002
1002
  <text/>
1003
- <ref name="em"/>
1004
- <ref name="strong"/>
1003
+ <ref name="pure_em"/>
1004
+ <ref name="pure_strong"/>
1005
1005
  <ref name="sub"/>
1006
1006
  <ref name="sup"/>
1007
- <ref name="tt"/>
1008
- <ref name="underline"/>
1009
- <ref name="strike"/>
1010
- <ref name="smallcap"/>
1007
+ <ref name="pure_tt"/>
1008
+ <ref name="pure_underline"/>
1009
+ <ref name="pure_strike"/>
1010
+ <ref name="pure_smallcap"/>
1011
1011
  <ref name="br"/>
1012
1012
  </choice>
1013
1013
  </define>
@@ -1031,6 +1031,13 @@
1031
1031
  </zeroOrMore>
1032
1032
  </element>
1033
1033
  </define>
1034
+ <define name="pure_em">
1035
+ <element name="em">
1036
+ <zeroOrMore>
1037
+ <ref name="PureTextElement"/>
1038
+ </zeroOrMore>
1039
+ </element>
1040
+ </define>
1034
1041
  <define name="strong">
1035
1042
  <element name="strong">
1036
1043
  <zeroOrMore>
@@ -1046,6 +1053,13 @@
1046
1053
  </zeroOrMore>
1047
1054
  </element>
1048
1055
  </define>
1056
+ <define name="pure_strong">
1057
+ <element name="strong">
1058
+ <zeroOrMore>
1059
+ <ref name="PureTextElement"/>
1060
+ </zeroOrMore>
1061
+ </element>
1062
+ </define>
1049
1063
  <define name="tt">
1050
1064
  <element name="tt">
1051
1065
  <zeroOrMore>
@@ -1060,6 +1074,13 @@
1060
1074
  </zeroOrMore>
1061
1075
  </element>
1062
1076
  </define>
1077
+ <define name="pure_tt">
1078
+ <element name="tt">
1079
+ <zeroOrMore>
1080
+ <ref name="PureTextElement"/>
1081
+ </zeroOrMore>
1082
+ </element>
1083
+ </define>
1063
1084
  <define name="keyword">
1064
1085
  <element name="keyword">
1065
1086
  <zeroOrMore>
@@ -1090,13 +1111,42 @@
1090
1111
  <zeroOrMore>
1091
1112
  <choice>
1092
1113
  <ref name="PureTextElement"/>
1114
+ <ref name="stem"/>
1115
+ <ref name="eref"/>
1116
+ <ref name="xref"/>
1117
+ <ref name="hyperlink"/>
1093
1118
  <ref name="index"/>
1094
1119
  <ref name="index-xref"/>
1095
1120
  </choice>
1096
1121
  </zeroOrMore>
1097
1122
  </element>
1098
1123
  </define>
1124
+ <define name="pure_strike">
1125
+ <element name="strike">
1126
+ <zeroOrMore>
1127
+ <ref name="PureTextElement"/>
1128
+ </zeroOrMore>
1129
+ </element>
1130
+ </define>
1099
1131
  <define name="underline">
1132
+ <element name="underline">
1133
+ <optional>
1134
+ <attribute name="style"/>
1135
+ </optional>
1136
+ <zeroOrMore>
1137
+ <choice>
1138
+ <ref name="PureTextElement"/>
1139
+ <ref name="stem"/>
1140
+ <ref name="eref"/>
1141
+ <ref name="xref"/>
1142
+ <ref name="hyperlink"/>
1143
+ <ref name="index"/>
1144
+ <ref name="index-xref"/>
1145
+ </choice>
1146
+ </zeroOrMore>
1147
+ </element>
1148
+ </define>
1149
+ <define name="pure_underline">
1100
1150
  <element name="underline">
1101
1151
  <optional>
1102
1152
  <attribute name="style"/>
@@ -1107,6 +1157,21 @@
1107
1157
  </element>
1108
1158
  </define>
1109
1159
  <define name="smallcap">
1160
+ <element name="smallcap">
1161
+ <zeroOrMore>
1162
+ <choice>
1163
+ <ref name="PureTextElement"/>
1164
+ <ref name="stem"/>
1165
+ <ref name="eref"/>
1166
+ <ref name="xref"/>
1167
+ <ref name="hyperlink"/>
1168
+ <ref name="index"/>
1169
+ <ref name="index-xref"/>
1170
+ </choice>
1171
+ </zeroOrMore>
1172
+ </element>
1173
+ </define>
1174
+ <define name="pure_smallcap">
1110
1175
  <element name="smallcap">
1111
1176
  <zeroOrMore>
1112
1177
  <ref name="PureTextElement"/>
@@ -1204,7 +1204,9 @@
1204
1204
  <optional>
1205
1205
  <ref name="formattedref"/>
1206
1206
  </optional>
1207
- <ref name="btitle"/>
1207
+ <oneOrMore>
1208
+ <ref name="btitle"/>
1209
+ </oneOrMore>
1208
1210
  <optional>
1209
1211
  <ref name="bplace"/>
1210
1212
  </optional>
@@ -2,6 +2,8 @@ require "asciidoctor"
2
2
  require "metanorma/standoc/converter"
3
3
  require "fileutils"
4
4
  require_relative "front"
5
+ require "metanorma"
6
+ require "pathname"
5
7
 
6
8
  module Metanorma
7
9
  module Generic
@@ -20,20 +22,17 @@ module Metanorma
20
22
  end
21
23
 
22
24
  def baselocation(loc)
23
- return nil if loc.nil?
24
-
25
+ loc.nil? and return nil
25
26
  return loc
26
- File.expand_path(File.join(File.dirname(
27
- self.class::_file || __FILE__,
28
- ), "..", "..", "..", loc))
29
27
  end
30
28
 
31
29
  def docidentifier_cleanup(xmldoc)
30
+ b = boilerplate_isodoc(xmldoc) or return
32
31
  template = configuration.docid_template ||
33
32
  "{{ organization_name_short }} {{ docnumeric }}"
34
33
  docid = xmldoc.at("//bibdata/docidentifier")
35
34
  docid&.text&.empty? or return
36
- id = boilerplate_isodoc(xmldoc).populate_template(template, nil)
35
+ id = b.populate_template(template, nil)
37
36
  (id.empty? and docid.remove) or docid.children = id
38
37
  end
39
38
 
@@ -58,6 +57,10 @@ module Metanorma
58
57
  def read_config_file(path_to_config_file)
59
58
  Metanorma::Generic.configuration
60
59
  .set_default_values_from_yaml_file(path_to_config_file)
60
+ # reregister Processor to Metanorma with updated values
61
+ if defined? Metanorma::Registry
62
+ Metanorma::Registry.instance.register(Metanorma::Generic::Processor)
63
+ end
61
64
  end
62
65
 
63
66
  def sectiontype_streamline(ret)
@@ -75,7 +78,12 @@ module Metanorma
75
78
  end
76
79
 
77
80
  def document(node)
78
- read_config_file(node.attr("customize")) if node.attr("customize")
81
+ if node.attr("customize")
82
+ p = node.attr("customize")
83
+ (Pathname.new p).absolute? or
84
+ p = File.expand_path(File.join(Metanorma::Utils::localdir(node), p))
85
+ read_config_file(p)
86
+ end
79
87
  super
80
88
  end
81
89
 
@@ -158,7 +166,7 @@ module Metanorma
158
166
  end
159
167
 
160
168
  def boilerplate_isodoc(xmldoc)
161
- conv = super
169
+ conv = super or return nil
162
170
  Metanorma::Generic::Configuration::CONFIG_ATTRS.each do |a|
163
171
  conv.meta.set(a, configuration.send(a))
164
172
  end
@@ -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.3.2 -->
20
+ <!-- VERSION v1.3.3 -->
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">
@@ -331,9 +331,9 @@
331
331
  <zeroOrMore>
332
332
  <ref name="table-note"/>
333
333
  </zeroOrMore>
334
- <optional>
334
+ <zeroOrMore>
335
335
  <ref name="source"/>
336
- </optional>
336
+ </zeroOrMore>
337
337
  </define>
338
338
  <define name="FigureAttr">
339
339
  <optional>
@@ -380,9 +380,9 @@
380
380
  <zeroOrMore>
381
381
  <ref name="note"/>
382
382
  </zeroOrMore>
383
- <optional>
383
+ <zeroOrMore>
384
384
  <ref name="source"/>
385
- </optional>
385
+ </zeroOrMore>
386
386
  </define>
387
387
  <define name="source">
388
388
  <element name="source">
@@ -662,6 +662,9 @@
662
662
  <value>LatexMath</value>
663
663
  </choice>
664
664
  </attribute>
665
+ <optional>
666
+ <attribute name="number-format"/>
667
+ </optional>
665
668
  <attribute name="block">
666
669
  <data type="boolean"/>
667
670
  </attribute>
@@ -15,10 +15,11 @@ module Metanorma
15
15
  end
16
16
 
17
17
  def output_formats
18
- super.merge(
19
- html: "html",
20
- doc: "doc",
21
- )
18
+ configuration.formats
19
+ end
20
+
21
+ def fonts_manifest
22
+ configuration&.fonts_manifest
22
23
  end
23
24
 
24
25
  def version
@@ -66,6 +66,9 @@
66
66
  <ref name="MultilingualRenderingType"/>
67
67
  </attribute>
68
68
  </optional>
69
+ <optional>
70
+ <attribute name="class"/>
71
+ </optional>
69
72
  <optional>
70
73
  <ref name="reqtitle"/>
71
74
  </optional>
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Generic
3
- VERSION = "2.6.5".freeze
3
+ VERSION = "2.7.1".freeze
4
4
  end
5
5
  end
@@ -10,6 +10,10 @@ module Metanorma
10
10
  DOCUMENT_NAMESPACE = "https://www.metanorma.org/ns/generic"
11
11
  YAML_CONFIG_FILE = "metanorma.yml"
12
12
 
13
+ class DummyProcessor < ::Metanorma::Processor
14
+ def initialize; end # rubocop:disable Lint/MissingSuper
15
+ end
16
+
13
17
  class Configuration
14
18
  CONFIG_ATTRS = %i[
15
19
  organization_name_short
@@ -21,6 +25,7 @@ module Metanorma
21
25
  docid_template
22
26
  doctypes
23
27
  default_doctype
28
+ fonts_manifest
24
29
  i18nyaml
25
30
  logo_path
26
31
  logo_paths
@@ -60,13 +65,15 @@ module Metanorma
60
65
  word_smallerfontsize
61
66
  word_footnotefontsize
62
67
  xml_root_tag
68
+ pdf_stylesheet
69
+ formats
63
70
  ].freeze
64
71
 
65
72
  def filepath_attrs
66
- %i[i18nyaml boilerplate logo_path logo_paths header
73
+ %i[i18nyaml boilerplate logo_path logo_paths header boilerplate
67
74
  htmlcoverpage htmlintropage htmlstylesheet scripts scripts_pdf
68
75
  standardstylesheet validate_rng_file wordcoverpage wordintropage
69
- wordstylesheet]
76
+ wordstylesheet pdf_stylesheet]
70
77
  end
71
78
 
72
79
  attr_accessor(*CONFIG_ATTRS)
@@ -84,11 +91,31 @@ module Metanorma
84
91
  # Try to set config values from yaml file in current directory
85
92
  @yaml = File.join(File.dirname(self.class::_file || __FILE__), "..",
86
93
  "..", YAML_CONFIG_FILE)
87
- set_default_values_from_yaml_file(@yaml) if File.file?(@yaml)
94
+ set_default_values_from_yaml_file(@yaml)
95
+ end
96
+
97
+ # may be invoked multiple times, needs to not overwrite
98
+ def postprocess_defaults
99
+ default_org
100
+ default_formats
101
+ default_titles
102
+ end
103
+
104
+ def default_org
88
105
  self.organization_name_short ||= ORGANIZATION_NAME_SHORT
89
106
  self.organization_name_long ||= ORGANIZATION_NAME_LONG
90
107
  self.document_namespace ||= DOCUMENT_NAMESPACE
91
- default_titles
108
+ end
109
+
110
+ # convert array to hash; if already is hash (no override in customize),
111
+ # don't reconvert
112
+ def default_formats
113
+ formats.is_a?(Hash) and return
114
+ self.formats ||= %w(html doc)
115
+ self.formats = self.formats.each_with_object({}) do |k, m|
116
+ m[k.to_sym] = k
117
+ end
118
+ self.formats.merge! DummyProcessor.new.output_formats
92
119
  end
93
120
 
94
121
  def default_titles
@@ -105,18 +132,26 @@ module Metanorma
105
132
  end
106
133
 
107
134
  def set_default_values_from_yaml_file(config_file)
108
- root_path, default_config_options =
109
- set_default_values_from_yaml_file_prep(config_file)
110
- CONFIG_ATTRS.each do |attr_name|
111
- value = default_config_options[attr_name.to_s]
112
- value && filepath_attrs.include?(attr_name) and
113
- value = absolute_path(value, root_path)
114
- instance_variable_set("@#{attr_name}", value)
135
+ if File.file?(config_file)
136
+ root_path, default_config_options =
137
+ set_default_values_from_yaml_file_prep(config_file)
138
+ CONFIG_ATTRS.each do |attr|
139
+ set_default_value_from_yaml_file(attr, root_path,
140
+ default_config_options)
141
+ end
115
142
  end
143
+ postprocess_defaults
144
+ end
145
+
146
+ def set_default_value_from_yaml_file(attr, root_path, default_options)
147
+ value = default_options[attr.to_s]
148
+ value && filepath_attrs.include?(attr) and
149
+ value = absolute_path(value, root_path)
150
+ instance_variable_set("@#{attr}", value)
116
151
  end
117
152
 
118
153
  def set_default_values_from_yaml_file_prep(config_file)
119
- root_path = File.dirname(self.class::_file || __FILE__)
154
+ root_path = File.dirname(config_file)
120
155
  default_config_options =
121
156
  YAML.safe_load(File.read(config_file, encoding: "UTF-8"))
122
157
  default_config_options["doctypes"].is_a? Array and
@@ -132,13 +167,14 @@ module Metanorma
132
167
  end
133
168
 
134
169
  def absolute_path(value, root_path)
135
- if value.is_a? Hash then absolute_path1(value, root_path)
136
- elsif value.is_a? Array
137
- value.reject { |a| blank?(a) }.each_with_object([]) do |v1, g|
138
- g << absolute_path(v1, root_path)
170
+ case value
171
+ when Hash then absolute_path1(value, root_path)
172
+ when Array then absolute_path1_array(value, root_path)
173
+ when String
174
+ if !value.empty? && !Pathname.new(value).absolute?
175
+ Pathname.new(File.join(root_path, value)).cleanpath.to_s
176
+ else value
139
177
  end
140
- elsif value.is_a?(String) && !value.empty?
141
- File.join(root_path, "..", "..", value)
142
178
  else value
143
179
  end
144
180
  end
@@ -148,6 +184,12 @@ module Metanorma
148
184
  absolute_path(v, pref)
149
185
  end
150
186
  end
187
+
188
+ def absolute_path1_array(value, pref)
189
+ value.reject { |a| blank?(a) }.each_with_object([]) do |v1, g|
190
+ g << absolute_path(v1, pref)
191
+ end
192
+ end
151
193
  end
152
194
 
153
195
  class << self
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
27
27
  spec.require_paths = ["lib"]
28
28
  spec.required_ruby_version = Gem::Requirement.new(">= 3.1.0")
29
29
 
30
- spec.add_dependency "metanorma-standoc", "~> 2.9.0"
30
+ spec.add_dependency "metanorma-standoc", "~> 2.9.3"
31
31
 
32
32
  spec.add_development_dependency "debug"
33
33
  spec.add_development_dependency "equivalent-xml", "~> 0.6"
@@ -39,4 +39,5 @@ Gem::Specification.new do |spec|
39
39
  spec.add_development_dependency "sassc", "2.4.0"
40
40
  spec.add_development_dependency "simplecov", "~> 0.15"
41
41
  spec.add_development_dependency "timecop", "~> 0.9"
42
+ spec.add_development_dependency "xml-c14n"
42
43
  end
@@ -8,6 +8,10 @@ logo_paths:
8
8
  - /metanorma-mine/lib/isodoc/mine/html/logo1.jpg
9
9
  - /metanorma-mine/lib/isodoc/mine/html/logo2.jpg
10
10
  validate_rng_file: /metanorma-mine/lib/metanorma/mine/mine.rng
11
+ formats:
12
+ - html
13
+ - pdf
14
+ - doc
11
15
  htmlcoverpage: /metanorma-mine/lib/isodoc/mine/html/html_mine_titlepage.html
12
16
  htmlintropage: /metanorma-mine/lib/isodoc/mine/html/html_mine_intro.html
13
17
  htmlstylesheet: /metanorma-mine/lib/isodoc/mine/html/htmlstyle.scss
@@ -25,6 +29,7 @@ header: /metanorma-mine/lib/isodoc/mine/html/header.html
25
29
  wordcoverpage: /metanorma-mine/lib/isodoc/mine/html/word_mine_titlepage.html
26
30
  wordintropage: /metanorma-mine/lib/isodoc/mine/html/word_mine_intro.html
27
31
  wordstylesheet: /metanorma-mine/lib/isodoc/mine/html/wordstyle.scss
32
+ pdf_stylesheet: /metanorma-mine/lib/isodoc/mine/html/mine.xsl
28
33
  word_bodyfont: '"Source Sans Pro","Arial",sans-serif'
29
34
  word_headerfont: '"Source Sans Pro","Arial",sans-serif'
30
35
  word_monospacefont: '"Source Code Pro",monospace'
@@ -72,3 +77,6 @@ normref_titles:
72
77
  - Normative references
73
78
  bibliography_titles:
74
79
  - Bibliography
80
+ fonts_manifest:
81
+ Font1:
82
+ Font2:
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: 2.6.5
4
+ version: 2.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-07-08 00:00:00.000000000 Z
11
+ date: 2024-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: metanorma-standoc
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 2.9.0
19
+ version: 2.9.3
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 2.9.0
26
+ version: 2.9.3
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: debug
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -164,6 +164,20 @@ dependencies:
164
164
  - - "~>"
165
165
  - !ruby/object:Gem::Version
166
166
  version: '0.9'
167
+ - !ruby/object:Gem::Dependency
168
+ name: xml-c14n
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
167
181
  description: |
168
182
  Metanorma template gem for customisation. This gem is meant to be customised for any downstream use.
169
183
 
@@ -201,6 +215,7 @@ files:
201
215
  - lib/isodoc/generic/i18n.rb
202
216
  - lib/isodoc/generic/init.rb
203
217
  - lib/isodoc/generic/metadata.rb
218
+ - lib/isodoc/generic/pdf_convert.rb
204
219
  - lib/isodoc/generic/presentation_xml_convert.rb
205
220
  - lib/isodoc/generic/utils.rb
206
221
  - lib/isodoc/generic/word_convert.rb