metanorma 2.0.0 → 2.5.5

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 (68) hide show
  1. checksums.yaml +4 -4
  2. data/.envrc +1 -0
  3. data/.gitignore +3 -0
  4. data/.rubocop.yml +23 -2
  5. data/Gemfile +17 -0
  6. data/Gemfile.devel +10 -0
  7. data/README.adoc +1 -1
  8. data/lib/metanorma/collection/artifact_store.rb +142 -0
  9. data/lib/metanorma/collection/collection.rb +160 -122
  10. data/lib/metanorma/collection/config/bibdata.rb +3 -3
  11. data/lib/metanorma/collection/config/compile_options.rb +4 -5
  12. data/lib/metanorma/collection/config/config.rb +81 -83
  13. data/lib/metanorma/collection/config/converters.rb +92 -8
  14. data/lib/metanorma/collection/config/directive.rb +9 -3
  15. data/lib/metanorma/collection/config/doc_container.rb +28 -0
  16. data/lib/metanorma/collection/config/manifest.rb +59 -29
  17. data/lib/metanorma/collection/config/namespaces.rb +12 -0
  18. data/lib/metanorma/collection/document/document.rb +56 -15
  19. data/lib/metanorma/collection/filelookup/filelookup.rb +185 -77
  20. data/lib/metanorma/collection/filelookup/filelookup_sectionsplit.rb +99 -27
  21. data/lib/metanorma/collection/filelookup/utils.rb +52 -0
  22. data/lib/metanorma/collection/helpers.rb +82 -0
  23. data/lib/metanorma/collection/log.rb +24 -0
  24. data/lib/metanorma/collection/manifest/manifest.rb +45 -14
  25. data/lib/metanorma/collection/multilingual/multilingual.rb +660 -0
  26. data/lib/metanorma/collection/renderer/filelocation.rb +166 -0
  27. data/lib/metanorma/collection/renderer/fileparse.rb +135 -115
  28. data/lib/metanorma/collection/renderer/fileprocess.rb +185 -37
  29. data/lib/metanorma/collection/renderer/navigation.rb +21 -7
  30. data/lib/metanorma/collection/renderer/render_word.rb +15 -10
  31. data/lib/metanorma/collection/renderer/renderer.rb +236 -32
  32. data/lib/metanorma/collection/renderer/svg.rb +107 -0
  33. data/lib/metanorma/collection/renderer/utils.rb +110 -39
  34. data/lib/metanorma/collection/sectionsplit/collection.rb +110 -0
  35. data/lib/metanorma/collection/sectionsplit/sectionsplit.rb +198 -115
  36. data/lib/metanorma/collection/util/disambig_files.rb +4 -5
  37. data/lib/metanorma/collection/util/util.rb +155 -18
  38. data/lib/metanorma/collection/xrefprocess/xrefprocess.rb +47 -33
  39. data/lib/metanorma/compile/assets/icc-boilerplate.adoc +41 -0
  40. data/lib/metanorma/compile/compile.rb +181 -156
  41. data/lib/metanorma/compile/compile_options.rb +186 -79
  42. data/lib/metanorma/compile/extract.rb +75 -58
  43. data/lib/metanorma/compile/flavor.rb +28 -0
  44. data/lib/metanorma/compile/output_filename.rb +75 -0
  45. data/lib/metanorma/compile/output_filename_config.rb +27 -0
  46. data/lib/metanorma/compile/relaton_drop.rb +56 -0
  47. data/lib/metanorma/compile/render.rb +226 -0
  48. data/lib/metanorma/compile/validator.rb +26 -0
  49. data/lib/metanorma/compile/writeable.rb +12 -0
  50. data/lib/metanorma/util/fontist_helper.rb +35 -19
  51. data/lib/metanorma/version.rb +1 -1
  52. data/lib/metanorma.rb +1 -7
  53. data/metanorma.gemspec +15 -21
  54. data/plans/collection-rendering-architecture-review.md +516 -0
  55. metadata +65 -113
  56. data/.hound.yml +0 -5
  57. data/lib/metanorma/asciidoctor_extensions/glob_include_processor.rb +0 -22
  58. data/lib/metanorma/asciidoctor_extensions.rb +0 -1
  59. data/lib/metanorma/compile/compile_validate.rb +0 -68
  60. data/lib/metanorma/config/config.rb +0 -23
  61. data/lib/metanorma/input/asciidoc.rb +0 -107
  62. data/lib/metanorma/input/base.rb +0 -9
  63. data/lib/metanorma/input.rb +0 -7
  64. data/lib/metanorma/processor/processor.rb +0 -54
  65. data/lib/metanorma/processor.rb +0 -6
  66. data/lib/metanorma/registry/registry.rb +0 -63
  67. data/lib/metanorma/shale_monkeypatch.rb +0 -15
  68. 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.0.0
4
+ version: 2.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-06-04 00:00:00.000000000 Z
11
+ date: 2026-09-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor
@@ -25,63 +25,63 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: fontist
28
+ name: concurrent-ruby
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 1.14.3
33
+ version: '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: 1.14.3
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: htmlentities
42
+ name: fontist
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
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: '0'
54
+ version: 2.1.2
55
55
  - !ruby/object:Gem::Dependency
56
- name: isodoc
56
+ name: htmlentities
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: 2.6.3
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: 2.6.3
68
+ version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: mn2pdf
70
+ name: isodoc
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
- version: '1'
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: '1'
82
+ version: 3.5.0
83
83
  - !ruby/object:Gem::Dependency
84
- name: nokogiri
84
+ name: marcel
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - ">="
@@ -95,7 +95,7 @@ dependencies:
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
- name: shale
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,89 +179,33 @@ 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.5.2
230
- type: :development
231
- prerelease: false
232
- version_requirements: !ruby/object:Gem::Requirement
233
- requirements:
234
- - - "~>"
235
- - !ruby/object:Gem::Version
236
- version: 1.5.2
237
- - !ruby/object:Gem::Dependency
238
- name: sassc
182
+ name: metanorma-iso
239
183
  requirement: !ruby/object:Gem::Requirement
240
184
  requirements:
241
- - - "~>"
185
+ - - ">="
242
186
  - !ruby/object:Gem::Version
243
- version: 2.4.0
187
+ version: '0'
244
188
  type: :development
245
189
  prerelease: false
246
190
  version_requirements: !ruby/object:Gem::Requirement
247
191
  requirements:
248
- - - "~>"
192
+ - - ">="
249
193
  - !ruby/object:Gem::Version
250
- version: 2.4.0
194
+ version: '0'
251
195
  - !ruby/object:Gem::Dependency
252
- name: simplecov
196
+ name: relaton-cli
253
197
  requirement: !ruby/object:Gem::Requirement
254
198
  requirements:
255
- - - "~>"
199
+ - - ">="
256
200
  - !ruby/object:Gem::Version
257
- version: '0.15'
258
- type: :development
201
+ version: '0'
202
+ type: :runtime
259
203
  prerelease: false
260
204
  version_requirements: !ruby/object:Gem::Requirement
261
205
  requirements:
262
- - - "~>"
206
+ - - ">="
263
207
  - !ruby/object:Gem::Version
264
- version: '0.15'
208
+ version: '0'
265
209
  description: Library to process any Metanorma standard.
266
210
  email:
267
211
  - open.source@ribose.com
@@ -272,62 +216,70 @@ extra_rdoc_files:
272
216
  - CHANGELOG.adoc
273
217
  - LICENSE.txt
274
218
  files:
219
+ - ".envrc"
275
220
  - ".gitignore"
276
- - ".hound.yml"
277
221
  - ".rspec"
278
222
  - ".rubocop.yml"
279
223
  - CHANGELOG.adoc
280
224
  - CODE_OF_CONDUCT.md
281
225
  - Gemfile
226
+ - Gemfile.devel
282
227
  - LICENSE.txt
283
228
  - README.adoc
284
229
  - lib/metanorma.rb
285
230
  - lib/metanorma/array_monkeypatch.rb
286
- - lib/metanorma/asciidoctor_extensions.rb
287
- - lib/metanorma/asciidoctor_extensions/glob_include_processor.rb
231
+ - lib/metanorma/collection/artifact_store.rb
288
232
  - lib/metanorma/collection/collection.rb
289
233
  - lib/metanorma/collection/config/bibdata.rb
290
234
  - lib/metanorma/collection/config/compile_options.rb
291
235
  - lib/metanorma/collection/config/config.rb
292
236
  - lib/metanorma/collection/config/converters.rb
293
237
  - lib/metanorma/collection/config/directive.rb
238
+ - lib/metanorma/collection/config/doc_container.rb
294
239
  - lib/metanorma/collection/config/manifest.rb
240
+ - lib/metanorma/collection/config/namespaces.rb
295
241
  - lib/metanorma/collection/document/document.rb
296
242
  - lib/metanorma/collection/filelookup/filelookup.rb
297
243
  - lib/metanorma/collection/filelookup/filelookup_sectionsplit.rb
244
+ - lib/metanorma/collection/filelookup/utils.rb
245
+ - lib/metanorma/collection/helpers.rb
246
+ - lib/metanorma/collection/log.rb
298
247
  - lib/metanorma/collection/manifest/manifest.rb
248
+ - lib/metanorma/collection/multilingual/multilingual.rb
249
+ - lib/metanorma/collection/renderer/filelocation.rb
299
250
  - lib/metanorma/collection/renderer/fileparse.rb
300
251
  - lib/metanorma/collection/renderer/fileprocess.rb
301
252
  - lib/metanorma/collection/renderer/navigation.rb
302
253
  - lib/metanorma/collection/renderer/render_word.rb
303
254
  - lib/metanorma/collection/renderer/renderer.rb
255
+ - lib/metanorma/collection/renderer/svg.rb
304
256
  - lib/metanorma/collection/renderer/utils.rb
257
+ - lib/metanorma/collection/sectionsplit/collection.rb
305
258
  - lib/metanorma/collection/sectionsplit/sectionsplit.rb
306
259
  - lib/metanorma/collection/util/disambig_files.rb
307
260
  - lib/metanorma/collection/util/util.rb
308
261
  - lib/metanorma/collection/xrefprocess/xrefprocess.rb
262
+ - lib/metanorma/compile/assets/icc-boilerplate.adoc
309
263
  - lib/metanorma/compile/compile.rb
310
264
  - lib/metanorma/compile/compile_options.rb
311
- - lib/metanorma/compile/compile_validate.rb
312
265
  - lib/metanorma/compile/extract.rb
313
- - lib/metanorma/config/config.rb
314
- - lib/metanorma/input.rb
315
- - lib/metanorma/input/asciidoc.rb
316
- - lib/metanorma/input/base.rb
317
- - lib/metanorma/processor.rb
318
- - lib/metanorma/processor/processor.rb
319
- - lib/metanorma/registry/registry.rb
320
- - lib/metanorma/shale_monkeypatch.rb
266
+ - lib/metanorma/compile/flavor.rb
267
+ - lib/metanorma/compile/output_filename.rb
268
+ - lib/metanorma/compile/output_filename_config.rb
269
+ - lib/metanorma/compile/relaton_drop.rb
270
+ - lib/metanorma/compile/render.rb
271
+ - lib/metanorma/compile/validator.rb
272
+ - lib/metanorma/compile/writeable.rb
321
273
  - lib/metanorma/util/fontist_helper.rb
322
- - lib/metanorma/util/util.rb
323
274
  - lib/metanorma/util/worker_pool.rb
324
275
  - lib/metanorma/version.rb
325
276
  - metanorma.gemspec
277
+ - plans/collection-rendering-architecture-review.md
326
278
  homepage: https://github.com/metanorma/metanorma
327
279
  licenses:
328
280
  - BSD-2-Clause
329
281
  metadata: {}
330
- post_install_message:
282
+ post_install_message:
331
283
  rdoc_options: []
332
284
  require_paths:
333
285
  - lib
@@ -335,15 +287,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
335
287
  requirements:
336
288
  - - ">="
337
289
  - !ruby/object:Gem::Version
338
- version: 2.7.0
290
+ version: 3.3.0
339
291
  required_rubygems_version: !ruby/object:Gem::Requirement
340
292
  requirements:
341
293
  - - ">="
342
294
  - !ruby/object:Gem::Version
343
295
  version: '0'
344
296
  requirements: []
345
- rubygems_version: 3.3.27
346
- signing_key:
297
+ rubygems_version: 3.5.22
298
+ signing_key:
347
299
  specification_version: 4
348
300
  summary: Metanorma is the standard of standards; the metanorma gem allows you to create
349
301
  any standard document type supported by Metanorma.
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
- private
37
-
38
- STDTYPE2FLAVOR = {}.freeze
39
-
40
- def stdtype2flavor(stdtype)
41
- flavor = STDTYPE2FLAVOR[stdtype] || stdtype
42
- "metanorma-#{flavor}"
43
- end
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,107 +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
- unless asciidoctor_validate(file, filename, out_opts)
14
- warn "Cannot continue compiling Asciidoctor document"
15
- abort
16
- end
17
- ::Asciidoctor.convert(file, out_opts)
18
- end
19
-
20
- def asciidoctor_validate(file, filename, options)
21
- err = nil
22
- begin
23
- previous_stderr = $stderr
24
- $stderr = StringIO.new
25
- ::Asciidoctor.load(file, options)
26
- %r{(\n|^)asciidoctor: ERROR: ['"]?#{Regexp.escape(filename ||
27
- '<empty>')}['"]?: line \d+: include file not found: }
28
- .match($stderr.string) and err = $stderr.string
29
- ensure
30
- $stderr = previous_stderr
31
- end
32
- warn err unless err.nil?
33
- err.nil?
34
- end
35
-
36
- def extract_metanorma_options(file)
37
- headerextract = file.sub(/\n\n.*$/m, "\n")
38
- /\n:mn-document-class:\s+(?<type>\S[^\n]*)\n/ =~ headerextract
39
- /\n:mn-output-extensions:\s+(?<extensions>\S[^\n]*)\n/ =~ headerextract
40
- /\n:mn-relaton-output-file:\s+(?<relaton>\S[^\n]*)\n/ =~ headerextract
41
- /\n(?<asciimath>:mn-keep-asciimath:[^\n]*)\n/ =~ headerextract
42
- /\n(?<novalid>:novalid:[^\n]*)\n/ =~ headerextract
43
- asciimath = if defined?(asciimath)
44
- !asciimath.nil? && asciimath != ":mn-keep-asciimath: false"
45
- end
46
- asciimath = nil if asciimath == false
47
- {
48
- type: defined?(type) ? type&.strip : nil,
49
- extensions: defined?(extensions) ? extensions&.strip : nil,
50
- relaton: defined?(relaton) ? relaton&.strip : nil,
51
- asciimath: asciimath, novalid: !novalid.nil? || nil
52
- }.compact
53
- end
54
-
55
- def empty_attr(attr, name)
56
- attr&.sub(/^#{name}:\s*$/, "#{name}: true")&.sub(/^#{name}:\s+/, "")
57
- end
58
-
59
- ADOC_OPTIONS =
60
- %w(htmlstylesheet htmlcoverpage htmlintropage scripts
61
- scripts-override scripts-pdf wordstylesheet i18nyaml
62
- standardstylesheet header wordcoverpage wordintropage
63
- ulstyle olstyle htmlstylesheet-override bare toclevels
64
- htmltoclevels doctoclevels sectionsplit base-asset-path
65
- body-font header-font monospace-font title-font
66
- align-cross-elements wordstylesheet-override ieee-dtd
67
- pdf-encrypt pdf-encryption-length pdf-user-password
68
- pdf-owner-password pdf-allow-copy-content pdf-allow-edit-content
69
- pdf-allow-assemble-document pdf-allow-edit-annotations
70
- pdf-allow-print pdf-allow-print-hq pdf-allow-fill-in-forms
71
- fonts font-license-agreement pdf-allow-access-content
72
- pdf-encrypt-metadata iso-word-template document-scheme
73
- localize-number iso-word-bg-strip-color modspec-identifier-base)
74
- .freeze
75
-
76
- EMPTY_ADOC_OPTIONS_DEFAULT_TRUE =
77
- %w(data-uri-image suppress-asciimath-dup use-xinclude
78
- source-highlighter).freeze
79
-
80
- EMPTY_ADOC_OPTIONS_DEFAULT_FALSE =
81
- %w(hierarchical-assets break-up-urls-in-tables toc-figures
82
- toc-tables toc-recommendations).freeze
83
-
84
- def attr_name_normalise(name)
85
- name.gsub("-", "").sub(/override$/, "_override").sub(/pdf$/, "_pdf")
86
- .to_sym
87
- end
88
-
89
- def extract_options(file)
90
- header = file.sub(/\n\n.*$/m, "\n")
91
- ret = ADOC_OPTIONS.each_with_object({}) do |w, acc|
92
- m = /\n:#{w}:\s+([^\n]+)\n/.match(header) or next
93
- acc[attr_name_normalise(w)] = m[1]&.strip
94
- end
95
- ret2 = EMPTY_ADOC_OPTIONS_DEFAULT_TRUE.each_with_object({}) do |w, acc|
96
- m = /\n:#{w}:([^\n]*)\n/.match(header) || [nil, "true"]
97
- acc[attr_name_normalise(w)] = (m[1].strip != "false")
98
- end
99
- ret3 = EMPTY_ADOC_OPTIONS_DEFAULT_FALSE.each_with_object({}) do |w, acc|
100
- m = /\n:#{w}:([^\n]*)\n/.match(header) || [nil, "false"]
101
- acc[attr_name_normalise(w)] = !["false"].include?(m[1].strip)
102
- end
103
- ret.merge(ret2).merge(ret3).compact
104
- end
105
- end
106
- end
107
- 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