jekyll-refergen 0.1.2

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 93bd72fabdb08bd4ae0643d5e654be1634c9d08f4a577bac24174b2b244c6ab1
4
+ data.tar.gz: f03cb2cb39101cd05daf744371cff913788cd264246fbb5a7549b83de5681e79
5
+ SHA512:
6
+ metadata.gz: af2178d64f8d5f57851bc9a6f2a2ce5f5981b1a745b19fc0f0742113f0d41ae9f40e2a1b78428a804a4292c21b41c22b0990087746d0caa4c5670be0d67caa1e
7
+ data.tar.gz: ea5ed017ad28d9371585e49ee3f59afdb9438936c03aa00cf254f4c143126d69d4fa6c980c83c2d6396ca45b95d40f4c401242ec924da0fc50016a368246ad35
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Min-Seong Lee
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, 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,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,82 @@
1
+ # jeklly-refergen
2
+ Don’t forget to include a reference at the end of your posts.
3
+
4
+ ---
5
+
6
+ ## Gem Installation and Usage
7
+
8
+ 1. **Gem Installation**
9
+ - Add to your Gemfile:
10
+ ```ruby
11
+ gem 'jeklly-refergen', git: 'https://github.com/yourname/jeklly-refergen.git'
12
+ ```
13
+ - Or after publishing to rubygems.org:
14
+ ```ruby
15
+ gem 'jeklly-refergen'
16
+ ```
17
+ - Run `bundle install`
18
+
19
+ 2. **_config.yml Configuration**
20
+ ```yaml
21
+ reference_plugin:
22
+ collections: ["posts", "wiki"] # Specify which collections to process
23
+ ```
24
+ - The plugin will process all documents in the specified collections.
25
+
26
+ 3. **Usage Example**
27
+ - In your post/page content:
28
+ ```markdown
29
+ [Example1](https://www.example.com), [Example2](https://www.example2.com), [Again Example1](https://www.example.com)
30
+ ```
31
+ - Will be rendered as:
32
+ ```markdown
33
+ Example1<sup><a href="#ref-1" id="ref-link-1">[1]</a></sup>, Example2<sup><a href="#ref-2" id="ref-link-2">[2]</a></sup>, Again Example1<sup><a href="#ref-1" id="ref-link-1">[1]</a></sup>
34
+
35
+ ---
36
+ ## Reference
37
+ 1. <a id="ref-1"></a>[Example1](https://www.example.com)<br/>
38
+ 2. <a id="ref-2"></a>[Example2](https://www.example2.com)<br/>
39
+ ```
40
+
41
+ ---
42
+
43
+ ## Github Actions: Automatic Deployment
44
+
45
+ 1. Create `.github/workflows/deploy.yml`
46
+ 2. Add the following workflow:
47
+
48
+ ```yaml
49
+ name: Build & Deploy Jekyll
50
+
51
+ on:
52
+ push:
53
+ branches: [ master ]
54
+
55
+ jobs:
56
+ build-deploy:
57
+ runs-on: ubuntu-latest
58
+ steps:
59
+ - uses: actions/checkout@v3
60
+ - name: Set up Ruby
61
+ uses: ruby/setup-ruby@v1
62
+ with:
63
+ ruby-version: '3.1'
64
+ - name: Install dependencies
65
+ run: bundle install
66
+ - name: Build site
67
+ run: bundle exec jekyll build
68
+ - name: Deploy to GitHub Pages
69
+ uses: peaceiris/actions-gh-pages@v3
70
+ with:
71
+ github_token: ${{ secrets.GITHUB_TOKEN }}
72
+ publish_dir: ./_site
73
+ ```
74
+
75
+ - This workflow builds your Jekyll site and deploys the `_site` folder to GitHub Pages on every push to the master branch.
76
+ - If your Gemfile includes `jeklly-refergen`, the plugin will work in the GitHub Actions environment.
77
+
78
+ ---
79
+
80
+ ### Notes
81
+ - The plugin works with Jekyll 3.x and 4.x.
82
+ - Custom gem plugins are not supported on the official GitHub Pages build server. You must use GitHub Actions or another external build server for deployment.
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "jekyll/refergen/version"
4
+ require "jekyll/refergen/reference_generator"
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+ puts "aaaaaaa"
3
+
4
+ module Jekyll
5
+ module Refergen
6
+ class ReferenceGenerator < Jekyll::Generator
7
+ safe true
8
+ priority :low
9
+
10
+ def generate(site)
11
+ puts "aaaaaaa"
12
+ config = site.config["refergen-plugin"] || {}
13
+ collections = config["collections"] || ["posts"]
14
+
15
+ puts collections
16
+ collections.each do |col|
17
+ next unless site.collections[col]
18
+ site.collections[col].docs.each do |doc|
19
+ doc.content = process_references(doc.content)
20
+ end
21
+ end
22
+ end
23
+
24
+ private
25
+
26
+ def process_references(content)
27
+ # Extract [text](url) patterns
28
+ references = content.scan(/\[([^\]]+)\]\(([^\)]+)\)/)
29
+ url_to_number = {}
30
+ number = 1
31
+ references.each do |name, url|
32
+ url_to_number[url] ||= number
33
+ number += 1 if url_to_number[url] == number
34
+ end
35
+ # Replace [name](url) with name<sup><a href="#ref-1" id="ref-link-1">[1]</a></sup>
36
+ replaced_content = content.gsub(/\[([^\]]+)\]\(([^\)]+)\)/) do
37
+ name = Regexp.last_match(1)
38
+ url = Regexp.last_match(2)
39
+ num = url_to_number[url]
40
+ "#{name}<sup><a href=\"#ref-#{num}\" id=\"ref-link-#{num}\">[#{num}]</a></sup>"
41
+ end
42
+ # Generate Reference section
43
+ if url_to_number.any?
44
+ reference_section = "\n\n---\n## Reference\n"
45
+ url_to_number.sort_by { |_, num| num }.each do |url, num|
46
+ name = references.find { |n, u| u == url }&.first || url
47
+ reference_section += "#{num}. <a id=\"ref-#{num}\"></a>[#{name}](#{url})<br/>\n"
48
+ end
49
+ replaced_content += reference_section
50
+ end
51
+ replaced_content
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Jekyll
4
+ module Refergen
5
+ VERSION = "0.1.2"
6
+ end
7
+ end
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "jekyll/jekyll-refergen"
metadata ADDED
@@ -0,0 +1,66 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-refergen
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
5
+ platform: ruby
6
+ authors:
7
+ - Minseong Lee
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2025-07-10 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.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '3.0'
27
+ description: A Jekyll plugin that automatically converts in-text references ([name](url))
28
+ to Wikipedia-style superscripted numbered references and generates a Reference section
29
+ at the end of the document. Only documents updated after a configurable date are
30
+ processed.
31
+ email:
32
+ - dlaepeul@gmail.com
33
+ executables: []
34
+ extensions: []
35
+ extra_rdoc_files: []
36
+ files:
37
+ - LICENSE
38
+ - README.md
39
+ - lib/jekyll-refergen.rb
40
+ - lib/jekyll/jekyll-refergen.rb
41
+ - lib/jekyll/refergen/reference_generator.rb
42
+ - lib/jekyll/refergen/version.rb
43
+ homepage: https://github.com/minseon9/jekyll-refergen
44
+ licenses:
45
+ - MIT
46
+ metadata: {}
47
+ post_install_message:
48
+ rdoc_options: []
49
+ require_paths:
50
+ - lib
51
+ required_ruby_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ required_rubygems_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ requirements: []
62
+ rubygems_version: 3.5.16
63
+ signing_key:
64
+ specification_version: 4
65
+ summary: Jekyll Reference Generator Plugin
66
+ test_files: []