metanorma-plugin-glossarist 0.3.6 → 0.3.7
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/.rubocop_todo.yml +104 -19
- data/lib/metanorma/plugin/glossarist/concept_path_resolver.rb +25 -8
- data/lib/metanorma/plugin/glossarist/dataset_preprocessor.rb +47 -2
- data/lib/metanorma/plugin/glossarist/dataset_registry.rb +10 -0
- data/lib/metanorma/plugin/glossarist/document.rb +1 -0
- data/lib/metanorma/plugin/glossarist/liquid/custom_blocks/with_glossarist_context.rb +1 -0
- data/lib/metanorma/plugin/glossarist/liquid_templates/_concept.liquid +2 -1
- data/lib/metanorma/plugin/glossarist/section_filter.rb +50 -0
- data/lib/metanorma/plugin/glossarist/template_renderer.rb +0 -1
- data/lib/metanorma/plugin/glossarist/version.rb +1 -1
- data/lib/metanorma-plugin-glossarist.rb +4 -0
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: df92f7c76b0f53a2ab86ce33202371f17a4d83a7c9f781196d2ffc8d88477102
|
|
4
|
+
data.tar.gz: 10c0cb1fa52fc6d9bd7b60a30910e78fe8f2dda1f23ea280b2ab84f9f2cf8a0d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ba5db22578e76a38145ded8c9fd81cfa6dd5bf5752b4e502e232ef1586ac502450918c9a7d450646407d3165f5cffafdc93571e19eb2cc5819d9106bf036a126
|
|
7
|
+
data.tar.gz: a27d8568b1a1dcdcc779374c0be6e13709cb68d921ac2ebbb0d7db3595680714c7e88d3db509574fdd717782c5827ac347bef1979d1aed707c8a6831bb740a5f
|
data/.rubocop_todo.yml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# This configuration was generated by
|
|
2
2
|
# `rubocop --auto-gen-config`
|
|
3
|
-
# on 2026-06-
|
|
3
|
+
# on 2026-06-13 04:20:36 UTC using RuboCop version 1.86.1.
|
|
4
4
|
# The point is for the user to remove these configuration records
|
|
5
5
|
# one by one as the offenses are removed from the code base.
|
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
|
@@ -11,18 +11,61 @@ Gemspec/RequiredRubyVersion:
|
|
|
11
11
|
Exclude:
|
|
12
12
|
- 'metanorma-plugin-glossarist.gemspec'
|
|
13
13
|
|
|
14
|
-
# Offense count:
|
|
14
|
+
# Offense count: 2
|
|
15
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
16
|
+
# Configuration parameters: EnforcedStyle, IndentationWidth.
|
|
17
|
+
# SupportedStyles: with_first_argument, with_fixed_indentation
|
|
18
|
+
Layout/ArgumentAlignment:
|
|
19
|
+
Exclude:
|
|
20
|
+
- 'lib/metanorma/plugin/glossarist/concept_path_resolver.rb'
|
|
21
|
+
- 'spec/metanorma/plugin/glossarist/section_spec.rb'
|
|
22
|
+
|
|
23
|
+
# Offense count: 1
|
|
24
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
25
|
+
# Configuration parameters: EnforcedStyleAlignWith.
|
|
26
|
+
# SupportedStylesAlignWith: either, start_of_block, start_of_line
|
|
27
|
+
Layout/BlockAlignment:
|
|
28
|
+
Exclude:
|
|
29
|
+
- 'spec/metanorma/plugin/glossarist/section_spec.rb'
|
|
30
|
+
|
|
31
|
+
# Offense count: 1
|
|
32
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
33
|
+
Layout/BlockEndNewline:
|
|
34
|
+
Exclude:
|
|
35
|
+
- 'spec/metanorma/plugin/glossarist/section_spec.rb'
|
|
36
|
+
|
|
37
|
+
# Offense count: 2
|
|
38
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
39
|
+
# Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle.
|
|
40
|
+
# SupportedHashRocketStyles: key, separator, table
|
|
41
|
+
# SupportedColonStyles: key, separator, table
|
|
42
|
+
# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
|
|
43
|
+
Layout/HashAlignment:
|
|
44
|
+
Exclude:
|
|
45
|
+
- 'spec/metanorma/plugin/glossarist/section_spec.rb'
|
|
46
|
+
|
|
47
|
+
# Offense count: 2
|
|
48
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
49
|
+
# Configuration parameters: Width, EnforcedStyleAlignWith, AllowedPatterns.
|
|
50
|
+
# SupportedStylesAlignWith: start_of_line, relative_to_receiver
|
|
51
|
+
Layout/IndentationWidth:
|
|
52
|
+
Exclude:
|
|
53
|
+
- 'spec/metanorma/plugin/glossarist/section_spec.rb'
|
|
54
|
+
|
|
55
|
+
# Offense count: 32
|
|
15
56
|
# This cop supports safe autocorrection (--autocorrect).
|
|
16
57
|
# Configuration parameters: Max, AllowHeredoc, AllowURI, AllowQualifiedName, URISchemes, AllowRBSInlineAnnotation, AllowCopDirectives, AllowedPatterns, SplitStrings.
|
|
17
58
|
# URISchemes: http, https
|
|
18
59
|
Layout/LineLength:
|
|
19
60
|
Exclude:
|
|
61
|
+
- 'lib/metanorma-plugin-glossarist.rb'
|
|
20
62
|
- 'lib/metanorma/plugin/glossarist/concept_path_resolver.rb'
|
|
21
63
|
- 'lib/metanorma/plugin/glossarist/dataset_preprocessor.rb'
|
|
22
64
|
- 'lib/metanorma/plugin/glossarist/liquid.rb'
|
|
23
65
|
- 'lib/metanorma/plugin/glossarist/liquid/custom_blocks/with_glossarist_context.rb'
|
|
24
66
|
- 'lib/metanorma/plugin/glossarist/liquid/drop_bracket_access.rb'
|
|
25
67
|
- 'lib/metanorma/plugin/glossarist/liquid/drops/managed_concept_data_drop.rb'
|
|
68
|
+
- 'lib/metanorma/plugin/glossarist/section_filter.rb'
|
|
26
69
|
- 'spec/metanorma/plugin/glossarist/bibliography_renderer_spec.rb'
|
|
27
70
|
- 'spec/metanorma/plugin/glossarist/bibliography_scope_spec.rb'
|
|
28
71
|
- 'spec/metanorma/plugin/glossarist/concept_filter_spec.rb'
|
|
@@ -30,21 +73,44 @@ Layout/LineLength:
|
|
|
30
73
|
- 'spec/metanorma/plugin/glossarist/liquid/drops/localization_collection_drop_spec.rb'
|
|
31
74
|
- 'spec/metanorma/plugin/glossarist/liquid/with_glossarist_context_spec.rb'
|
|
32
75
|
|
|
76
|
+
# Offense count: 1
|
|
77
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
78
|
+
Layout/MultilineBlockLayout:
|
|
79
|
+
Exclude:
|
|
80
|
+
- 'spec/metanorma/plugin/glossarist/section_spec.rb'
|
|
81
|
+
|
|
82
|
+
# Offense count: 2
|
|
83
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
84
|
+
# Configuration parameters: AllowInHeredoc.
|
|
85
|
+
Layout/TrailingWhitespace:
|
|
86
|
+
Exclude:
|
|
87
|
+
- 'lib/metanorma/plugin/glossarist/concept_path_resolver.rb'
|
|
88
|
+
- 'spec/metanorma/plugin/glossarist/section_spec.rb'
|
|
89
|
+
|
|
90
|
+
# Offense count: 1
|
|
91
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
92
|
+
# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods, NotImplementedExceptions.
|
|
93
|
+
# NotImplementedExceptions: NotImplementedError
|
|
94
|
+
Lint/UnusedMethodArgument:
|
|
95
|
+
Exclude:
|
|
96
|
+
- 'lib/metanorma/plugin/glossarist/dataset_preprocessor.rb'
|
|
97
|
+
|
|
33
98
|
# Offense count: 1
|
|
34
99
|
Lint/UselessConstantScoping:
|
|
35
100
|
Exclude:
|
|
36
101
|
- 'lib/metanorma/plugin/glossarist/dataset_preprocessor.rb'
|
|
37
102
|
|
|
38
|
-
# Offense count:
|
|
103
|
+
# Offense count: 11
|
|
39
104
|
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes, Max.
|
|
40
105
|
Metrics/AbcSize:
|
|
41
106
|
Exclude:
|
|
42
107
|
- 'lib/metanorma/plugin/glossarist/bibliography_renderer.rb'
|
|
43
108
|
- 'lib/metanorma/plugin/glossarist/concept_filter.rb'
|
|
44
109
|
- 'lib/metanorma/plugin/glossarist/dataset_preprocessor.rb'
|
|
110
|
+
- 'lib/metanorma/plugin/glossarist/liquid/custom_blocks/with_glossarist_context.rb'
|
|
45
111
|
- 'lib/metanorma/plugin/glossarist/template_renderer.rb'
|
|
46
112
|
|
|
47
|
-
# Offense count:
|
|
113
|
+
# Offense count: 6
|
|
48
114
|
# Configuration parameters: AllowedMethods, AllowedPatterns, Max.
|
|
49
115
|
Metrics/CyclomaticComplexity:
|
|
50
116
|
Exclude:
|
|
@@ -53,12 +119,12 @@ Metrics/CyclomaticComplexity:
|
|
|
53
119
|
- 'lib/metanorma/plugin/glossarist/concept_path_resolver.rb'
|
|
54
120
|
- 'lib/metanorma/plugin/glossarist/dataset_preprocessor.rb'
|
|
55
121
|
|
|
56
|
-
# Offense count:
|
|
122
|
+
# Offense count: 14
|
|
57
123
|
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
|
|
58
124
|
Metrics/MethodLength:
|
|
59
|
-
Max:
|
|
125
|
+
Max: 24
|
|
60
126
|
|
|
61
|
-
# Offense count:
|
|
127
|
+
# Offense count: 5
|
|
62
128
|
# Configuration parameters: AllowedMethods, AllowedPatterns, Max.
|
|
63
129
|
Metrics/PerceivedComplexity:
|
|
64
130
|
Exclude:
|
|
@@ -66,13 +132,7 @@ Metrics/PerceivedComplexity:
|
|
|
66
132
|
- 'lib/metanorma/plugin/glossarist/concept_filter.rb'
|
|
67
133
|
- 'lib/metanorma/plugin/glossarist/dataset_preprocessor.rb'
|
|
68
134
|
|
|
69
|
-
# Offense count:
|
|
70
|
-
# Configuration parameters: MinSize.
|
|
71
|
-
Performance/CollectionLiteralInLoop:
|
|
72
|
-
Exclude:
|
|
73
|
-
- 'lib/metanorma/plugin/glossarist/bibliography_renderer.rb'
|
|
74
|
-
|
|
75
|
-
# Offense count: 17
|
|
135
|
+
# Offense count: 19
|
|
76
136
|
# Configuration parameters: Prefixes, AllowedPatterns.
|
|
77
137
|
# Prefixes: when, with, without
|
|
78
138
|
RSpec/ContextWording:
|
|
@@ -85,23 +145,23 @@ RSpec/DescribeClass:
|
|
|
85
145
|
Exclude:
|
|
86
146
|
- 'spec/metanorma/plugin/glossarist/bibliography_scope_spec.rb'
|
|
87
147
|
|
|
88
|
-
# Offense count:
|
|
148
|
+
# Offense count: 27
|
|
89
149
|
# Configuration parameters: CountAsOne.
|
|
90
150
|
RSpec/ExampleLength:
|
|
91
151
|
Max: 35
|
|
92
152
|
|
|
93
|
-
# Offense count:
|
|
153
|
+
# Offense count: 31
|
|
94
154
|
RSpec/MultipleExpectations:
|
|
95
|
-
Max:
|
|
155
|
+
Max: 4
|
|
96
156
|
|
|
97
|
-
# Offense count:
|
|
157
|
+
# Offense count: 33
|
|
98
158
|
# Configuration parameters: EnforcedStyle, IgnoreSharedExamples.
|
|
99
159
|
# SupportedStyles: always, named_only
|
|
100
160
|
RSpec/NamedSubject:
|
|
101
161
|
Exclude:
|
|
102
162
|
- 'spec/metanorma/plugin/glossarist/dataset_preprocessor_spec.rb'
|
|
103
163
|
|
|
104
|
-
# Offense count:
|
|
164
|
+
# Offense count: 30
|
|
105
165
|
# Configuration parameters: AllowedGroups.
|
|
106
166
|
RSpec/NestedGroups:
|
|
107
167
|
Max: 6
|
|
@@ -120,6 +180,31 @@ RSpec/SpecFilePathFormat:
|
|
|
120
180
|
- 'spec/metanorma/plugin/glossarist/liquid/drops/managed_concept_data_drop_spec.rb'
|
|
121
181
|
- 'spec/metanorma/plugin/glossarist/liquid/drops/managed_concept_drop_spec.rb'
|
|
122
182
|
|
|
183
|
+
# Offense count: 1
|
|
184
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
185
|
+
# Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, AllowedMethods, AllowedPatterns, AllowBracesOnProceduralOneLiners, BracesRequiredMethods.
|
|
186
|
+
# SupportedStyles: line_count_based, semantic, braces_for_chaining, always_braces
|
|
187
|
+
# ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object
|
|
188
|
+
# FunctionalMethods: let, let!, subject, watch
|
|
189
|
+
# AllowedMethods: lambda, proc, it
|
|
190
|
+
Style/BlockDelimiters:
|
|
191
|
+
Exclude:
|
|
192
|
+
- 'spec/metanorma/plugin/glossarist/section_spec.rb'
|
|
193
|
+
|
|
194
|
+
# Offense count: 1
|
|
195
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
196
|
+
# Configuration parameters: EnforcedStyle, AllowComments.
|
|
197
|
+
# SupportedStyles: empty, nil, both
|
|
198
|
+
Style/EmptyElse:
|
|
199
|
+
Exclude:
|
|
200
|
+
- 'lib/metanorma/plugin/glossarist/concept_path_resolver.rb'
|
|
201
|
+
|
|
202
|
+
# Offense count: 1
|
|
203
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
204
|
+
Style/MultilineIfModifier:
|
|
205
|
+
Exclude:
|
|
206
|
+
- 'lib/metanorma/plugin/glossarist/concept_path_resolver.rb'
|
|
207
|
+
|
|
123
208
|
# Offense count: 2
|
|
124
209
|
# Configuration parameters: Max.
|
|
125
210
|
Style/SafeNavigationChainLength:
|
|
@@ -61,32 +61,49 @@ module Metanorma
|
|
|
61
61
|
when Array
|
|
62
62
|
nil
|
|
63
63
|
when ::Lutaml::Model::Serializable
|
|
64
|
-
|
|
64
|
+
read_attribute(obj, key)
|
|
65
65
|
when Hash
|
|
66
66
|
obj[key] || obj[key.to_s]
|
|
67
67
|
end
|
|
68
68
|
end
|
|
69
69
|
|
|
70
70
|
def resolve_managed_concept(concept, key)
|
|
71
|
-
|
|
71
|
+
if DELEGATED_TO_DATA.include?(key)
|
|
72
|
+
return read_attribute(concept.data,
|
|
73
|
+
key)
|
|
74
|
+
end
|
|
72
75
|
|
|
73
|
-
|
|
76
|
+
read_attribute(concept, key) { read_method(concept, key) }
|
|
74
77
|
rescue NoMethodError
|
|
75
78
|
nil
|
|
76
79
|
end
|
|
77
80
|
|
|
78
81
|
def resolve_data_attribute(data, key)
|
|
79
82
|
aliased = DATA_ALIASES[key]
|
|
80
|
-
|
|
83
|
+
if aliased && data.class.attributes.key?(aliased)
|
|
84
|
+
return read_attribute(data, aliased)
|
|
85
|
+
end
|
|
81
86
|
|
|
82
|
-
|
|
87
|
+
read_attribute(data, key)
|
|
83
88
|
end
|
|
84
89
|
|
|
85
|
-
|
|
90
|
+
# Reads a validated public attribute from a Lutaml::Model::Serializable
|
|
91
|
+
# object. Uses public_send because the attribute name is determined at
|
|
92
|
+
# runtime from path strings. Falls back to the block for non-attribute
|
|
93
|
+
# public methods (e.g., ManagedConcept#default_designation).
|
|
94
|
+
def read_attribute(obj, key)
|
|
86
95
|
sym = key.to_sym
|
|
87
|
-
|
|
96
|
+
if obj.class.respond_to?(:attributes) && obj.class.attributes.key?(sym)
|
|
97
|
+
obj.public_send(sym)
|
|
98
|
+
elsif block_given?
|
|
99
|
+
yield
|
|
100
|
+
end
|
|
101
|
+
end
|
|
88
102
|
|
|
89
|
-
|
|
103
|
+
# Calls a public method by name on the object. Used as a fallback for
|
|
104
|
+
# methods that aren't lutaml-model attributes (e.g., computed accessors).
|
|
105
|
+
def read_method(obj, key)
|
|
106
|
+
obj.public_send(key.to_sym)
|
|
90
107
|
end
|
|
91
108
|
|
|
92
109
|
def access_index(obj, index)
|
|
@@ -10,6 +10,7 @@ module Metanorma
|
|
|
10
10
|
class DatasetPreprocessor < Asciidoctor::Extensions::Preprocessor
|
|
11
11
|
DATASET_ATTR_REGEX = /^:glossarist-dataset:\s*(.*?)$/m
|
|
12
12
|
IMPORT_REGEX = /^glossarist::import\[(.*?)\]$/m
|
|
13
|
+
IMPORT_SECTIONS_REGEX = /^glossarist::import_sections\[(.*?)\]$/m
|
|
13
14
|
RENDER_REGEX = /^glossarist::render\[(.*?)\]$/m
|
|
14
15
|
BLOCK_REGEX = /^\[glossarist,(.+?),(.+?)\]$/m
|
|
15
16
|
BIBLIOGRAPHY_REGEX = /^glossarist::render_bibliography\[(.*?)\]$/m
|
|
@@ -26,6 +27,7 @@ module Metanorma
|
|
|
26
27
|
input_lines = reader.lines.to_enum
|
|
27
28
|
@config[:file_system] = relative_file_path(document, "")
|
|
28
29
|
@registry = DatasetRegistry.new
|
|
30
|
+
@renderer = TemplateRenderer.new(file_system: @config[:file_system])
|
|
29
31
|
@rendered_concepts = []
|
|
30
32
|
@title_depth = 2
|
|
31
33
|
@existing_bib_anchors = []
|
|
@@ -71,6 +73,8 @@ module Metanorma
|
|
|
71
73
|
process_dataset_tag(document, input_lines, liquid_doc, match)
|
|
72
74
|
elsif (match = current_line.match(RENDER_REGEX))
|
|
73
75
|
process_render_tag(liquid_doc, match)
|
|
76
|
+
elsif (match = current_line.match(IMPORT_SECTIONS_REGEX))
|
|
77
|
+
process_import_sections_tag(document, liquid_doc, match)
|
|
74
78
|
elsif (match = current_line.match(IMPORT_REGEX))
|
|
75
79
|
process_import_tag(liquid_doc, match)
|
|
76
80
|
elsif (match = current_line.match(BIBLIOGRAPHY_REGEX))
|
|
@@ -150,7 +154,7 @@ module Metanorma
|
|
|
150
154
|
return unless concept
|
|
151
155
|
|
|
152
156
|
@rendered_concepts << concept
|
|
153
|
-
renderer =
|
|
157
|
+
renderer = @renderer
|
|
154
158
|
rendered = renderer.render_concept(concept,
|
|
155
159
|
depth: @title_depth,
|
|
156
160
|
anchor_prefix: options["anchor-prefix"])
|
|
@@ -171,13 +175,54 @@ module Metanorma
|
|
|
171
175
|
concepts = ConceptFilter.new(filter_options).apply(dataset)
|
|
172
176
|
concepts = concepts.select(&:default_designation)
|
|
173
177
|
@rendered_concepts.concat(concepts)
|
|
174
|
-
renderer =
|
|
178
|
+
renderer = @renderer
|
|
175
179
|
rendered = renderer.render_concepts(concepts,
|
|
176
180
|
depth: @title_depth,
|
|
177
181
|
anchor_prefix: options["anchor-prefix"])
|
|
178
182
|
liquid_doc.add_content("\n#{rendered}")
|
|
179
183
|
end
|
|
180
184
|
|
|
185
|
+
def process_import_sections_tag(_document, liquid_doc, match)
|
|
186
|
+
@seen_glossarist = true
|
|
187
|
+
matches = match[1].split(",").map(&:strip)
|
|
188
|
+
context_name = matches[0]
|
|
189
|
+
options = parse_options(matches[1..])
|
|
190
|
+
|
|
191
|
+
sections = @registry.register_sections(context_name)
|
|
192
|
+
return unless sections && !sections.empty?
|
|
193
|
+
|
|
194
|
+
dataset = @registry.resolve_dataset(nil, context_name)
|
|
195
|
+
return unless dataset
|
|
196
|
+
|
|
197
|
+
renderer = @renderer
|
|
198
|
+
sort_by = options["sort_by"] || "term"
|
|
199
|
+
section_filter = SectionFilter.new(
|
|
200
|
+
exclude: (options["section_exclude"] || "").split("|"),
|
|
201
|
+
include: (options["section_include"] || "").split("|"),
|
|
202
|
+
)
|
|
203
|
+
filtered = section_filter.apply(sections)
|
|
204
|
+
parts = render_section_concepts(filtered, dataset, renderer,
|
|
205
|
+
sort_by, options)
|
|
206
|
+
liquid_doc.add_content("\n#{parts.join("\n\n")}")
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
def render_section_concepts(sections, dataset, renderer, sort_by,
|
|
210
|
+
options)
|
|
211
|
+
sections.filter_map do |section|
|
|
212
|
+
filter_options = { "section" => section.id, "sort_by" => sort_by }
|
|
213
|
+
concepts = ConceptFilter.new(filter_options).apply(dataset)
|
|
214
|
+
concepts = concepts.select(&:default_designation)
|
|
215
|
+
next if concepts.empty?
|
|
216
|
+
|
|
217
|
+
@rendered_concepts.concat(concepts)
|
|
218
|
+
heading = "#{'=' * (@title_depth + 1)} #{section.name || section.id}"
|
|
219
|
+
rendered = renderer.render_concepts(concepts,
|
|
220
|
+
depth: @title_depth + 1,
|
|
221
|
+
anchor_prefix: options["anchor-prefix"])
|
|
222
|
+
"#{heading}\n\n#{rendered}"
|
|
223
|
+
end
|
|
224
|
+
end
|
|
225
|
+
|
|
181
226
|
def process_bibliography(document, liquid_doc, match)
|
|
182
227
|
@seen_glossarist = true
|
|
183
228
|
dataset_name = match[1].strip
|
|
@@ -56,6 +56,16 @@ module Metanorma
|
|
|
56
56
|
found&.split("=")&.last&.strip
|
|
57
57
|
end
|
|
58
58
|
|
|
59
|
+
def register_sections(context_name)
|
|
60
|
+
dataset_path = context_path(context_name)
|
|
61
|
+
return nil unless dataset_path
|
|
62
|
+
|
|
63
|
+
@register_cache ||= {}
|
|
64
|
+
@register_cache[dataset_path] ||=
|
|
65
|
+
::Glossarist::DatasetRegister.from_directory(dataset_path)
|
|
66
|
+
@register_cache[dataset_path]&.sections
|
|
67
|
+
end
|
|
68
|
+
|
|
59
69
|
def bibliography_data
|
|
60
70
|
@bibliography_data
|
|
61
71
|
end
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
{
|
|
1
|
+
{% if anchor %}[[{{ anchor }}]]
|
|
2
|
+
{% endif %}{{ depth_marker }} {{ l10n.data.terms[0].designation }}
|
|
2
3
|
{%- for term in l10n.data.terms offset:1 %}
|
|
3
4
|
{%- if term.normative_status == "preferred" %}
|
|
4
5
|
preferred:[{{ term.designation }}]
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Metanorma
|
|
4
|
+
module Plugin
|
|
5
|
+
module Glossarist
|
|
6
|
+
# Filters an array of Glossarist::Section objects by include/exclude patterns.
|
|
7
|
+
#
|
|
8
|
+
# Pattern matching uses *substring* matching against section IDs
|
|
9
|
+
# (e.g., pattern "3" matches sections with IDs "3", "3.1", "34").
|
|
10
|
+
# For the common _arm/_mim filtering, use patterns like "_arm" and "_mim"
|
|
11
|
+
# which are specific enough to avoid false positives.
|
|
12
|
+
#
|
|
13
|
+
# @example Exclude _arm and _mim sections
|
|
14
|
+
# SectionFilter.new(exclude: ["_arm", "_mim"]).apply(sections)
|
|
15
|
+
#
|
|
16
|
+
# @example Include only _arm sections
|
|
17
|
+
# SectionFilter.new(include: ["_arm"]).apply(sections)
|
|
18
|
+
class SectionFilter
|
|
19
|
+
# @param exclude [Array<String>] substring patterns; sections whose ID
|
|
20
|
+
# contains any of these are removed
|
|
21
|
+
# @param include [Array<String>] substring patterns; only sections whose
|
|
22
|
+
# ID contains at least one of these are kept (empty = include all)
|
|
23
|
+
def initialize(exclude: [], include: [])
|
|
24
|
+
@exclude = exclude.reject(&:empty?)
|
|
25
|
+
@include = include.reject(&:empty?)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# @param sections [Array<Glossarist::Section>]
|
|
29
|
+
# @return [Array<Glossarist::Section>]
|
|
30
|
+
def apply(sections)
|
|
31
|
+
sections.select { |s| matches?(s) }
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
private
|
|
35
|
+
|
|
36
|
+
def matches?(section)
|
|
37
|
+
!excluded?(section) && included?(section)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def excluded?(section)
|
|
41
|
+
@exclude.any? { |p| section.id.include?(p) }
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def included?(section)
|
|
45
|
+
@include.empty? || @include.any? { |p| section.id.include?(p) }
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
@@ -7,6 +7,9 @@ require "glossarist"
|
|
|
7
7
|
module Metanorma
|
|
8
8
|
module Plugin
|
|
9
9
|
module Glossarist
|
|
10
|
+
TEMPLATES_DIR = File.join(File.dirname(__FILE__), "metanorma",
|
|
11
|
+
"plugin", "glossarist", "liquid_templates").freeze
|
|
12
|
+
|
|
10
13
|
autoload :BibliographyRenderer,
|
|
11
14
|
"metanorma/plugin/glossarist/bibliography_renderer"
|
|
12
15
|
autoload :ConceptFilter, "metanorma/plugin/glossarist/concept_filter"
|
|
@@ -19,6 +22,7 @@ module Metanorma
|
|
|
19
22
|
autoload :Liquid, "metanorma/plugin/glossarist/liquid"
|
|
20
23
|
autoload :LiquidRendering, "metanorma/plugin/glossarist/liquid_rendering"
|
|
21
24
|
autoload :Sanitize, "metanorma/plugin/glossarist/sanitize"
|
|
25
|
+
autoload :SectionFilter, "metanorma/plugin/glossarist/section_filter"
|
|
22
26
|
autoload :TemplateRenderer,
|
|
23
27
|
"metanorma/plugin/glossarist/template_renderer"
|
|
24
28
|
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.3.
|
|
4
|
+
version: 0.3.7
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-06-
|
|
11
|
+
date: 2026-06-13 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: asciidoctor
|
|
@@ -112,6 +112,7 @@ files:
|
|
|
112
112
|
- lib/metanorma/plugin/glossarist/liquid_rendering.rb
|
|
113
113
|
- lib/metanorma/plugin/glossarist/liquid_templates/_concept.liquid
|
|
114
114
|
- lib/metanorma/plugin/glossarist/sanitize.rb
|
|
115
|
+
- lib/metanorma/plugin/glossarist/section_filter.rb
|
|
115
116
|
- lib/metanorma/plugin/glossarist/template_renderer.rb
|
|
116
117
|
- lib/metanorma/plugin/glossarist/version.rb
|
|
117
118
|
- metanorma-plugin-glossarist.gemspec
|