jekyll-markly 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: 97974bf8db134f319970d7d9014115beaefe1d5814f43ffb8760dc37ef7cc95a
4
+ data.tar.gz: 3f5961f505fa5e9b8a286fbd1437e14b915d2a4a109e40f8d487c942e9134448
5
+ SHA512:
6
+ metadata.gz: 60949607733291e1c37030349f784090140d5e5444ecc608cdbddc8f7e63ecc5ba3829d8b3a8d344da0ca60646c1edc7513652dddce889eab643a62faa4fd664
7
+ data.tar.gz: 8c5382cba2509ca2ef95ff22902671a62968b3e6c06aa7c693a7999a9fce24294258fb5e27cd70a30b7e7795817b8e9f7d9c459201e600370012b7fc20f379c7
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2026-09-04
4
+
5
+ - Initial release
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2026 Hartley McGuire
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,39 @@
1
+ # Jekyll::Markly
2
+
3
+ TODO: Delete this and the text below, and describe your gem
4
+
5
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/jekyll/markly`. To experiment with that code, run `bin/console` for an interactive prompt.
6
+
7
+ ## Installation
8
+
9
+ TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
10
+
11
+ Install the gem and add to the application's Gemfile by executing:
12
+
13
+ ```bash
14
+ bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
15
+ ```
16
+
17
+ If bundler is not being used to manage dependencies, install the gem by executing:
18
+
19
+ ```bash
20
+ gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
21
+ ```
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake ` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ 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).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/jekyll-markly.
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "megatest/test_task"
5
+
6
+ Megatest::TestTask.create
7
+
8
+ require "standard/rake"
9
+
10
+ task default: [:test, :standard]
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Jekyll
4
+ module Markly
5
+ VERSION = "0.1.0"
6
+ end
7
+ end
@@ -0,0 +1,113 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "markly/version"
4
+ require "jekyll"
5
+ require "markly"
6
+ require "rouge"
7
+
8
+ # Markly made a bunch of changes to how footnotes are rendered. This module
9
+ # restores them to CommonMarker's behavior.
10
+ #
11
+ # TBD on whether I keep this, but I'm trying to minize the diff for now
12
+ module Jekyll::Markly::FootnoteCompat
13
+ def footnote_reference(node)
14
+ label = node.string_content
15
+
16
+ out("<sup class=\"footnote-ref\"><a href=\"#fn#{label}\" id=\"fnref#{label}\">#{node.string_content}</a></sup>")
17
+ end
18
+
19
+ def footnote_definition(node)
20
+ unless @footnote_ix
21
+ out("<section class=\"footnotes\">\n<ol>\n")
22
+ @footnote_ix = 0
23
+ end
24
+
25
+ @footnote_ix += 1
26
+ label = node.string_content
27
+ @footnotes[@footnote_ix] = label
28
+
29
+ out("<li id=\"fn#{@footnote_ix}\">\n", :children)
30
+ out("\n") if out_footnote_backref
31
+ out("</li>\n")
32
+ end
33
+
34
+ private
35
+
36
+ def out_footnote_backref
37
+ return false if @written_footnote_ix == @footnote_ix
38
+
39
+ @written_footnote_ix = @footnote_ix
40
+
41
+ out("<a href=\"#fnref#{@footnote_ix}\" class=\"footnote-backref\">↩</a>")
42
+ true
43
+ end
44
+ end
45
+
46
+ class Jekyll::Markly::HtmlRenderer < Markly::Renderer::HTML
47
+ include Jekyll::Markly::FootnoteCompat
48
+
49
+ def code_block(node)
50
+ block do
51
+ lang = extract_code_lang(node.fence_info)
52
+
53
+ out('<div class="')
54
+ out("language-", lang, " ") if lang
55
+ out('highlighter-rouge"><div class="highlight">')
56
+ out("<pre", source_position(node), ' class="highlight"')
57
+
58
+ if flag_enabled?(Markly::GITHUB_PRE_LANG)
59
+ out_data_attr(lang)
60
+ out("><code>")
61
+ else
62
+ out("><code")
63
+ out_data_attr(lang)
64
+ out(">")
65
+ end
66
+ out(render_with_rouge(node.string_content, lang))
67
+ out("</code></pre></div></div>")
68
+ end
69
+ end
70
+
71
+ private
72
+
73
+ def extract_code_lang(info)
74
+ return unless info.is_a?(String)
75
+ return if info.empty?
76
+
77
+ info.split(%r{\s+})[0]
78
+ end
79
+
80
+ def out_data_attr(lang)
81
+ return unless lang
82
+
83
+ out(' data-lang="', lang, '"')
84
+ end
85
+
86
+ def render_with_rouge(code, lang)
87
+ formatter = Rouge::Formatters::HTMLLegacy.new(
88
+ line_numbers: false,
89
+ wrap: false,
90
+ css_class: "highlight",
91
+ gutter_class: "gutter",
92
+ code_class: "code"
93
+ )
94
+ lexer = Rouge::Lexer.find_fancy(lang, code) || Rouge::Lexers::PlainText
95
+ formatter.format(lexer.lex(code))
96
+ end
97
+ end
98
+
99
+ class Jekyll::Converters::Markdown::Markly
100
+ def initialize(config)
101
+ @extensions = config.dig("commonmark", "extensions").map!(&:to_sym)
102
+
103
+ symbol_options = config.dig("commonmark", "options").map!(&:to_sym)
104
+ @parse_flags = symbol_options.filter_map { |k| Markly::PARSE_FLAGS[k] }.reduce(&:|)
105
+ @render_flags = symbol_options.filter_map { |k| Markly::RENDER_FLAGS[k] }.reduce(&:|)
106
+ end
107
+
108
+ def convert(content)
109
+ node = Markly.parse(content, extensions: @extensions, flags: @parse_flags)
110
+
111
+ Jekyll::Markly::HtmlRenderer.new(extensions: @extensions, flags: @render_flags).render(node)
112
+ end
113
+ end
@@ -0,0 +1,5 @@
1
+ class JekyllMarklyTest < JekyllMarklyTestCase
2
+ test "nothing" do
3
+ assert true
4
+ end
5
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ $LOAD_PATH.unshift File.expand_path("../lib", __dir__)
4
+
5
+ require "jekyll/markly"
6
+
7
+ class JekyllMarklyTestCase < Megatest::Test
8
+ end
metadata ADDED
@@ -0,0 +1,92 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-markly
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Hartley McGuire
8
+ bindir: bin
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
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: '4.0'
26
+ - !ruby/object:Gem::Dependency
27
+ name: markly
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0.17'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0.17'
40
+ - !ruby/object:Gem::Dependency
41
+ name: rouge
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '3.0'
47
+ type: :runtime
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '3.0'
54
+ email:
55
+ - skipkayhil@gmail.com
56
+ executables: []
57
+ extensions: []
58
+ extra_rdoc_files: []
59
+ files:
60
+ - CHANGELOG.md
61
+ - LICENSE.txt
62
+ - README.md
63
+ - Rakefile
64
+ - lib/jekyll/markly.rb
65
+ - lib/jekyll/markly/version.rb
66
+ - test/jekyll_markly_test.rb
67
+ - test/test_helper.rb
68
+ homepage: https://github.com/skipkayhil/jekyll-markly
69
+ licenses:
70
+ - MIT
71
+ metadata:
72
+ homepage_uri: https://github.com/skipkayhil/jekyll-markly
73
+ source_code_uri: https://github.com/skipkayhil/jekyll-markly
74
+ changelog_uri: https://github.com/skipkayhil/jekyll-markly/blob/main/CHANGELOG.md
75
+ rdoc_options: []
76
+ require_paths:
77
+ - lib
78
+ required_ruby_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: 3.3.0
83
+ required_rubygems_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ requirements: []
89
+ rubygems_version: 4.0.16
90
+ specification_version: 4
91
+ summary: CommonMark generator for Jekyll
92
+ test_files: []