jekyll-markdown 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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 574cdd365c2ed2e8869b43d3fd22a0ed7754b4e8363b761afefb683d5ccdc751
4
+ data.tar.gz: 2b3db1512e5e9d0fb899c9c0d94da0c245ad9f75897170ecdd5647dd7fd55146
5
+ SHA512:
6
+ metadata.gz: e8df1d63ed245dd99cabc85a09d17c8c4a5a3ec8817e4407a4ec59b7091ea86663e0d65f33abb788125bfea8463846eef4f7dda509f32099496f76b1a5803fd9
7
+ data.tar.gz: eff165447e20707bbc830fe5935bab307617f165d4c378fd7d2be799952c48bede7ccdf907df32b05bf37a843b793247d53dea6bc466d54c4af0a7c310bbd336
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2026-12-07
4
+
5
+ - Initial release
@@ -0,0 +1,10 @@
1
+ # Code of Conduct
2
+
3
+ "jekyll-markdown" follows [The Ruby Community Conduct Guideline](https://www.ruby-lang.org/en/conduct) in all "collaborative space", which is defined as community communications channels (such as mailing lists, submitted patches, commit comments, etc.):
4
+
5
+ * Participants will be tolerant of opposing views.
6
+ * Participants must ensure that their language and actions are free of personal attacks and disparaging personal remarks.
7
+ * When interpreting the words and actions of others, participants should always assume good intentions.
8
+ * Behaviour which can be reasonably considered harassment will not be tolerated.
9
+
10
+ If you have any concerns about behaviour within this project, please contact us at ["bangseongbeom@gmail.com"](mailto:"bangseongbeom@gmail.com").
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2026 방성범 (Bang Seongbeom)
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
13
+ all 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
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,70 @@
1
+ # jekyll-markdown
2
+
3
+ A Jekyll plugin that publishes the Markdown source of each page next to its HTML.
4
+
5
+ Copies the source of every Markdown page, post and collection document into the built site next to its HTML, such as `/about.md` beside `/about.html`, and exposes that URL to Liquid as `page.markdown_url`.
6
+
7
+ ## Installation
8
+
9
+ Add the gem to your site's `Gemfile`:
10
+
11
+ ```ruby
12
+ group :jekyll_plugins do
13
+ gem "jekyll-markdown"
14
+ end
15
+ ```
16
+
17
+ Then add it to the plugins in your site's `_config.yml`:
18
+
19
+ ```yaml
20
+ plugins:
21
+ - jekyll-markdown
22
+ ```
23
+
24
+ ## Usage
25
+
26
+ Build your site as usual. There is nothing to configure. Each Markdown file gets a copy whose URL follows the page's:
27
+
28
+ | Page URL | Markdown URL |
29
+ | ----------------------- | ---------------------- |
30
+ | `/about.html` | `/about.md` |
31
+ | `/1970/01/01/post.html` | `/1970/01/01/post.md` |
32
+ | `/1970/01/01/post` | `/1970/01/01/post.md` |
33
+ | `/about/` | `/about/index.md` |
34
+
35
+ The copy is the source file byte for byte, front matter included. Any extension listed in `markdown_ext` counts as Markdown, but the copy is always served as `.md`.
36
+
37
+ To link to it from a layout, use `page.markdown_url`. Like `page.url`, it does not include `baseurl`, so pass it through `relative_url` or `absolute_url`:
38
+
39
+ ```liquid
40
+ {% if page.markdown_url %}
41
+ <link rel="alternate" type="text/markdown" href="{{ page.markdown_url | relative_url }}">
42
+ <a href="{{ page.markdown_url | relative_url }}">View as Markdown</a>
43
+ {% endif %}
44
+ ```
45
+
46
+ `page.markdown_url` is not set, and no copy is made, for:
47
+
48
+ - pages that are not Markdown, such as `.html` files;
49
+ - documents in collections with `output: false`;
50
+ - pages that other plugins generate without a source file.
51
+
52
+ jekyll-markdown runs after [jekyll-relative-links](https://github.com/benbalter/jekyll-relative-links), so links in your HTML pages still point to HTML pages, while the Markdown copies keep their links as written.
53
+
54
+ ## Development
55
+
56
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
57
+
58
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
59
+
60
+ ## Contributing
61
+
62
+ Bug reports and pull requests are welcome on GitHub at https://github.com/bangseongbeom/jekyll-markdown. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/bangseongbeom/jekyll-markdown/blob/main/CODE_OF_CONDUCT.md).
63
+
64
+ ## License
65
+
66
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
67
+
68
+ ## Code of Conduct
69
+
70
+ Everyone interacting in the jekyll-markdown project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/bangseongbeom/jekyll-markdown/blob/main/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "minitest/test_task"
5
+
6
+ Minitest::TestTask.create
7
+
8
+ require "standard/rake"
9
+
10
+ task default: %i[test standard]
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module JekyllMarkdown
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,74 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "jekyll"
4
+ require_relative "jekyll-markdown/version"
5
+
6
+ module JekyllMarkdown
7
+ class MarkdownFile < Jekyll::StaticFile
8
+ def initialize(site, relative_path, url, collection)
9
+ dir = File.dirname(relative_path)
10
+ # `StaticFile` joins `dir` and `name` into its paths as plain strings. At
11
+ # the site root, `dirname` gives ".", so pass `nil` instead.
12
+ dir = nil if dir == "."
13
+ name = File.basename(relative_path)
14
+ super(site, site.source, dir, name, collection)
15
+ @url = url
16
+ end
17
+ end
18
+
19
+ module Hooks
20
+ class << self
21
+ def generate(site)
22
+ markdown_converter = site.find_converter_instance(Jekyll::Converters::Markdown)
23
+
24
+ markdown_files = documents(site).filter_map do |document|
25
+ next unless markdown_converter.matches(File.extname(document.relative_path))
26
+ next unless document.write?
27
+
28
+ collection = document.is_a?(Jekyll::Document) ? document.collection : nil
29
+
30
+ # Skip virtual pages.
31
+ next unless File.file?(source_path(site, document))
32
+
33
+ url = markdown_url(document.url)
34
+ # Available in layouts as `page.markdown_url`.
35
+ document.data["markdown_url"] = url
36
+ MarkdownFile.new(site, document.relative_path, url, collection)
37
+ end
38
+
39
+ site.static_files.concat(markdown_files)
40
+ end
41
+
42
+ private
43
+
44
+ def documents(site)
45
+ [site.pages, site.collections.values.map(&:docs)].flatten
46
+ end
47
+
48
+ # `Page#relative_path` is relative to the source directory, but
49
+ # `Document#relative_path` is relative to the collections directory.
50
+ def source_path(site, document)
51
+ document.is_a?(Jekyll::Document) ? document.path : site.in_source_dir(document.relative_path)
52
+ end
53
+
54
+ # Follows the shape of the page's URL.
55
+ #
56
+ # @example
57
+ # markdown_url("/1970/01/01/post.html") #=> "/1970/01/01/post.md"
58
+ # markdown_url("/1970/01/01/post/") #=> "/1970/01/01/post/index.md"
59
+ def markdown_url(url)
60
+ if url.end_with?("/")
61
+ "#{url}index.md"
62
+ else
63
+ "#{url.delete_suffix(".html")}.md"
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
69
+
70
+ # This is a hook, not a `Generator`, because it has to run after
71
+ # `jekyll-relative-links`, and that plugin already has `:lowest` priority.
72
+ Jekyll::Hooks.register :site, :pre_render do |site|
73
+ JekyllMarkdown::Hooks.generate(site)
74
+ end
@@ -0,0 +1,4 @@
1
+ module JekyllMarkdown
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,77 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-markdown
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - 방성범 (Bang Seongbeom)
8
+ bindir: exe
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: jekyll
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: '4.0'
19
+ - - "<"
20
+ - !ruby/object:Gem::Version
21
+ version: '5.0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ version: '4.0'
29
+ - - "<"
30
+ - !ruby/object:Gem::Version
31
+ version: '5.0'
32
+ description: |
33
+ Copies the source of every Markdown page, post and collection document into
34
+ the built site next to its HTML, such as /about.md beside /about.html, and
35
+ exposes that URL to Liquid as page.markdown_url.
36
+ email:
37
+ - bangseongbeom@gmail.com
38
+ executables: []
39
+ extensions: []
40
+ extra_rdoc_files: []
41
+ files:
42
+ - CHANGELOG.md
43
+ - CODE_OF_CONDUCT.md
44
+ - LICENSE.txt
45
+ - README.md
46
+ - Rakefile
47
+ - lib/jekyll-markdown.rb
48
+ - lib/jekyll-markdown/version.rb
49
+ - sig/jekyll-markdown.rbs
50
+ homepage: https://github.com/bangseongbeom/jekyll-markdown
51
+ licenses:
52
+ - MIT
53
+ metadata:
54
+ allowed_push_host: https://rubygems.org
55
+ homepage_uri: https://github.com/bangseongbeom/jekyll-markdown
56
+ source_code_uri: https://github.com/bangseongbeom/jekyll-markdown
57
+ changelog_uri: https://github.com/bangseongbeom/jekyll-markdown/blob/main/CHANGELOG.md
58
+ rubygems_mfa_required: 'true'
59
+ rdoc_options: []
60
+ require_paths:
61
+ - lib
62
+ required_ruby_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: 3.2.0
67
+ required_rubygems_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ requirements: []
73
+ rubygems_version: 4.0.20
74
+ specification_version: 4
75
+ summary: A Jekyll plugin that publishes the Markdown source of each page next to its
76
+ HTML.
77
+ test_files: []