metanorma-plugin-glossarist 0.2.8 → 0.2.10
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.
- checksums.yaml +4 -4
- data/README.adoc +11 -4
- data/lib/metanorma/plugin/glossarist/dataset_preprocessor.rb +102 -50
- data/lib/metanorma/plugin/glossarist/document.rb +7 -4
- data/lib/metanorma/plugin/glossarist/liquid/custom_blocks/with_glossarist_context.rb +3 -4
- data/lib/metanorma/plugin/glossarist/liquid/custom_filters/filters.rb +11 -0
- data/lib/metanorma/plugin/glossarist/liquid/multiply_local_file_system.rb +74 -0
- data/lib/metanorma/plugin/glossarist/version.rb +1 -1
- data/lib/metanorma-plugin-glossarist.rb +1 -0
- data/metanorma-plugin-glossarist.gemspec +1 -0
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c15949c9576065603f4a70e07d513df78d3042747d5506a4a80a0aaf23189b99
|
4
|
+
data.tar.gz: 7231ecb9af7c8dd43cc7ee9419d1a179ceaf468e6af248ac5ab183600afb6f27
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d0d74131f0d39fe1c75893814730551db56f6471bacbd5c18f85a53fb07c440da28d1d7fb70ab8e7cf47db63f2a92b099f866269ad46e5acec944dff9fed9808
|
7
|
+
data.tar.gz: 999be7b8d32c5204e0c7b822b4ae2536e4b7f4b327986ab86d635bd60b6d210b2556f23b9e71d1f1c940e303fe8f57eb940a13872e8941636aa4d665d1372248
|
data/README.adoc
CHANGED
@@ -83,7 +83,7 @@ Syntax:
|
|
83
83
|
|
84
84
|
[source,adoc]
|
85
85
|
------
|
86
|
-
[glossarist,{dataset-path},{filters},{context}]
|
86
|
+
[glossarist,{dataset-path},{filter=filters},{template=path/to/template},{context}]
|
87
87
|
----
|
88
88
|
// Liquid template
|
89
89
|
----
|
@@ -96,9 +96,12 @@ Where,
|
|
96
96
|
|
97
97
|
`{context}`:: The context in which the dataset is being used (e.g., `concepts`).
|
98
98
|
|
99
|
-
`{filters}`:: (Optional) Filters to apply to the dataset prior to making the
|
99
|
+
`{filter=filters}`:: (Optional) Filters to apply to the dataset prior to making the
|
100
100
|
`context` available.
|
101
101
|
|
102
|
+
`{template=path/to/template}`:: (Optional) The path to a Liquid template folder
|
103
|
+
to use for rendering.
|
104
|
+
|
102
105
|
[example]
|
103
106
|
======
|
104
107
|
Given the following Glossarist block:
|
@@ -566,7 +569,9 @@ glossarist::render_bibliography_entry[{dataset-name}, {term}]
|
|
566
569
|
|
567
570
|
Where,
|
568
571
|
|
569
|
-
`{dataset-name}`:: The name of the dataset (e.g., `dataset`)
|
572
|
+
`{dataset-name}`:: The name of the dataset (e.g., `dataset`) or the path to the
|
573
|
+
Glossarist dataset relative to the master document
|
574
|
+
(e.g., `./path/to/glossarist-dataset`).
|
570
575
|
|
571
576
|
`{term}`:: The term to render the bibliography for (e.g., `foo`).
|
572
577
|
|
@@ -614,7 +619,9 @@ glossarist::render_bibliography[{dataset-name}]
|
|
614
619
|
|
615
620
|
Where,
|
616
621
|
|
617
|
-
`{dataset-name}`:: The name of the dataset (e.g., `dataset`)
|
622
|
+
`{dataset-name}`:: The name of the dataset (e.g., `dataset`) or the path to the
|
623
|
+
Glossarist dataset relative to the master document
|
624
|
+
(e.g., `./path/to/glossarist-dataset`).
|
618
625
|
|
619
626
|
[example]
|
620
627
|
====
|
@@ -6,16 +6,18 @@ require "liquid"
|
|
6
6
|
require "asciidoctor/reader"
|
7
7
|
require "glossarist"
|
8
8
|
require "metanorma/plugin/glossarist/document"
|
9
|
+
require "metanorma/plugin/glossarist/liquid/custom_filters/filters"
|
9
10
|
|
10
11
|
module Metanorma
|
11
12
|
module Plugin
|
12
13
|
module Glossarist
|
13
14
|
class DatasetPreprocessor < Asciidoctor::Extensions::Preprocessor
|
15
|
+
include Metanorma::Plugin::Glossarist::Liquid::CustomFilters::Filters
|
16
|
+
|
14
17
|
GLOSSARIST_DATASET_REGEX = /^:glossarist-dataset:\s*(.*?)$/m.freeze
|
15
18
|
GLOSSARIST_IMPORT_REGEX = /^glossarist::import\[(.*?)\]$/m.freeze
|
16
19
|
GLOSSARIST_RENDER_REGEX = /^glossarist::render\[(.*?)\]$/m.freeze
|
17
|
-
GLOSSARIST_BLOCK_REGEX = /^\[glossarist,(.+?),(.+?)\]
|
18
|
-
GLOSSARIST_FILTER_BLOCK_REGEX = /^\[glossarist,(.+?),(filter=.+?),(.+?)\]/.freeze # rubocop:disable Layout/LineLength
|
20
|
+
GLOSSARIST_BLOCK_REGEX = /^\[glossarist,(.+?),(.+?)\]$/m.freeze
|
19
21
|
GLOSSARIST_BIBLIOGRAPHY_REGEX = /^glossarist::render_bibliography\[(.*?)\]$/m.freeze # rubocop:disable Layout/LineLength
|
20
22
|
GLOSSARIST_BIBLIOGRAPHY_ENTRY_REGEX = /^glossarist::render_bibliography_entry\[(.*?)\]$/m.freeze # rubocop:disable Layout/LineLength
|
21
23
|
|
@@ -57,13 +59,7 @@ module Metanorma
|
|
57
59
|
|
58
60
|
def process(document, reader)
|
59
61
|
input_lines = reader.lines.to_enum
|
60
|
-
|
61
|
-
file_system = ::Liquid::LocalFileSystem.new(
|
62
|
-
relative_file_path(document, ""),
|
63
|
-
)
|
64
|
-
|
65
|
-
@config[:file_system] = file_system
|
66
|
-
|
62
|
+
@config[:file_system] = relative_file_path(document, "")
|
67
63
|
processed_doc = prepare_document(document, input_lines)
|
68
64
|
log(document, processed_doc.to_s) unless @seen_glossarist.empty?
|
69
65
|
Asciidoctor::PreprocessorReader.new(document,
|
@@ -112,18 +108,14 @@ module Metanorma
|
|
112
108
|
elsif match = current_line.match(GLOSSARIST_IMPORT_REGEX)
|
113
109
|
process_import_tag(liquid_doc, match)
|
114
110
|
elsif match = current_line.match(GLOSSARIST_BIBLIOGRAPHY_REGEX)
|
115
|
-
process_bibliography(liquid_doc, match)
|
111
|
+
process_bibliography(document, liquid_doc, match)
|
116
112
|
elsif match = current_line.match(GLOSSARIST_BIBLIOGRAPHY_ENTRY_REGEX)
|
117
|
-
process_bibliography_entry(liquid_doc, match)
|
118
|
-
elsif match = current_line.match(
|
119
|
-
process_glossarist_block(document, liquid_doc, input_lines, match)
|
120
|
-
elsif match = current_line.match(GLOSSARIST_BLOCK_REGEX) # rubocop:disable Lint/DuplicateBranch
|
113
|
+
process_bibliography_entry(document, liquid_doc, match)
|
114
|
+
elsif match = current_line.match(GLOSSARIST_BLOCK_REGEX)
|
121
115
|
process_glossarist_block(document, liquid_doc, input_lines, match)
|
122
116
|
else
|
123
117
|
if /^==+ \S/.match?(current_line)
|
124
|
-
@title_depth[:value] =
|
125
|
-
current_line.sub(/ .*$/,
|
126
|
-
"").size
|
118
|
+
@title_depth[:value] = current_line.sub(/ .*$/, "").size
|
127
119
|
end
|
128
120
|
liquid_doc.add_content(current_line)
|
129
121
|
end
|
@@ -146,9 +138,9 @@ module Metanorma
|
|
146
138
|
def process_glossarist_block(document, liquid_doc, input_lines, match)
|
147
139
|
@seen_glossarist << "x"
|
148
140
|
end_mark = input_lines.next
|
149
|
-
# path = relative_file_path(document, match[1])
|
150
|
-
glossarist_params = prepare_glossarist_block_params(document, match)
|
151
141
|
|
142
|
+
glossarist_params, template =
|
143
|
+
prepare_glossarist_block_params(document, match)
|
152
144
|
glossarist_section = <<~TEMPLATE.strip
|
153
145
|
{% with_glossarist_context #{glossarist_params} %}
|
154
146
|
#{prepare_document(
|
@@ -158,23 +150,38 @@ module Metanorma
|
|
158
150
|
{% endwith_glossarist_context %}
|
159
151
|
TEMPLATE
|
160
152
|
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
)
|
153
|
+
options = { render: true }
|
154
|
+
options[:template] = template if template
|
155
|
+
|
156
|
+
liquid_doc.add_content(glossarist_section, options)
|
165
157
|
end
|
166
158
|
|
167
|
-
def prepare_glossarist_block_params(document, match)
|
159
|
+
def prepare_glossarist_block_params(document, match) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
168
160
|
path = get_context_path(document, match[1])
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
161
|
+
matched_arr = match[2].split(",").map(&:strip)
|
162
|
+
# get the last element as context name
|
163
|
+
context_name = matched_arr.last
|
164
|
+
|
165
|
+
glossarist_block_params = []
|
166
|
+
glossarist_block_params << "#{context_name}=#{path}"
|
167
|
+
|
168
|
+
template = nil
|
169
|
+
if matched_arr.size > 1
|
170
|
+
filters_or_template = matched_arr[0..-2]
|
171
|
+
filters_or_template.each do |item|
|
172
|
+
if item.start_with?("filter=")
|
173
|
+
filters = item.gsub(/^filter=/, "").strip
|
174
|
+
glossarist_block_params << filters
|
175
|
+
elsif item.start_with?("template=")
|
176
|
+
template = relative_file_path(
|
177
|
+
document,
|
178
|
+
item.gsub(/^template=/, "").strip,
|
179
|
+
)
|
180
|
+
end
|
181
|
+
end
|
177
182
|
end
|
183
|
+
|
184
|
+
[glossarist_block_params.join(";"), template]
|
178
185
|
end
|
179
186
|
|
180
187
|
def get_context_path(document, key) # rubocop:disable Metrics/MethodLength
|
@@ -195,32 +202,44 @@ module Metanorma
|
|
195
202
|
|
196
203
|
def process_render_tag(liquid_doc, match)
|
197
204
|
@seen_glossarist << "x"
|
198
|
-
|
205
|
+
matches = match[1].split(",").map(&:strip)
|
206
|
+
|
207
|
+
context_name = matches[0]
|
208
|
+
concept_name = matches[1]
|
209
|
+
render_options = matches[2..-1]
|
199
210
|
|
200
211
|
liquid_doc.add_content(
|
201
|
-
concept_template(context_name.strip, concept_name.strip
|
212
|
+
concept_template(context_name.strip, concept_name.strip,
|
213
|
+
render_options),
|
202
214
|
)
|
203
215
|
end
|
204
216
|
|
205
|
-
def process_import_tag(liquid_doc, match) # rubocop:disable Metrics/AbcSize
|
217
|
+
def process_import_tag(liquid_doc, match) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
206
218
|
@seen_glossarist << "x"
|
207
|
-
|
208
|
-
|
219
|
+
matches = match[1].split(",").map(&:strip)
|
220
|
+
context_name = matches[0]
|
221
|
+
render_options = matches[1..-1]
|
222
|
+
dataset = @datasets[context_name.strip]
|
209
223
|
|
210
224
|
liquid_doc.add_content(
|
211
225
|
dataset.map do |concept|
|
212
226
|
concept_name = concept.data.localizations["eng"].data
|
213
227
|
.terms[0].designation
|
214
|
-
concept_template(context_name, concept_name)
|
228
|
+
concept_template(context_name, concept_name, render_options)
|
215
229
|
end.join("\n"),
|
216
230
|
)
|
217
231
|
end
|
218
232
|
|
219
|
-
def process_bibliography(liquid_doc, match)
|
233
|
+
def process_bibliography(document, liquid_doc, match) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
220
234
|
@seen_glossarist << "x"
|
221
235
|
dataset_name = match[1].strip
|
222
236
|
dataset = @datasets[dataset_name]
|
223
237
|
|
238
|
+
if dataset.nil? || @datasets.empty?
|
239
|
+
path = relative_file_path(document, dataset_name)
|
240
|
+
dataset = load_dataset_from_path(path)
|
241
|
+
end
|
242
|
+
|
224
243
|
liquid_doc.add_content(
|
225
244
|
dataset.map do |concept|
|
226
245
|
concept_bibliography(concept)
|
@@ -228,11 +247,12 @@ module Metanorma
|
|
228
247
|
)
|
229
248
|
end
|
230
249
|
|
231
|
-
def process_bibliography_entry(liquid_doc, match)
|
250
|
+
def process_bibliography_entry(document, liquid_doc, match)
|
232
251
|
@seen_glossarist << "x"
|
233
252
|
dataset_name, concept_name = match[1].split(",").map(&:strip)
|
234
|
-
concept = get_concept(dataset_name, concept_name)
|
253
|
+
concept = get_concept(dataset_name, concept_name, document)
|
235
254
|
bibliography = concept_bibliography(concept)
|
255
|
+
|
236
256
|
if bibliography
|
237
257
|
liquid_doc.add_content(bibliography)
|
238
258
|
end
|
@@ -257,15 +277,19 @@ module Metanorma
|
|
257
277
|
contexts.split(";").map do |context|
|
258
278
|
context_name, file_path = context.split(":").map(&:strip)
|
259
279
|
path = relative_file_path(document, file_path)
|
260
|
-
|
261
|
-
dataset = ::Glossarist::ManagedConceptCollection.new
|
262
|
-
dataset.load_from_files(path)
|
280
|
+
dataset = load_dataset_from_path(path)
|
263
281
|
@datasets[context_name] = dataset.map(&:to_liquid)
|
264
282
|
|
265
283
|
"#{context_name}=#{path}"
|
266
284
|
end
|
267
285
|
end
|
268
286
|
|
287
|
+
def load_dataset_from_path(path)
|
288
|
+
dataset = ::Glossarist::ManagedConceptCollection.new
|
289
|
+
dataset.load_from_files(path)
|
290
|
+
dataset
|
291
|
+
end
|
292
|
+
|
269
293
|
def relative_file_path(document, file_path)
|
270
294
|
docfile_directory = File.dirname(
|
271
295
|
document.attributes["docfile"] || ".",
|
@@ -275,9 +299,13 @@ module Metanorma
|
|
275
299
|
.system_path(file_path, docfile_directory)
|
276
300
|
end
|
277
301
|
|
278
|
-
def concept_template(dataset_name, concept_name)
|
302
|
+
def concept_template(dataset_name, concept_name, options = [])
|
303
|
+
options = options_to_hash(options)
|
304
|
+
|
279
305
|
<<~CONCEPT_TEMPLATE
|
306
|
+
[[#{identifier(dataset_name, concept_name, options)}]]
|
280
307
|
#{'=' * (@title_depth[:value] + 1)} #{concept_title(dataset_name, concept_name)}
|
308
|
+
|
281
309
|
#{alt_terms(dataset_name, concept_name)}
|
282
310
|
|
283
311
|
#{concept_definition(dataset_name, concept_name)}
|
@@ -290,14 +318,38 @@ module Metanorma
|
|
290
318
|
CONCEPT_TEMPLATE
|
291
319
|
end
|
292
320
|
|
293
|
-
def get_concept(dataset_name, concept_name)
|
294
|
-
@datasets[dataset_name]
|
321
|
+
def get_concept(dataset_name, concept_name, document = nil)
|
322
|
+
dataset = @datasets[dataset_name]
|
323
|
+
|
324
|
+
if document && dataset.nil?
|
325
|
+
path = relative_file_path(document, dataset_name)
|
326
|
+
dataset = load_dataset_from_path(path)
|
327
|
+
end
|
328
|
+
|
329
|
+
dataset.find do |c|
|
295
330
|
c.data.localizations["eng"]
|
296
331
|
.data.terms[0]
|
297
332
|
.designation == concept_name
|
298
333
|
end
|
299
334
|
end
|
300
335
|
|
336
|
+
def identifier(dataset_name, concept_name, options = {})
|
337
|
+
prefix = options["anchor-prefix"].to_s if options["anchor-prefix"]
|
338
|
+
concept = get_concept(dataset_name, concept_name)
|
339
|
+
|
340
|
+
id = "#{prefix}#{concept.data.id}"
|
341
|
+
# id starts with digits 0-9
|
342
|
+
return id if id.start_with?(/[0-9]/)
|
343
|
+
|
344
|
+
Metanorma::Utils.to_ncname(id.gsub(":", "_"))
|
345
|
+
end
|
346
|
+
|
347
|
+
def options_to_hash(options_arr)
|
348
|
+
return {} if !options_arr || options_arr.empty?
|
349
|
+
|
350
|
+
options_arr.map { |option| option.split("=") }.to_h
|
351
|
+
end
|
352
|
+
|
301
353
|
def concept_title(dataset_name, concept_name)
|
302
354
|
concept = get_concept(dataset_name, concept_name)
|
303
355
|
concept.data.localizations["eng"].data.terms[0].designation
|
@@ -307,7 +359,7 @@ module Metanorma
|
|
307
359
|
concept = get_concept(dataset_name, concept_name)
|
308
360
|
definition = concept.data.localizations["eng"].data
|
309
361
|
.definition[0].content
|
310
|
-
definition.to_s
|
362
|
+
sanitize_references(definition.to_s)
|
311
363
|
end
|
312
364
|
|
313
365
|
def alt_terms(dataset_name, concept_name) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
@@ -333,7 +385,7 @@ module Metanorma
|
|
333
385
|
examples.each do |example|
|
334
386
|
content = <<~EXAMPLE
|
335
387
|
[example]
|
336
|
-
#{example.content}
|
388
|
+
#{sanitize_references(example.content)}
|
337
389
|
|
338
390
|
EXAMPLE
|
339
391
|
result << content
|
@@ -351,7 +403,7 @@ module Metanorma
|
|
351
403
|
content = <<~NOTE
|
352
404
|
[NOTE]
|
353
405
|
====
|
354
|
-
#{note.content}
|
406
|
+
#{sanitize_references(note.content)}
|
355
407
|
====
|
356
408
|
|
357
409
|
NOTE
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require_relative "liquid/custom_blocks/with_glossarist_context"
|
4
4
|
require_relative "liquid/custom_filters/filters"
|
5
|
+
require_relative "liquid/multiply_local_file_system"
|
5
6
|
|
6
7
|
module Metanorma
|
7
8
|
module Plugin
|
@@ -16,7 +17,7 @@ module Metanorma
|
|
16
17
|
|
17
18
|
def add_content(content, options = {})
|
18
19
|
@content << if options[:render]
|
19
|
-
render_liquid(content)
|
20
|
+
render_liquid(content, options)
|
20
21
|
else
|
21
22
|
content
|
22
23
|
end
|
@@ -26,11 +27,13 @@ module Metanorma
|
|
26
27
|
@content.compact.join("\n")
|
27
28
|
end
|
28
29
|
|
29
|
-
def render_liquid(file_content)
|
30
|
+
def render_liquid(file_content, options = {}) # rubocop:disable Metrics/AbcSize
|
31
|
+
include_paths = [file_system, options[:template]].compact
|
30
32
|
template = ::Liquid::Template
|
31
33
|
.parse(file_content, environment: create_liquid_environment)
|
32
|
-
|
33
|
-
|
34
|
+
template.registers[:file_system] = ::Metanorma::Plugin::Glossarist::Liquid::LocalFileSystem.new(
|
35
|
+
include_paths, ["%s.liquid", "_%s.liquid", "_%s.adoc"]
|
36
|
+
)
|
34
37
|
rendered_template = template.render(strict_variables: false,
|
35
38
|
error_mode: :warn)
|
36
39
|
|
@@ -14,13 +14,12 @@ module Metanorma
|
|
14
14
|
@contexts = []
|
15
15
|
@filters = {}
|
16
16
|
|
17
|
-
contexts, filters = markup.split(";", 2)
|
17
|
+
contexts, filters = markup.strip.split(";", 2)
|
18
18
|
|
19
19
|
if filters && !filters.empty?
|
20
|
-
filters.strip.gsub(/^['"]|['"]$/,
|
21
|
-
|
20
|
+
filters = filters.strip.gsub(/^['"]|['"]$/, "").split(";")
|
21
|
+
filters.each do |filter|
|
22
22
|
property, value = filter.split("=")
|
23
|
-
|
24
23
|
@filters[property] = value
|
25
24
|
end
|
26
25
|
end
|
@@ -6,10 +6,21 @@ module Metanorma
|
|
6
6
|
module Liquid
|
7
7
|
module CustomFilters
|
8
8
|
module Filters
|
9
|
+
REF_REGEX = /{{([^,]{1,500}),([^\}]{1,500})}}(.*?)$/s.freeze
|
10
|
+
|
9
11
|
def values(list)
|
10
12
|
list.values
|
11
13
|
end
|
12
14
|
|
15
|
+
def sanitize_references(str)
|
16
|
+
return str unless str.match?(REF_REGEX)
|
17
|
+
|
18
|
+
matched_str = str.match(REF_REGEX)
|
19
|
+
urn = Metanorma::Utils.to_ncname(matched_str[1]).gsub(":", "_")
|
20
|
+
|
21
|
+
"{{#{urn},#{matched_str[2]}}}#{matched_str[3]}"
|
22
|
+
end
|
23
|
+
|
13
24
|
def terminological_data(term)
|
14
25
|
result = []
|
15
26
|
|
@@ -0,0 +1,74 @@
|
|
1
|
+
module Metanorma
|
2
|
+
module Plugin
|
3
|
+
module Glossarist
|
4
|
+
module Liquid
|
5
|
+
class LocalFileSystem
|
6
|
+
attr_accessor :roots, :patterns
|
7
|
+
|
8
|
+
def initialize(roots, patterns = ["_%s.liquid"])
|
9
|
+
@roots = roots
|
10
|
+
@patterns = patterns
|
11
|
+
end
|
12
|
+
|
13
|
+
def read_template_file(template_path)
|
14
|
+
full_path = full_path(template_path)
|
15
|
+
|
16
|
+
unless File.exist?(full_path)
|
17
|
+
raise FileSystemError, "No such template '#{template_path}'"
|
18
|
+
end
|
19
|
+
|
20
|
+
File.read(full_path)
|
21
|
+
end
|
22
|
+
|
23
|
+
def full_path(template_path) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
|
24
|
+
unless %r{\A[^./][a-zA-Z0-9_/]+\z}.match?(template_path)
|
25
|
+
raise ::Liquid::FileSystemError,
|
26
|
+
"Illegal template name '#{template_path}'"
|
27
|
+
end
|
28
|
+
|
29
|
+
result_path = if template_path.include?("/")
|
30
|
+
roots
|
31
|
+
.map do |root|
|
32
|
+
patterns.map do |pattern|
|
33
|
+
File.join(
|
34
|
+
root,
|
35
|
+
File.dirname(template_path),
|
36
|
+
pattern % File.basename(template_path),
|
37
|
+
)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
.flatten
|
41
|
+
.find { |path| File.file?(path) }
|
42
|
+
else
|
43
|
+
roots
|
44
|
+
.map do |root|
|
45
|
+
patterns.map do |pattern|
|
46
|
+
File.join(root, pattern % template_path)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
.flatten
|
50
|
+
.find { |path| File.file?(path) }
|
51
|
+
end
|
52
|
+
|
53
|
+
if result_path.nil?
|
54
|
+
raise ::Liquid::FileSystemError,
|
55
|
+
"No documents in template path: " \
|
56
|
+
" #{File.expand_path(template_path)}"
|
57
|
+
end
|
58
|
+
|
59
|
+
unless roots.any? do |root|
|
60
|
+
File.expand_path(result_path).start_with?(
|
61
|
+
File.expand_path(root),
|
62
|
+
)
|
63
|
+
end
|
64
|
+
raise ::Liquid::FileSystemError,
|
65
|
+
"Illegal template path '#{File.expand_path(result_path)}'"
|
66
|
+
end
|
67
|
+
|
68
|
+
result_path
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metanorma-plugin-glossarist
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-10-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciidoctor
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: metanorma-utils
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.10'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.10'
|
55
69
|
description: Metanorma plugin for glossarist
|
56
70
|
email:
|
57
71
|
- open.source@ribose.com
|
@@ -77,6 +91,7 @@ files:
|
|
77
91
|
- lib/metanorma/plugin/glossarist/document.rb
|
78
92
|
- lib/metanorma/plugin/glossarist/liquid/custom_blocks/with_glossarist_context.rb
|
79
93
|
- lib/metanorma/plugin/glossarist/liquid/custom_filters/filters.rb
|
94
|
+
- lib/metanorma/plugin/glossarist/liquid/multiply_local_file_system.rb
|
80
95
|
- lib/metanorma/plugin/glossarist/version.rb
|
81
96
|
- metanorma-plugin-glossarist.gemspec
|
82
97
|
homepage: https://github.com/metanorma/metanorma-plugin-glossarist
|