al_utils 0.1.0

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 (6) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +5 -0
  3. data/LICENSE +20 -0
  4. data/README.md +33 -0
  5. data/lib/al_utils.rb +73 -0
  6. metadata +145 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 4172a509d0b614f27b124ade7a6e1cd19080ad32572cdc1ac3b4c6cb7e62f18b
4
+ data.tar.gz: 50807ddc96678be6a77e60c039e308fd2666e1fcb5076d89fd7a8edb57e18a90
5
+ SHA512:
6
+ metadata.gz: f8c5b1080262e083da3ede8ede56028e604b685a0d0fcb04e71911f28335eaf1e4ebdb724bbb053ba51c7dc405ec773d6fbb9bd277e25521d7ca270de4bb481f
7
+ data.tar.gz: 03e42c3e94f31a83bf2248f683016badd590ba0946dc1519435b0befc339d52c36c2228d50874a98d56ea4818aa87a6de997ab9ec66fdbd6cc1d9c31e096faa7
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0 - 2026-02-07
4
+ - Initial gem release.
5
+ - Added reusable utility tags/filters extracted from al-folio.
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2025 Maruan Al-Shedivat.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # Al-Utils
2
+
3
+ A Jekyll plugin that provides utility Liquid tags and filters extracted from al-folio.
4
+
5
+ ## Features
6
+
7
+ - `{% details %}` block tag
8
+ - `{% file_exists %}` tag
9
+ - `remove_accents` filter
10
+ - `hideCustomBibtex` filter
11
+
12
+ ## Installation
13
+
14
+ Add this line to your Jekyll site's Gemfile:
15
+
16
+ ```ruby
17
+ gem 'al_utils'
18
+ ```
19
+
20
+ Then run:
21
+
22
+ ```bash
23
+ bundle install
24
+ ```
25
+
26
+ ## Usage
27
+
28
+ Add the plugin to `_config.yml`:
29
+
30
+ ```yaml
31
+ plugins:
32
+ - al_utils
33
+ ```
data/lib/al_utils.rb ADDED
@@ -0,0 +1,73 @@
1
+ require 'jekyll'
2
+ require 'i18n'
3
+
4
+ module AlUtils
5
+ module Tags
6
+ class DetailsTag < Liquid::Block
7
+ def initialize(tag_name, markup, tokens)
8
+ super
9
+ @caption = markup
10
+ end
11
+
12
+ def render(context)
13
+ site = context.registers[:site]
14
+ converter = site.find_converter_instance(::Jekyll::Converters::Markdown)
15
+ caption = converter.convert(@caption).gsub(%r{</?p[^>]*>}, '').chomp
16
+ body = converter.convert(super(context))
17
+ "<details><summary>#{caption}</summary>#{body}</details>"
18
+ end
19
+ end
20
+
21
+ class FileExistsTag < Liquid::Tag
22
+ def initialize(tag_name, path, tokens)
23
+ super
24
+ @path = path
25
+ end
26
+
27
+ def render(context)
28
+ url = Liquid::Template.parse(@path).render(context)
29
+ site_source = context.registers[:site].config['source']
30
+ file_path = "#{site_source}/#{url}"
31
+ File.exist?(file_path.strip).to_s
32
+ end
33
+ end
34
+ end
35
+
36
+ module Filters
37
+ module HideCustomBibtex
38
+ def hideCustomBibtex(input)
39
+ keywords = @context.registers[:site].config['filtered_bibtex_keywords']
40
+ keywords.each do |keyword|
41
+ input = input.gsub(/^.*\b#{keyword}\b *= *\{.*$\n/, '')
42
+ end
43
+
44
+ input.gsub(/^.*\bauthor\b *= *\{.*$\n/) { |line| line.gsub(/[*†‡§¶‖&^]/, '') }
45
+ end
46
+ end
47
+
48
+ module CleanString
49
+ class RemoveAccents
50
+ I18n.config.available_locales = :en
51
+
52
+ attr_accessor :string
53
+
54
+ def initialize(string:)
55
+ self.string = string
56
+ end
57
+
58
+ def digest!
59
+ I18n.transliterate(string)
60
+ end
61
+ end
62
+
63
+ def remove_accents(string)
64
+ RemoveAccents.new(string: string).digest!
65
+ end
66
+ end
67
+ end
68
+ end
69
+
70
+ Liquid::Template.register_tag('details', AlUtils::Tags::DetailsTag)
71
+ Liquid::Template.register_tag('file_exists', AlUtils::Tags::FileExistsTag)
72
+ Liquid::Template.register_filter(AlUtils::Filters::HideCustomBibtex)
73
+ Liquid::Template.register_filter(AlUtils::Filters::CleanString)
metadata ADDED
@@ -0,0 +1,145 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: al_utils
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - al-org
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2026-02-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: jekyll
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '3.9'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '5.0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '3.9'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '5.0'
33
+ - !ruby/object:Gem::Dependency
34
+ name: liquid
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '4.0'
40
+ - - "<"
41
+ - !ruby/object:Gem::Version
42
+ version: '6.0'
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: '4.0'
50
+ - - "<"
51
+ - !ruby/object:Gem::Version
52
+ version: '6.0'
53
+ - !ruby/object:Gem::Dependency
54
+ name: i18n
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: '1.8'
60
+ - - "<"
61
+ - !ruby/object:Gem::Version
62
+ version: '2.0'
63
+ type: :runtime
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '1.8'
70
+ - - "<"
71
+ - !ruby/object:Gem::Version
72
+ version: '2.0'
73
+ - !ruby/object:Gem::Dependency
74
+ name: bundler
75
+ requirement: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: '2.0'
80
+ - - "<"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.0'
83
+ type: :development
84
+ prerelease: false
85
+ version_requirements: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '2.0'
90
+ - - "<"
91
+ - !ruby/object:Gem::Version
92
+ version: '3.0'
93
+ - !ruby/object:Gem::Dependency
94
+ name: rake
95
+ requirement: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - "~>"
98
+ - !ruby/object:Gem::Version
99
+ version: '13.0'
100
+ type: :development
101
+ prerelease: false
102
+ version_requirements: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - "~>"
105
+ - !ruby/object:Gem::Version
106
+ version: '13.0'
107
+ description: Jekyll plugin extracted from al-folio with reusable Liquid tags/filters
108
+ including details, file_exists, hideCustomBibtex, and remove_accents.
109
+ email:
110
+ - dev@al-org.dev
111
+ executables: []
112
+ extensions: []
113
+ extra_rdoc_files: []
114
+ files:
115
+ - CHANGELOG.md
116
+ - LICENSE
117
+ - README.md
118
+ - lib/al_utils.rb
119
+ homepage: https://github.com/al-org-dev/al-utils
120
+ licenses:
121
+ - MIT
122
+ metadata:
123
+ allowed_push_host: https://rubygems.org
124
+ homepage_uri: https://github.com/al-org-dev/al-utils
125
+ source_code_uri: https://github.com/al-org-dev/al-utils
126
+ post_install_message:
127
+ rdoc_options: []
128
+ require_paths:
129
+ - lib
130
+ required_ruby_version: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ version: '2.7'
135
+ required_rubygems_version: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - ">="
138
+ - !ruby/object:Gem::Version
139
+ version: '0'
140
+ requirements: []
141
+ rubygems_version: 3.0.3.1
142
+ signing_key:
143
+ specification_version: 4
144
+ summary: Utility Liquid tags and filters for Jekyll
145
+ test_files: []