metanorma 2.1.4 → 2.5.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.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +23 -2
  3. data/Gemfile +14 -0
  4. data/README.adoc +1 -1
  5. data/lib/metanorma/collection/artifact_store.rb +142 -0
  6. data/lib/metanorma/collection/collection.rb +140 -131
  7. data/lib/metanorma/collection/config/bibdata.rb +1 -1
  8. data/lib/metanorma/collection/config/config.rb +50 -20
  9. data/lib/metanorma/collection/config/converters.rb +89 -31
  10. data/lib/metanorma/collection/config/doc_container.rb +28 -0
  11. data/lib/metanorma/collection/config/manifest.rb +30 -6
  12. data/lib/metanorma/collection/config/namespaces.rb +12 -0
  13. data/lib/metanorma/collection/document/document.rb +54 -15
  14. data/lib/metanorma/collection/filelookup/filelookup.rb +170 -74
  15. data/lib/metanorma/collection/filelookup/filelookup_sectionsplit.rb +62 -27
  16. data/lib/metanorma/collection/filelookup/utils.rb +52 -0
  17. data/lib/metanorma/collection/helpers.rb +82 -0
  18. data/lib/metanorma/collection/log.rb +24 -0
  19. data/lib/metanorma/collection/manifest/manifest.rb +27 -14
  20. data/lib/metanorma/collection/multilingual/multilingual.rb +1 -1
  21. data/lib/metanorma/collection/renderer/filelocation.rb +166 -0
  22. data/lib/metanorma/collection/renderer/fileparse.rb +60 -55
  23. data/lib/metanorma/collection/renderer/fileprocess.rb +184 -40
  24. data/lib/metanorma/collection/renderer/navigation.rb +20 -6
  25. data/lib/metanorma/collection/renderer/render_word.rb +8 -4
  26. data/lib/metanorma/collection/renderer/renderer.rb +202 -19
  27. data/lib/metanorma/collection/renderer/svg.rb +60 -5
  28. data/lib/metanorma/collection/renderer/utils.rb +76 -42
  29. data/lib/metanorma/collection/sectionsplit/collection.rb +14 -4
  30. data/lib/metanorma/collection/sectionsplit/sectionsplit.rb +141 -61
  31. data/lib/metanorma/collection/util/disambig_files.rb +4 -5
  32. data/lib/metanorma/collection/util/util.rb +147 -23
  33. data/lib/metanorma/collection/xrefprocess/xrefprocess.rb +7 -7
  34. data/lib/metanorma/compile/assets/icc-boilerplate.adoc +41 -0
  35. data/lib/metanorma/compile/compile.rb +180 -165
  36. data/lib/metanorma/compile/compile_options.rb +155 -83
  37. data/lib/metanorma/compile/extract.rb +76 -56
  38. data/lib/metanorma/compile/flavor.rb +19 -0
  39. data/lib/metanorma/compile/output_filename.rb +75 -0
  40. data/lib/metanorma/compile/output_filename_config.rb +27 -0
  41. data/lib/metanorma/compile/relaton_drop.rb +56 -0
  42. data/lib/metanorma/compile/render.rb +196 -0
  43. data/lib/metanorma/compile/validator.rb +26 -0
  44. data/lib/metanorma/compile/writeable.rb +12 -0
  45. data/lib/metanorma/util/fontist_helper.rb +35 -19
  46. data/lib/metanorma/version.rb +1 -1
  47. data/lib/metanorma.rb +1 -7
  48. data/metanorma.gemspec +11 -20
  49. data/plans/collection-rendering-architecture-review.md +516 -0
  50. metadata +42 -122
  51. data/.hound.yml +0 -5
  52. data/lib/metanorma/asciidoctor_extensions/glob_include_processor.rb +0 -22
  53. data/lib/metanorma/asciidoctor_extensions.rb +0 -1
  54. data/lib/metanorma/compile/compile_validate.rb +0 -68
  55. data/lib/metanorma/config/config.rb +0 -23
  56. data/lib/metanorma/input/asciidoc.rb +0 -88
  57. data/lib/metanorma/input/base.rb +0 -9
  58. data/lib/metanorma/input.rb +0 -7
  59. data/lib/metanorma/processor/processor.rb +0 -54
  60. data/lib/metanorma/processor.rb +0 -6
  61. data/lib/metanorma/registry/registry.rb +0 -63
  62. data/lib/metanorma/util/util.rb +0 -45
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.4
4
+ version: 2.5.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-03-04 00:00:00.000000000 Z
11
+ date: 2026-08-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: 1.14.3
47
+ version: 2.1.2
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.14.3
54
+ version: 2.1.2
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: htmlentities
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -72,30 +72,30 @@ dependencies:
72
72
  requirements:
73
73
  - - ">="
74
74
  - !ruby/object:Gem::Version
75
- version: 3.0.0
75
+ version: 3.5.0
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
- version: 3.0.0
82
+ version: 3.5.0
83
83
  - !ruby/object:Gem::Dependency
84
- name: mn2pdf
84
+ name: marcel
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - "~>"
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
- version: '2'
89
+ version: '0'
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - "~>"
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
- version: '2'
96
+ version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
- name: nokogiri
98
+ name: metanorma-core
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - ">="
@@ -109,13 +109,13 @@ dependencies:
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
- name: debug
112
+ name: metanorma-standoc
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - ">="
116
116
  - !ruby/object:Gem::Version
117
117
  version: '0'
118
- type: :development
118
+ type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
@@ -123,27 +123,27 @@ dependencies:
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  - !ruby/object:Gem::Dependency
126
- name: equivalent-xml
126
+ name: mn2pdf
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: '0.6'
132
- type: :development
131
+ version: '2'
132
+ type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: '0.6'
138
+ version: '2'
139
139
  - !ruby/object:Gem::Dependency
140
- name: metanorma-iso
140
+ name: nokogiri
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
143
  - - ">="
144
144
  - !ruby/object:Gem::Version
145
145
  version: '0'
146
- type: :development
146
+ type: :runtime
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
@@ -151,7 +151,7 @@ dependencies:
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
153
  - !ruby/object:Gem::Dependency
154
- name: mnconvert
154
+ name: canon
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
157
  - - ">="
@@ -165,7 +165,7 @@ dependencies:
165
165
  - !ruby/object:Gem::Version
166
166
  version: '0'
167
167
  - !ruby/object:Gem::Dependency
168
- name: pry
168
+ name: metanorma-iho
169
169
  requirement: !ruby/object:Gem::Requirement
170
170
  requirements:
171
171
  - - ">="
@@ -179,63 +179,7 @@ dependencies:
179
179
  - !ruby/object:Gem::Version
180
180
  version: '0'
181
181
  - !ruby/object:Gem::Dependency
182
- name: rake
183
- requirement: !ruby/object:Gem::Requirement
184
- requirements:
185
- - - "~>"
186
- - !ruby/object:Gem::Version
187
- version: '13.0'
188
- type: :development
189
- prerelease: false
190
- version_requirements: !ruby/object:Gem::Requirement
191
- requirements:
192
- - - "~>"
193
- - !ruby/object:Gem::Version
194
- version: '13.0'
195
- - !ruby/object:Gem::Dependency
196
- name: rspec
197
- requirement: !ruby/object:Gem::Requirement
198
- requirements:
199
- - - "~>"
200
- - !ruby/object:Gem::Version
201
- version: '3.0'
202
- type: :development
203
- prerelease: false
204
- version_requirements: !ruby/object:Gem::Requirement
205
- requirements:
206
- - - "~>"
207
- - !ruby/object:Gem::Version
208
- version: '3.0'
209
- - !ruby/object:Gem::Dependency
210
- name: rspec-command
211
- requirement: !ruby/object:Gem::Requirement
212
- requirements:
213
- - - "~>"
214
- - !ruby/object:Gem::Version
215
- version: '1.0'
216
- type: :development
217
- prerelease: false
218
- version_requirements: !ruby/object:Gem::Requirement
219
- requirements:
220
- - - "~>"
221
- - !ruby/object:Gem::Version
222
- version: '1.0'
223
- - !ruby/object:Gem::Dependency
224
- name: rubocop
225
- requirement: !ruby/object:Gem::Requirement
226
- requirements:
227
- - - "~>"
228
- - !ruby/object:Gem::Version
229
- version: '1'
230
- type: :development
231
- prerelease: false
232
- version_requirements: !ruby/object:Gem::Requirement
233
- requirements:
234
- - - "~>"
235
- - !ruby/object:Gem::Version
236
- version: '1'
237
- - !ruby/object:Gem::Dependency
238
- name: rubocop-performance
182
+ name: metanorma-iso
239
183
  requirement: !ruby/object:Gem::Requirement
240
184
  requirements:
241
185
  - - ">="
@@ -249,41 +193,13 @@ dependencies:
249
193
  - !ruby/object:Gem::Version
250
194
  version: '0'
251
195
  - !ruby/object:Gem::Dependency
252
- name: sassc-embedded
253
- requirement: !ruby/object:Gem::Requirement
254
- requirements:
255
- - - "~>"
256
- - !ruby/object:Gem::Version
257
- version: '1'
258
- type: :development
259
- prerelease: false
260
- version_requirements: !ruby/object:Gem::Requirement
261
- requirements:
262
- - - "~>"
263
- - !ruby/object:Gem::Version
264
- version: '1'
265
- - !ruby/object:Gem::Dependency
266
- name: simplecov
267
- requirement: !ruby/object:Gem::Requirement
268
- requirements:
269
- - - "~>"
270
- - !ruby/object:Gem::Version
271
- version: '0.15'
272
- type: :development
273
- prerelease: false
274
- version_requirements: !ruby/object:Gem::Requirement
275
- requirements:
276
- - - "~>"
277
- - !ruby/object:Gem::Version
278
- version: '0.15'
279
- - !ruby/object:Gem::Dependency
280
- name: xml-c14n
196
+ name: relaton-cli
281
197
  requirement: !ruby/object:Gem::Requirement
282
198
  requirements:
283
199
  - - ">="
284
200
  - !ruby/object:Gem::Version
285
201
  version: '0'
286
- type: :development
202
+ type: :runtime
287
203
  prerelease: false
288
204
  version_requirements: !ruby/object:Gem::Requirement
289
205
  requirements:
@@ -302,7 +218,6 @@ extra_rdoc_files:
302
218
  files:
303
219
  - ".envrc"
304
220
  - ".gitignore"
305
- - ".hound.yml"
306
221
  - ".rspec"
307
222
  - ".rubocop.yml"
308
223
  - CHANGELOG.adoc
@@ -312,20 +227,25 @@ files:
312
227
  - README.adoc
313
228
  - lib/metanorma.rb
314
229
  - lib/metanorma/array_monkeypatch.rb
315
- - lib/metanorma/asciidoctor_extensions.rb
316
- - lib/metanorma/asciidoctor_extensions/glob_include_processor.rb
230
+ - lib/metanorma/collection/artifact_store.rb
317
231
  - lib/metanorma/collection/collection.rb
318
232
  - lib/metanorma/collection/config/bibdata.rb
319
233
  - lib/metanorma/collection/config/compile_options.rb
320
234
  - lib/metanorma/collection/config/config.rb
321
235
  - lib/metanorma/collection/config/converters.rb
322
236
  - lib/metanorma/collection/config/directive.rb
237
+ - lib/metanorma/collection/config/doc_container.rb
323
238
  - lib/metanorma/collection/config/manifest.rb
239
+ - lib/metanorma/collection/config/namespaces.rb
324
240
  - lib/metanorma/collection/document/document.rb
325
241
  - lib/metanorma/collection/filelookup/filelookup.rb
326
242
  - lib/metanorma/collection/filelookup/filelookup_sectionsplit.rb
243
+ - lib/metanorma/collection/filelookup/utils.rb
244
+ - lib/metanorma/collection/helpers.rb
245
+ - lib/metanorma/collection/log.rb
327
246
  - lib/metanorma/collection/manifest/manifest.rb
328
247
  - lib/metanorma/collection/multilingual/multilingual.rb
248
+ - lib/metanorma/collection/renderer/filelocation.rb
329
249
  - lib/metanorma/collection/renderer/fileparse.rb
330
250
  - lib/metanorma/collection/renderer/fileprocess.rb
331
251
  - lib/metanorma/collection/renderer/navigation.rb
@@ -338,22 +258,22 @@ files:
338
258
  - lib/metanorma/collection/util/disambig_files.rb
339
259
  - lib/metanorma/collection/util/util.rb
340
260
  - lib/metanorma/collection/xrefprocess/xrefprocess.rb
261
+ - lib/metanorma/compile/assets/icc-boilerplate.adoc
341
262
  - lib/metanorma/compile/compile.rb
342
263
  - lib/metanorma/compile/compile_options.rb
343
- - lib/metanorma/compile/compile_validate.rb
344
264
  - lib/metanorma/compile/extract.rb
345
- - lib/metanorma/config/config.rb
346
- - lib/metanorma/input.rb
347
- - lib/metanorma/input/asciidoc.rb
348
- - lib/metanorma/input/base.rb
349
- - lib/metanorma/processor.rb
350
- - lib/metanorma/processor/processor.rb
351
- - lib/metanorma/registry/registry.rb
265
+ - lib/metanorma/compile/flavor.rb
266
+ - lib/metanorma/compile/output_filename.rb
267
+ - lib/metanorma/compile/output_filename_config.rb
268
+ - lib/metanorma/compile/relaton_drop.rb
269
+ - lib/metanorma/compile/render.rb
270
+ - lib/metanorma/compile/validator.rb
271
+ - lib/metanorma/compile/writeable.rb
352
272
  - lib/metanorma/util/fontist_helper.rb
353
- - lib/metanorma/util/util.rb
354
273
  - lib/metanorma/util/worker_pool.rb
355
274
  - lib/metanorma/version.rb
356
275
  - metanorma.gemspec
276
+ - plans/collection-rendering-architecture-review.md
357
277
  homepage: https://github.com/metanorma/metanorma
358
278
  licenses:
359
279
  - BSD-2-Clause
@@ -366,7 +286,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
366
286
  requirements:
367
287
  - - ">="
368
288
  - !ruby/object:Gem::Version
369
- version: 3.1.0
289
+ version: 3.3.0
370
290
  required_rubygems_version: !ruby/object:Gem::Requirement
371
291
  requirements:
372
292
  - - ">="
data/.hound.yml DELETED
@@ -1,5 +0,0 @@
1
- # Auto-generated by Cimas: Do not edit it manually!
2
- # See https://github.com/metanorma/cimas
3
- ruby:
4
- enabled: true
5
- config_file: .rubocop.yml
@@ -1,22 +0,0 @@
1
- module Metanorma
2
- module AsciidoctorExtensions
3
- class GlobIncludeProcessor < ::Asciidoctor::Extensions::IncludeProcessor
4
- def process(_doc, reader, target_glob, attributes)
5
- Dir[File.join reader.dir, target_glob].sort.reverse_each do |target|
6
- content = File.readlines target
7
- content.unshift "" unless attributes["adjoin-option"]
8
- reader.push_include content, target, target, 1, attributes
9
- end
10
- reader
11
- end
12
-
13
- def handles?(target)
14
- target.include? "*"
15
- end
16
- end
17
- end
18
- end
19
-
20
- Asciidoctor::Extensions.register do
21
- include_processor ::Metanorma::AsciidoctorExtensions::GlobIncludeProcessor
22
- end
@@ -1 +0,0 @@
1
- require_relative "asciidoctor_extensions/glob_include_processor"
@@ -1,68 +0,0 @@
1
- module Metanorma
2
- class Compile
3
- def validate_options(options)
4
- validate_type(options)
5
- validate_format(options)
6
- end
7
-
8
- def validate_type(options)
9
- unless options[:type]
10
- Util.log("[metanorma] Error: Please specify a standard type: "\
11
- "#{@registry.supported_backends}.", :fatal)
12
- end
13
- stdtype = options[:type].to_sym
14
- load_flavor(stdtype)
15
- end
16
-
17
- def validate_format(options)
18
- unless options[:format] == :asciidoc
19
- Util.log("[metanorma] Error: Only source file format currently "\
20
- "supported is 'asciidoc'.", :fatal)
21
- end
22
- end
23
-
24
- def load_flavor(stdtype)
25
- stdtype = stdtype.to_sym
26
- flavor = stdtype2flavor(stdtype)
27
- @registry.supported_backends.include? stdtype or
28
- Util.log("[metanorma] Info: Loading `#{flavor}` gem "\
29
- "for standard type `#{stdtype}`.", :info)
30
- require_flavor(flavor)
31
- @registry.supported_backends.include? stdtype or
32
- Util.log("[metanorma] Error: The `#{flavor}` gem does not "\
33
- "support the standard type #{stdtype}. Exiting.", :fatal)
34
- end
35
-
36
- def stdtype2flavor(stdtype)
37
- flavor = STDTYPE2FLAVOR[stdtype] || stdtype
38
- "metanorma-#{flavor}"
39
- end
40
-
41
- private
42
-
43
- STDTYPE2FLAVOR = {}.freeze
44
-
45
- def require_flavor(flavor)
46
- require flavor
47
- Util.log("[metanorma] Info: gem `#{flavor}` loaded.", :info)
48
- rescue LoadError => e
49
- error_log = "#{Date.today}-error.log"
50
- File.write(error_log, e)
51
-
52
- msg = <<~MSG
53
- Error: #{e.message}
54
- Metanorma has encountered an exception.
55
-
56
- If this problem persists, please report this issue at the following link:
57
-
58
- * https://github.com/metanorma/metanorma/issues/new
59
-
60
- Please attach the #{error_log} file.
61
- Your valuable feedback is very much appreciated!
62
-
63
- - The Metanorma team
64
- MSG
65
- Util.log(msg, :fatal)
66
- end
67
- end
68
- end
@@ -1,23 +0,0 @@
1
- module Metanorma
2
- module Config
3
- def configure
4
- if block_given?
5
- yield configuration
6
- end
7
- end
8
-
9
- def configuration
10
- @configuration ||= Configuration.new
11
- end
12
- end
13
-
14
- class Configuration
15
- attr_accessor :logs
16
-
17
- def initialize
18
- @logs = %i[warning error fatal]
19
- end
20
- end
21
-
22
- extend Config
23
- end
@@ -1,88 +0,0 @@
1
- require "nokogiri"
2
-
3
- module Metanorma
4
- module Input
5
- class Asciidoc < Base
6
- def process(file, filename, type, options = {})
7
- require "asciidoctor"
8
- out_opts = { to_file: false, safe: :safe, backend: type,
9
- header_footer: true, log: options[:log],
10
- novalid: options[:novalid],
11
- attributes: ["nodoc", "stem", "docfile=#{filename}",
12
- "output_dir=#{options[:output_dir]}"] }
13
- ::Asciidoctor.convert(file, out_opts)
14
- end
15
-
16
- def extract_metanorma_options(file)
17
- hdr = file.sub(/\n\n.*$/m, "\n")
18
- /\n:(?:mn-)?(?:document-class|flavor):\s+(?<type>\S[^\n]*)\n/ =~ hdr
19
- /\n:(?:mn-)?output-extensions:\s+(?<extensions>\S[^\n]*)\n/ =~ hdr
20
- /\n:(?:mn-)?relaton-output-file:\s+(?<relaton>\S[^\n]*)\n/ =~ hdr
21
- /\n(?<asciimath>:(?:mn-)?keep-asciimath:[^\n]*)\n/ =~ hdr
22
- /\n(?<novalid>:novalid:[^\n]*)\n/ =~ hdr
23
- if defined?(asciimath)
24
- asciimath =
25
- !asciimath.nil? && !/keep-asciimath: false/.match?(asciimath)
26
- end
27
- asciimath = nil if asciimath == false
28
- {
29
- type: defined?(type) ? type&.strip : nil,
30
- extensions: defined?(extensions) ? extensions&.strip : nil,
31
- relaton: defined?(relaton) ? relaton&.strip : nil,
32
- asciimath: asciimath, novalid: !novalid.nil? || nil
33
- }.compact
34
- end
35
-
36
- def empty_attr(attr, name)
37
- attr&.sub(/^#{name}:\s*$/, "#{name}: true")&.sub(/^#{name}:\s+/, "")
38
- end
39
-
40
- ADOC_OPTIONS =
41
- %w(htmlstylesheet htmlcoverpage htmlintropage scripts
42
- scripts-override scripts-pdf wordstylesheet i18nyaml
43
- standardstylesheet header wordcoverpage wordintropage
44
- ulstyle olstyle htmlstylesheet-override bare toclevels
45
- htmltoclevels doctoclevels sectionsplit base-asset-path
46
- body-font header-font monospace-font title-font
47
- align-cross-elements wordstylesheet-override ieee-dtd
48
- pdf-encrypt pdf-encryption-length pdf-user-password
49
- pdf-owner-password pdf-allow-copy-content pdf-allow-edit-content
50
- pdf-allow-assemble-document pdf-allow-edit-annotations
51
- pdf-allow-print pdf-allow-print-hq pdf-allow-fill-in-forms
52
- fonts font-license-agreement pdf-allow-access-content
53
- pdf-encrypt-metadata iso-word-template document-scheme
54
- localize-number iso-word-bg-strip-color modspec-identifier-base)
55
- .freeze
56
-
57
- EMPTY_ADOC_OPTIONS_DEFAULT_TRUE =
58
- %w(data-uri-image suppress-asciimath-dup use-xinclude
59
- source-highlighter).freeze
60
-
61
- EMPTY_ADOC_OPTIONS_DEFAULT_FALSE =
62
- %w(hierarchical-assets break-up-urls-in-tables toc-figures
63
- toc-tables toc-recommendations).freeze
64
-
65
- def attr_name_normalise(name)
66
- name.delete("-").sub(/override$/, "_override").sub(/pdf$/, "_pdf")
67
- .to_sym
68
- end
69
-
70
- def extract_options(file)
71
- header = file.sub(/\n\n.*$/m, "\n")
72
- ret = ADOC_OPTIONS.each_with_object({}) do |w, acc|
73
- m = /\n:#{w}:\s+([^\n]+)\n/.match(header) or next
74
- acc[attr_name_normalise(w)] = m[1]&.strip
75
- end
76
- ret2 = EMPTY_ADOC_OPTIONS_DEFAULT_TRUE.each_with_object({}) do |w, acc|
77
- m = /\n:#{w}:([^\n]*)\n/.match(header) || [nil, "true"]
78
- acc[attr_name_normalise(w)] = (m[1].strip != "false")
79
- end
80
- ret3 = EMPTY_ADOC_OPTIONS_DEFAULT_FALSE.each_with_object({}) do |w, acc|
81
- m = /\n:#{w}:([^\n]*)\n/.match(header) || [nil, "false"]
82
- acc[attr_name_normalise(w)] = !["false"].include?(m[1].strip)
83
- end
84
- ret.merge(ret2).merge(ret3).compact
85
- end
86
- end
87
- end
88
- end
@@ -1,9 +0,0 @@
1
- module Metanorma
2
- module Input
3
- class Base
4
- def process(_file, _filename, _type)
5
- raise "This is an abstract class"
6
- end
7
- end
8
- end
9
- end
@@ -1,7 +0,0 @@
1
- require_relative "./input/base"
2
- require_relative "./input/asciidoc"
3
-
4
- module Metanorma
5
- module Input
6
- end
7
- end
@@ -1,54 +0,0 @@
1
- # Registry of all Metanorma types and entry points
2
- #
3
-
4
- module Metanorma
5
- class Processor
6
- attr_reader :short, :input_format, :asciidoctor_backend
7
-
8
- def initialize
9
- raise "This is an abstract class!"
10
- end
11
-
12
- def output_formats
13
- {
14
- xml: "xml",
15
- presentation: "presentation.xml",
16
- rxl: "rxl",
17
- }
18
- end
19
-
20
- def input_to_isodoc(file, filename, options = {})
21
- Metanorma::Input::Asciidoc.new.process(file, filename,
22
- @asciidoctor_backend, options)
23
- end
24
-
25
- # def input_to_isodoc(file, filename)
26
- # raise "This is an abstract class!"
27
- # end
28
-
29
- def use_presentation_xml(ext)
30
- case ext
31
- when :html, :doc, :pdf then true
32
- else
33
- false
34
- end
35
- end
36
-
37
- def options_preprocess(options)
38
- options[:output_formats] ||= output_formats
39
- end
40
-
41
- def output(isodoc_node, _inname, outname, _format, _options = {})
42
- File.open(outname, "w:UTF-8") { |f| f.write(isodoc_node) }
43
- end
44
-
45
- def extract_options(file)
46
- Metanorma::Input::Asciidoc.new.extract_options(file)
47
- .merge(output_formats: output_formats)
48
- end
49
-
50
- def extract_metanorma_options(file)
51
- Metanorma::Input::Asciidoc.new.extract_metanorma_options(file)
52
- end
53
- end
54
- end
@@ -1,6 +0,0 @@
1
- require_relative "./processor/processor"
2
-
3
- module Metanorma
4
- class Processor
5
- end
6
- end
@@ -1,63 +0,0 @@
1
- # Registry of all Metanorma types and entry points
2
-
3
- require "singleton"
4
-
5
- class Error < StandardError
6
- end
7
-
8
- module Metanorma
9
- class Registry
10
- include Singleton
11
-
12
- attr_reader :processors
13
-
14
- def initialize
15
- @processors = {}
16
- @aliases = { csd: :cc, m3d: :m3aawg, mpfd: :mpfa, csand: :csa }
17
- end
18
-
19
- def alias(flavour)
20
- @aliases[flavour]
21
- end
22
-
23
- def register(processor)
24
- raise Error unless processor < ::Metanorma::Processor
25
-
26
- p = processor.new
27
- # p.short[-1] is the canonical name
28
- short = Array(p.short)
29
- @processors[short[-1]] = p
30
- short.each do |s|
31
- @aliases[s] = short[-1]
32
- end
33
- Array(p.short)
34
- Util.log("[metanorma] processor \"#{Array(p.short)[0]}\" registered",
35
- :info)
36
- end
37
-
38
- def find_processor(short)
39
- @processors[short.to_sym]
40
- end
41
-
42
- def supported_backends
43
- @processors.keys
44
- end
45
-
46
- def output_formats
47
- @processors.inject({}) do |acc, (k, v)|
48
- acc[k] = v.output_formats
49
- acc
50
- end
51
- end
52
-
53
- def root_tags
54
- @processors.inject({}) do |acc, (k, v)|
55
- if v.asciidoctor_backend
56
- x = Asciidoctor.load nil, { backend: v.asciidoctor_backend }
57
- acc[k] = x.converter.xml_root_tag
58
- end
59
- acc
60
- end
61
- end
62
- end
63
- end