metanorma-plugin-glossarist 0.3.3 → 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/.gitignore +6 -6
- data/.rubocop_todo.yml +90 -196
- data/Gemfile +6 -5
- data/README.adoc +11 -1
- data/lib/metanorma/plugin/glossarist/bibliography_renderer.rb +54 -12
- data/lib/metanorma/plugin/glossarist/concept_filter.rb +22 -40
- data/lib/metanorma/plugin/glossarist/concept_path_resolver.rb +117 -0
- data/lib/metanorma/plugin/glossarist/dataset_preprocessor.rb +98 -82
- data/lib/metanorma/plugin/glossarist/dataset_registry.rb +108 -0
- data/lib/metanorma/plugin/glossarist/document.rb +9 -20
- data/lib/metanorma/plugin/glossarist/liquid/custom_blocks/with_glossarist_context.rb +47 -60
- data/lib/metanorma/plugin/glossarist/liquid/custom_filters/filters.rb +10 -4
- data/lib/metanorma/plugin/glossarist/liquid/custom_filters.rb +14 -0
- data/lib/metanorma/plugin/glossarist/liquid/drop_bracket_access.rb +36 -0
- data/lib/metanorma/plugin/glossarist/liquid/drops/localization_collection_drop.rb +47 -0
- data/lib/metanorma/plugin/glossarist/liquid/drops/managed_concept_data_drop.rb +29 -0
- data/lib/metanorma/plugin/glossarist/liquid/drops/managed_concept_drop.rb +45 -0
- data/lib/metanorma/plugin/glossarist/liquid/multiply_local_file_system.rb +1 -1
- data/lib/metanorma/plugin/glossarist/liquid.rb +26 -0
- data/lib/metanorma/plugin/glossarist/liquid_rendering.rb +26 -0
- data/lib/metanorma/plugin/glossarist/liquid_templates/_concept.liquid +52 -0
- data/lib/metanorma/plugin/glossarist/sanitize.rb +6 -4
- data/lib/metanorma/plugin/glossarist/section_filter.rb +50 -0
- data/lib/metanorma/plugin/glossarist/template_renderer.rb +112 -0
- data/lib/metanorma/plugin/glossarist/version.rb +1 -1
- data/lib/metanorma-plugin-glossarist.rb +30 -8
- data/metanorma-plugin-glossarist.gemspec +1 -1
- metadata +18 -9
- data/lib/metanorma/plugin/glossarist/citation_helper.rb +0 -13
- data/lib/metanorma/plugin/glossarist/concept_renderer.rb +0 -93
- data/lib/metanorma/plugin/glossarist/concept_serializer.rb +0 -27
|
@@ -2,11 +2,33 @@
|
|
|
2
2
|
|
|
3
3
|
require "metanorma/plugin/glossarist/version"
|
|
4
4
|
require "metanorma-utils"
|
|
5
|
-
require "
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
require "glossarist"
|
|
6
|
+
|
|
7
|
+
module Metanorma
|
|
8
|
+
module Plugin
|
|
9
|
+
module Glossarist
|
|
10
|
+
TEMPLATES_DIR = File.join(File.dirname(__FILE__), "metanorma",
|
|
11
|
+
"plugin", "glossarist", "liquid_templates").freeze
|
|
12
|
+
|
|
13
|
+
autoload :BibliographyRenderer,
|
|
14
|
+
"metanorma/plugin/glossarist/bibliography_renderer"
|
|
15
|
+
autoload :ConceptFilter, "metanorma/plugin/glossarist/concept_filter"
|
|
16
|
+
autoload :ConceptPathResolver,
|
|
17
|
+
"metanorma/plugin/glossarist/concept_path_resolver"
|
|
18
|
+
autoload :DatasetPreprocessor,
|
|
19
|
+
"metanorma/plugin/glossarist/dataset_preprocessor"
|
|
20
|
+
autoload :DatasetRegistry, "metanorma/plugin/glossarist/dataset_registry"
|
|
21
|
+
autoload :Document, "metanorma/plugin/glossarist/document"
|
|
22
|
+
autoload :Liquid, "metanorma/plugin/glossarist/liquid"
|
|
23
|
+
autoload :LiquidRendering, "metanorma/plugin/glossarist/liquid_rendering"
|
|
24
|
+
autoload :Sanitize, "metanorma/plugin/glossarist/sanitize"
|
|
25
|
+
autoload :SectionFilter, "metanorma/plugin/glossarist/section_filter"
|
|
26
|
+
autoload :TemplateRenderer,
|
|
27
|
+
"metanorma/plugin/glossarist/template_renderer"
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
Metanorma::Plugin::Glossarist::Liquid::PolyfillIndexedAccess.apply!
|
|
33
|
+
Metanorma::Plugin::Glossarist::Liquid::WithGlossaristContext.register!
|
|
34
|
+
Metanorma::Plugin::Glossarist::Liquid::CustomFilters::Filters.register!
|
|
@@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
|
|
|
26
26
|
spec.required_ruby_version = ">= 3.1.0"
|
|
27
27
|
|
|
28
28
|
spec.add_dependency "asciidoctor"
|
|
29
|
-
spec.add_dependency "glossarist", "~> 2.
|
|
29
|
+
spec.add_dependency "glossarist", "~> 2.8", ">= 2.8.7"
|
|
30
30
|
spec.add_dependency "liquid"
|
|
31
31
|
spec.add_dependency "metanorma-utils"
|
|
32
32
|
spec.metadata["rubygems_mfa_required"] = "true"
|
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-
|
|
11
|
+
date: 2026-06-13 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: asciidoctor
|
|
@@ -30,20 +30,20 @@ dependencies:
|
|
|
30
30
|
requirements:
|
|
31
31
|
- - "~>"
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: '2.
|
|
33
|
+
version: '2.8'
|
|
34
34
|
- - ">="
|
|
35
35
|
- !ruby/object:Gem::Version
|
|
36
|
-
version: 2.
|
|
36
|
+
version: 2.8.7
|
|
37
37
|
type: :runtime
|
|
38
38
|
prerelease: false
|
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|
|
40
40
|
requirements:
|
|
41
41
|
- - "~>"
|
|
42
42
|
- !ruby/object:Gem::Version
|
|
43
|
-
version: '2.
|
|
43
|
+
version: '2.8'
|
|
44
44
|
- - ">="
|
|
45
45
|
- !ruby/object:Gem::Version
|
|
46
|
-
version: 2.
|
|
46
|
+
version: 2.8.7
|
|
47
47
|
- !ruby/object:Gem::Dependency
|
|
48
48
|
name: liquid
|
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -95,16 +95,25 @@ files:
|
|
|
95
95
|
- bin/setup
|
|
96
96
|
- lib/metanorma-plugin-glossarist.rb
|
|
97
97
|
- lib/metanorma/plugin/glossarist/bibliography_renderer.rb
|
|
98
|
-
- lib/metanorma/plugin/glossarist/citation_helper.rb
|
|
99
98
|
- lib/metanorma/plugin/glossarist/concept_filter.rb
|
|
100
|
-
- lib/metanorma/plugin/glossarist/
|
|
101
|
-
- lib/metanorma/plugin/glossarist/concept_serializer.rb
|
|
99
|
+
- lib/metanorma/plugin/glossarist/concept_path_resolver.rb
|
|
102
100
|
- lib/metanorma/plugin/glossarist/dataset_preprocessor.rb
|
|
101
|
+
- lib/metanorma/plugin/glossarist/dataset_registry.rb
|
|
103
102
|
- lib/metanorma/plugin/glossarist/document.rb
|
|
103
|
+
- lib/metanorma/plugin/glossarist/liquid.rb
|
|
104
104
|
- lib/metanorma/plugin/glossarist/liquid/custom_blocks/with_glossarist_context.rb
|
|
105
|
+
- lib/metanorma/plugin/glossarist/liquid/custom_filters.rb
|
|
105
106
|
- lib/metanorma/plugin/glossarist/liquid/custom_filters/filters.rb
|
|
107
|
+
- lib/metanorma/plugin/glossarist/liquid/drop_bracket_access.rb
|
|
108
|
+
- lib/metanorma/plugin/glossarist/liquid/drops/localization_collection_drop.rb
|
|
109
|
+
- lib/metanorma/plugin/glossarist/liquid/drops/managed_concept_data_drop.rb
|
|
110
|
+
- lib/metanorma/plugin/glossarist/liquid/drops/managed_concept_drop.rb
|
|
106
111
|
- lib/metanorma/plugin/glossarist/liquid/multiply_local_file_system.rb
|
|
112
|
+
- lib/metanorma/plugin/glossarist/liquid_rendering.rb
|
|
113
|
+
- lib/metanorma/plugin/glossarist/liquid_templates/_concept.liquid
|
|
107
114
|
- lib/metanorma/plugin/glossarist/sanitize.rb
|
|
115
|
+
- lib/metanorma/plugin/glossarist/section_filter.rb
|
|
116
|
+
- lib/metanorma/plugin/glossarist/template_renderer.rb
|
|
108
117
|
- lib/metanorma/plugin/glossarist/version.rb
|
|
109
118
|
- metanorma-plugin-glossarist.gemspec
|
|
110
119
|
homepage: https://github.com/metanorma/metanorma-plugin-glossarist
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Metanorma
|
|
4
|
-
module Plugin
|
|
5
|
-
module Glossarist
|
|
6
|
-
class ConceptRenderer
|
|
7
|
-
include CitationHelper
|
|
8
|
-
TERM_TYPES = %w[preferred admitted deprecated].freeze
|
|
9
|
-
|
|
10
|
-
def initialize(concept, depth:, anchor_prefix: nil)
|
|
11
|
-
@concept = concept
|
|
12
|
-
@depth = depth
|
|
13
|
-
@anchor_prefix = anchor_prefix
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def render
|
|
17
|
-
sections = [concept_header]
|
|
18
|
-
sections << alt_terms_section
|
|
19
|
-
sections << definition_section
|
|
20
|
-
sections << examples_section
|
|
21
|
-
sections << notes_section
|
|
22
|
-
sections << sources_section
|
|
23
|
-
sections.compact.join("\n\n")
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
private
|
|
27
|
-
|
|
28
|
-
def eng_l10n
|
|
29
|
-
@eng_l10n ||= @concept.localization("eng")
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def concept_header
|
|
33
|
-
"[[#{anchor_id}]]\n#{heading_line}"
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
def anchor_id
|
|
37
|
-
id = "#{@anchor_prefix}#{@concept.data.id}"
|
|
38
|
-
id.match?(/\A\d/) ? id : Metanorma::Utils.to_ncname(id.gsub(":", "_"))
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
def heading_line
|
|
42
|
-
"#{'=' * (@depth + 1)} #{term_designation}"
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
def term_designation
|
|
46
|
-
eng_l10n.terms.first&.designation.to_s
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
def alt_terms_section
|
|
50
|
-
terms = eng_l10n.terms[1..].map do |term|
|
|
51
|
-
type = TERM_TYPES.include?(term.normative_status) ? term.normative_status : "alt"
|
|
52
|
-
"#{type}:[#{term.designation}]"
|
|
53
|
-
end
|
|
54
|
-
terms.empty? ? nil : terms.join("\n")
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
def definition_section
|
|
58
|
-
content = eng_l10n.definition.first&.content
|
|
59
|
-
return nil unless content
|
|
60
|
-
|
|
61
|
-
Sanitize.references(content.to_s)
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
def examples_section
|
|
65
|
-
examples = eng_l10n.examples.map do |example|
|
|
66
|
-
"[example]\n#{Sanitize.references(example.content.to_s)}"
|
|
67
|
-
end
|
|
68
|
-
examples.empty? ? nil : examples.join("\n")
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
def notes_section
|
|
72
|
-
notes = eng_l10n.notes.map do |note|
|
|
73
|
-
"[NOTE]\n====\n#{Sanitize.references(note.content.to_s)}\n===="
|
|
74
|
-
end
|
|
75
|
-
notes.empty? ? nil : notes.join("\n")
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
def sources_section
|
|
79
|
-
sources = eng_l10n.sources.filter_map do |source|
|
|
80
|
-
ref = citation_ref_label(source.origin)
|
|
81
|
-
next if ref.nil? || ref.empty?
|
|
82
|
-
next unless source.origin.locality&.type == "clause"
|
|
83
|
-
|
|
84
|
-
anchor = ref.gsub(%r{[ /:]}, "_")
|
|
85
|
-
clause = source.origin.locality.reference_from
|
|
86
|
-
"[.source]\n<<#{anchor},#{clause}>>"
|
|
87
|
-
end
|
|
88
|
-
sources.empty? ? nil : sources.join("\n")
|
|
89
|
-
end
|
|
90
|
-
end
|
|
91
|
-
end
|
|
92
|
-
end
|
|
93
|
-
end
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Metanorma
|
|
4
|
-
module Plugin
|
|
5
|
-
module Glossarist
|
|
6
|
-
class ConceptSerializer
|
|
7
|
-
def initialize(concept)
|
|
8
|
-
@concept = concept
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def to_h
|
|
12
|
-
data = @concept.data.to_hash
|
|
13
|
-
data["localizations"] = localizations_hash unless @concept.localizations.empty?
|
|
14
|
-
{ "data" => data.compact }
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
private
|
|
18
|
-
|
|
19
|
-
def localizations_hash
|
|
20
|
-
@concept.localizations.to_h do |l10n|
|
|
21
|
-
[l10n.language_code, l10n.to_hash]
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|