metanorma-generic 1.7.3 → 1.10.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -25,14 +25,18 @@ module IsoDoc
25
25
  def default_fonts(options)
26
26
  {
27
27
  bodyfont: (
28
- options[:script] == "Hans" ? '"SimSun",serif' :
28
+ options[:script] == "Hans" ? '"Source Han Sans",serif' :
29
29
  configuration.html_bodyfont || '"Overpass",sans-serif'
30
30
  ),
31
31
  headerfont: (
32
- options[:script] == "Hans" ? '"SimHei",sans-serif' :
32
+ options[:script] == "Hans" ? '"Source Han Sans",sans-serif' :
33
33
  configuration.html_headerfont || '"Overpass",sans-serif'
34
34
  ),
35
- monospacefont: configuration.html_monospacefont || '"Space Mono",monospace'
35
+ monospacefont: configuration.html_monospacefont || '"Space Mono",monospace',
36
+ normalfontsize: configuration.html_normalfontsize,
37
+ smallerfontsize: configuration.html_smallerfontsize,
38
+ footnotefontsize: configuration.html_footnotefontsize,
39
+ monospacefontsize: configuration.html_monospacefontsize,
36
40
  }.transform_values { |v| v&.empty? ? nil : v }
37
41
  end
38
42
 
@@ -44,19 +48,12 @@ module IsoDoc
44
48
  html_doc_path("html_generic_titlepage.html"),
45
49
  htmlintropage: baselocation(configuration.htmlintropage) ||
46
50
  html_doc_path("html_generic_intro.html"),
47
- scripts: baselocation(configuration.scripts) ||
48
- html_doc_path("scripts.html"),
51
+ scripts: baselocation(configuration.scripts),
49
52
  i18nyaml: (configuration.i18nyaml.is_a?(String) ?
50
53
  baselocation(configuration.i18nyaml) : nil)
51
54
  }.transform_values { |v| v&.empty? ? nil : v }
52
55
  end
53
56
 
54
- =begin
55
- def configuration
56
- Metanorma::Generic.configuration
57
- end
58
- =end
59
-
60
57
  def googlefonts
61
58
  return unless configuration.webfont
62
59
  Array(configuration.webfont).map do |x|
@@ -22,9 +22,9 @@ module IsoDoc
22
22
 
23
23
  def default_fonts(options)
24
24
  {
25
- bodyfont: (options[:script] == "Hans" ? '"SimSun",serif'
25
+ bodyfont: (options[:script] == "Hans" ? '"Source Han Sans",serif'
26
26
  : configuration.html_bodyfont || '"Overpass",sans-serif'),
27
- headerfont: (options[:script] == "Hans" ? '"SimHei",sans-serif' :
27
+ headerfont: (options[:script] == "Hans" ? '"Source Han Sans",sans-serif' :
28
28
  configuration.html_headerfont || '"Overpass",sans-serif'),
29
29
  monospacefont: configuration.html_monospacefont || '"Space Mono",monospace'
30
30
  }.transform_values { |v| v&.empty? ? nil : v }
@@ -12,6 +12,7 @@ module IsoDoc
12
12
  def baselocation(loc)
13
13
  return nil if loc.nil?
14
14
  return "" if loc.empty?
15
+ return loc
15
16
  f = defined?(self.class::_file) ? (self.class::_file || __FILE__) :
16
17
  __FILE__
17
18
  File.expand_path(File.join(
@@ -24,14 +24,18 @@ module IsoDoc
24
24
  def default_fonts(options)
25
25
  {
26
26
  bodyfont: (
27
- options[:script] == "Hans" ? '"SimSun",serif' :
27
+ options[:script] == "Hans" ? '"Source Han Sans",serif' :
28
28
  configuration.word_bodyfont || '"Arial",sans-serif'
29
29
  ),
30
30
  headerfont: (
31
- options[:script] == "Hans" ? '"SimHei",sans-serif' :
31
+ options[:script] == "Hans" ? '"Source Han Sans",sans-serif' :
32
32
  configuration.word_headerfont || '"Arial",sans-serif'
33
33
  ),
34
- monospacefont: configuration.word_monospacefont || '"Courier New",monospace'
34
+ monospacefont: configuration.word_monospacefont || '"Courier New",monospace',
35
+ normalfontsize: configuration.word_normalfontsize,
36
+ smallerfontsize: configuration.word_smallerfontsize,
37
+ footnotefontsize: configuration.word_footnotefontsize,
38
+ monospacefontsize: configuration.word_monospacefontsize,
35
39
  }.transform_values { |v| v&.empty? ? nil : v }
36
40
  end
37
41
 
@@ -31,6 +31,10 @@ module Metanorma
31
31
  html_bodyfont
32
32
  html_headerfont
33
33
  html_monospacefont
34
+ html_normalfontsize
35
+ html_monospacefontsize
36
+ html_smallerfontsize
37
+ html_footnotefontsize
34
38
  metadata_extensions
35
39
  metanorma_name
36
40
  normref_titles
@@ -51,9 +55,33 @@ module Metanorma
51
55
  word_bodyfont
52
56
  word_headerfont
53
57
  word_monospacefont
58
+ word_normalfontsize
59
+ word_monospacefontsize
60
+ word_smallerfontsize
61
+ word_footnotefontsize
54
62
  xml_root_tag
55
63
  ].freeze
56
64
 
65
+ def filepath_attrs
66
+ return %i[
67
+ i18nyaml
68
+ boilerplate
69
+ logo_path
70
+ logo_paths
71
+ header
72
+ htmlcoverpage
73
+ htmlintropage
74
+ htmlstylesheet
75
+ scripts
76
+ scripts_pdf
77
+ standardstylesheet
78
+ validate_rng_file
79
+ wordcoverpage
80
+ wordintropage
81
+ wordstylesheet
82
+ ]
83
+ end
84
+
57
85
  attr_accessor(*CONFIG_ATTRS)
58
86
 
59
87
  class << self
@@ -84,17 +112,47 @@ module Metanorma
84
112
  end
85
113
 
86
114
  def set_default_values_from_yaml_file(config_file)
115
+ root_path = File.dirname(self.class::_file || __FILE__)
87
116
  default_config_options = YAML.load(File.read(config_file))
88
117
  if default_config_options["doctypes"]&.is_a? Array
89
118
  default_config_options["doctypes"] = default_config_options["doctypes"].
90
119
  each_with_object({}) { |k, m| m[k] = nil }
91
120
  end
92
121
  CONFIG_ATTRS.each do |attr_name|
93
- instance_variable_set("@#{attr_name}", default_config_options[attr_name.to_s])
122
+ value = default_config_options[attr_name.to_s]
123
+ if value && filepath_attrs.include?(attr_name)
124
+ value = absolute_path(value, root_path)
125
+ end
126
+
127
+ instance_variable_set("@#{attr_name}", value)
128
+ end
129
+ end
130
+
131
+ def blank?(v)
132
+ v.nil? || v.respond_to?(:empty?) && v.empty?
133
+ end
134
+
135
+ def absolute_path(value, root_path)
136
+ if value.is_a? Hash then absolute_path1(value, root_path)
137
+ elsif value.is_a? Array
138
+ value.reject { |a| blank?(a) }.each_with_object([]) do |v1, g|
139
+ g << absolute_path(v1, root_path)
140
+ end
141
+ elsif value.is_a?(String) && !value.empty?
142
+ File.join(root_path, "..", "..", value)
143
+ else
144
+ value
145
+ end
146
+ end
147
+
148
+ def absolute_path1(h, pref)
149
+ h.reject { |k, v| blank?(v) }.each_with_object({}) do |(k, v), g|
150
+ g[k] = absolute_path(v, pref)
94
151
  end
95
152
  end
96
153
  end
97
154
 
155
+
98
156
  class << self
99
157
  extend Forwardable
100
158
 
@@ -0,0 +1,5 @@
1
+ ---
2
+ Source Sans Pro:
3
+ Overpass:
4
+ Space Mono:
5
+ Arial:
@@ -2,21 +2,6 @@ require "metanorma/processor"
2
2
 
3
3
  module Metanorma
4
4
  module Generic
5
- def self.fonts_used
6
- {
7
- html: [
8
- configuration.html_bodyfont || "Overpass", configuration.html_headerfont || "Overpass",
9
- configuration.html_monospacefont || "Space Mono"
10
- ].uniq,
11
- doc: [
12
- configuration.word_bodyfont || "Overpass", configuration.word_headerfont || "Overpass",
13
- configuration.word_monospacefont || "Space Mono"].uniq,
14
- pdf: [
15
- configuration.word_bodyfont || "Overpass", configuration.word_headerfont || "Overpass",
16
- configuration.word_monospacefont || "Space Mono"].uniq,
17
- }
18
- end
19
-
20
5
  class Processor < Metanorma::Processor
21
6
  def configuration
22
7
  Metanorma::Generic.configuration
@@ -42,31 +27,15 @@ module Metanorma
42
27
 
43
28
  def extract_options(file)
44
29
  head = file.sub(/\n\n.*$/m, "\n")
45
- /\n:htmlstylesheet: (?<htmlstylesheet>[^\n]+)\n/ =~ head
46
- /\n:htmlcoverpage: (?<htmlcoverpage>[^\n]+)\n/ =~ head
47
- /\n:htmlintropage: (?<htmlintropage>[^\n]+)\n/ =~ head
48
- /\n:scripts: (?<scripts>[^\n]+)\n/ =~ head
49
- /\n:wordstylesheet: (?<wordstylesheet>[^\n]+)\n/ =~ head
50
- /\n:standardstylesheet: (?<standardstylesheet>[^\n]+)\n/ =~ head
51
- /\n:header: (?<header>[^\n]+)\n/ =~ head
52
- /\n:wordcoverpage: (?<wordcoverpage>[^\n]+)\n/ =~ head
53
- /\n:wordintropage: (?<wordintropage>[^\n]+)\n/ =~ head
54
- /\n:ulstyle: (?<ulstyle>[^\n]+)\n/ =~ head
55
- /\n:olstyle: (?<olstyle>[^\n]+)\n/ =~ head
56
- new_options = {
57
- htmlstylesheet: defined?(htmlstylesheet) ? htmlstylesheet : nil,
58
- htmlcoverpage: defined?(htmlcoverpage) ? htmlcoverpage : nil,
59
- htmlintropage: defined?(htmlintropage) ? htmlintropage : nil,
60
- scripts: defined?(scripts) ? scripts : nil,
61
- wordstylesheet: defined?(wordstylesheet) ? wordstylesheet : nil,
62
- standardstylesheet: defined?(standardstylesheet) ? standardstylesheet : nil,
63
- header: defined?(header) ? header : nil,
64
- wordcoverpage: defined?(wordcoverpage) ? wordcoverpage : nil,
65
- wordintropage: defined?(wordintropage) ? wordintropage : nil,
66
- ulstyle: defined?(ulstyle) ? ulstyle : nil,
67
- olstyle: defined?(olstyle) ? olstyle : nil,
68
- }.reject { |_, val| val.nil? }
69
- super.merge(new_options)
30
+ ret = %w(htmlstylesheet htmlcoverpage htmlintropage scripts scripts-pdf
31
+ wordstylesheet standardstylesheet header wordcoverpage
32
+ wordintropage datauriimage htmltoclevels doctoclevels
33
+ ulstyle olstyle htmlstylesheet-override sectionsplit
34
+ wordstylesheet-override).each_with_object({}) do |w, acc|
35
+ m = /\n:#{w}: ([^\n]+)\n/.match(head) or next
36
+ acc[w.sub(/-/, "_").to_sym] = m[1]
37
+ end
38
+ super.merge(ret)
70
39
  end
71
40
 
72
41
  def output(isodoc_node, inname, outname, format, options={})
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Generic
3
- VERSION = "1.7.3"
3
+ VERSION = "1.10.0".freeze
4
4
  end
5
5
  end
@@ -1,4 +1,4 @@
1
- lib = File.expand_path("../lib", __FILE__)
1
+ lib = File.expand_path("lib", __dir__)
2
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
  require "metanorma/generic/version"
4
4
 
@@ -10,9 +10,9 @@ Gem::Specification.new do |spec|
10
10
 
11
11
  spec.summary = "Metanorma template gem for customisation."
12
12
  spec.description = <<~DESCRIPTION
13
- Metanorma template gem for customisation. This gem is meant to be customised for any downstream use.
14
-
15
- Formerly known as metanorma-acme
13
+ Metanorma template gem for customisation. This gem is meant to be customised for any downstream use.
14
+ #{' '}
15
+ Formerly known as metanorma-acme
16
16
  DESCRIPTION
17
17
 
18
18
  spec.homepage = "https://github.com/metanorma/metanorma-generic"
@@ -27,18 +27,18 @@ Gem::Specification.new do |spec|
27
27
  spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
28
28
 
29
29
  spec.add_dependency "htmlentities", "~> 4.3.4"
30
+ spec.add_dependency "isodoc", "~> 1.6.0"
31
+ spec.add_dependency "metanorma-standoc", "~> 1.9.0"
30
32
  spec.add_dependency "ruby-jing"
31
- spec.add_dependency "metanorma-standoc", "~> 1.6.0"
32
- spec.add_dependency "isodoc", "~> 1.2.0"
33
33
 
34
34
  spec.add_development_dependency "byebug", "~> 9.1"
35
- spec.add_development_dependency "sassc", "2.4.0"
36
35
  spec.add_development_dependency "equivalent-xml", "~> 0.6"
37
36
  spec.add_development_dependency "guard", "~> 2.14"
38
37
  spec.add_development_dependency "guard-rspec", "~> 4.7"
39
- spec.add_development_dependency "rake", "~> 12.0"
38
+ spec.add_development_dependency "rake", "~> 13.0"
40
39
  spec.add_development_dependency "rspec", "~> 3.6"
41
- spec.add_development_dependency "rubocop", "= 0.54.0"
40
+ spec.add_development_dependency "rubocop", "~> 1.5.2"
41
+ spec.add_development_dependency "sassc", "2.4.0"
42
42
  spec.add_development_dependency "simplecov", "~> 0.15"
43
43
  spec.add_development_dependency "timecop", "~> 0.9"
44
44
  end
@@ -14,6 +14,10 @@ htmlstylesheet: /metanorma-mine/lib/isodoc/mine/html/htmlstyle.scss
14
14
  html_bodyfont: '"Source Sans Pro",sans-serif'
15
15
  html_headerfont: '"Source Sans Pro",sans-serif'
16
16
  html_monospacefont: '"Source Code Pro",monospace'
17
+ html_normalfontsize: "1.0em"
18
+ html_monospacefontsize: "0.8em"
19
+ html_smallerfontsize: "0.9em"
20
+ html_footnotefontsize: "0.8em"
17
21
  scripts: /metanorma-mine/lib/isodoc/mine/html/scripts.html
18
22
  scripts_pdf: /metanorma-mine/lib/isodoc/mine/html/scripts.prd.html
19
23
  standardstylesheet: /metanorma-mine/lib/isodoc/mine/html/
@@ -24,6 +28,10 @@ wordstylesheet: /metanorma-mine/lib/isodoc/mine/html/wordstyle.scss
24
28
  word_bodyfont: '"Source Sans Pro","Arial",sans-serif'
25
29
  word_headerfont: '"Source Sans Pro","Arial",sans-serif'
26
30
  word_monospacefont: '"Source Code Pro",monospace'
31
+ word_normalfontsize: "12.0pt"
32
+ word_monospacefontsize: "11.0pt"
33
+ word_smallerfontsize: "10.0pt"
34
+ word_footnotefontsize: "9.0pt"
27
35
  docid_template: "{{ organization_name_short }} {{ docnumeric }}"
28
36
  metadata_extensions:
29
37
  - security
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.7.3
4
+ version: 1.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-11-09 00:00:00.000000000 Z
11
+ date: 2021-04-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: htmlentities
@@ -25,47 +25,47 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: 4.3.4
27
27
  - !ruby/object:Gem::Dependency
28
- name: ruby-jing
28
+ name: isodoc
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: 1.6.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: 1.6.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: metanorma-standoc
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 1.6.0
47
+ version: 1.9.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 1.6.0
54
+ version: 1.9.0
55
55
  - !ruby/object:Gem::Dependency
56
- name: isodoc
56
+ name: ruby-jing
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: 1.2.0
61
+ version: '0'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: 1.2.0
68
+ version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: byebug
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -80,20 +80,6 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '9.1'
83
- - !ruby/object:Gem::Dependency
84
- name: sassc
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - '='
88
- - !ruby/object:Gem::Version
89
- version: 2.4.0
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - '='
95
- - !ruby/object:Gem::Version
96
- version: 2.4.0
97
83
  - !ruby/object:Gem::Dependency
98
84
  name: equivalent-xml
99
85
  requirement: !ruby/object:Gem::Requirement
@@ -142,14 +128,14 @@ dependencies:
142
128
  requirements:
143
129
  - - "~>"
144
130
  - !ruby/object:Gem::Version
145
- version: '12.0'
131
+ version: '13.0'
146
132
  type: :development
147
133
  prerelease: false
148
134
  version_requirements: !ruby/object:Gem::Requirement
149
135
  requirements:
150
136
  - - "~>"
151
137
  - !ruby/object:Gem::Version
152
- version: '12.0'
138
+ version: '13.0'
153
139
  - !ruby/object:Gem::Dependency
154
140
  name: rspec
155
141
  requirement: !ruby/object:Gem::Requirement
@@ -166,18 +152,32 @@ dependencies:
166
152
  version: '3.6'
167
153
  - !ruby/object:Gem::Dependency
168
154
  name: rubocop
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: 1.5.2
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: 1.5.2
167
+ - !ruby/object:Gem::Dependency
168
+ name: sassc
169
169
  requirement: !ruby/object:Gem::Requirement
170
170
  requirements:
171
171
  - - '='
172
172
  - !ruby/object:Gem::Version
173
- version: 0.54.0
173
+ version: 2.4.0
174
174
  type: :development
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
178
  - - '='
179
179
  - !ruby/object:Gem::Version
180
- version: 0.54.0
180
+ version: 2.4.0
181
181
  - !ruby/object:Gem::Dependency
182
182
  name: simplecov
183
183
  requirement: !ruby/object:Gem::Requirement
@@ -206,10 +206,8 @@ dependencies:
206
206
  - - "~>"
207
207
  - !ruby/object:Gem::Version
208
208
  version: '0.9'
209
- description: |
210
- Metanorma template gem for customisation. This gem is meant to be customised for any downstream use.
211
-
212
- Formerly known as metanorma-acme
209
+ description: " Metanorma template gem for customisation. This gem is meant to be
210
+ customised for any downstream use.\n \n Formerly known as metanorma-acme\n"
213
211
  email:
214
212
  - open.source@ribose.com
215
213
  executables: []
@@ -219,8 +217,6 @@ files:
219
217
  - ".github/workflows/rake.yml"
220
218
  - ".gitignore"
221
219
  - ".hound.yml"
222
- - ".rubocop.ribose.yml"
223
- - ".rubocop.tb.yml"
224
220
  - ".rubocop.yml"
225
221
  - CODE_OF_CONDUCT.md
226
222
  - Gemfile
@@ -262,6 +258,7 @@ files:
262
258
  - lib/isodoc/generic/xref.rb
263
259
  - lib/metanorma-generic.rb
264
260
  - lib/metanorma/generic.rb
261
+ - lib/metanorma/generic/fonts_manifest.yaml
265
262
  - lib/metanorma/generic/processor.rb
266
263
  - lib/metanorma/generic/version.rb
267
264
  - metanorma-generic.gemspec
@@ -285,7 +282,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
285
282
  - !ruby/object:Gem::Version
286
283
  version: '0'
287
284
  requirements: []
288
- rubygems_version: 3.0.3
285
+ rubygems_version: 3.1.4
289
286
  signing_key:
290
287
  specification_version: 4
291
288
  summary: Metanorma template gem for customisation.