jekyll-markly 0.1.0 → 0.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 97974bf8db134f319970d7d9014115beaefe1d5814f43ffb8760dc37ef7cc95a
4
- data.tar.gz: 3f5961f505fa5e9b8a286fbd1437e14b915d2a4a109e40f8d487c942e9134448
3
+ metadata.gz: 373c40119a536a69530b3b67433d0672f6d7a72c427f26cc02532a66119dbc22
4
+ data.tar.gz: a92db070578e1bf8cbb0648e800af57248fa2acac604b715e077fc6fc1cf3a56
5
5
  SHA512:
6
- metadata.gz: 60949607733291e1c37030349f784090140d5e5444ecc608cdbddc8f7e63ecc5ba3829d8b3a8d344da0ca60646c1edc7513652dddce889eab643a62faa4fd664
7
- data.tar.gz: 8c5382cba2509ca2ef95ff22902671a62968b3e6c06aa7c693a7999a9fce24294258fb5e27cd70a30b7e7795817b8e9f7d9c459201e600370012b7fc20f379c7
6
+ metadata.gz: 35df5c81714314fb6c5292b8e692a53d233e62e8ecc7bcab02705c69cdbf1adb201071f1d22f1f42ad1136aff5d6d49d42ffe73b3d08c6673106f61f1589c686
7
+ data.tar.gz: b6854973256e3126ac4466be85eeb562eb4fcab29e899b1840fb6ade3af047639029f1bd654172df08aa28aeb0c1e6fd94dea5a3eac519fb966639b7b90f9442
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.1.1] - 2026-09-05
4
+
5
+ - Strip Rouge lexer options from codeblock language attributes
6
+ - Remove the `div.highlight` inside `div.highlighter-rouge` wrapping
7
+ `pre.highlight`
8
+
3
9
  ## [0.1.0] - 2026-09-04
4
10
 
5
11
  - Initial release
data/README.md CHANGED
@@ -1,39 +1,55 @@
1
1
  # Jekyll::Markly
2
2
 
3
- TODO: Delete this and the text below, and describe your gem
3
+ Jekyll Markdown converter that uses [`cmark-gfm`], Github's fork of the
4
+ reference parser for CommonMark, through the [`markly`] gem.
4
5
 
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
+ [`cmark-gfm`]: https://github.com/github/cmark-gfm
7
+ [`markly`]: https://github.com/socketry/markly
6
8
 
7
9
  ## Installation
8
10
 
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.
11
+ Add `jekyll-markly` to the `jekyll_plugins` group in your `Gemfile`
10
12
 
11
- Install the gem and add to the application's Gemfile by executing:
13
+ ```ruby
14
+ group :jekyll_plugins do
15
+ gem "jekyll-markly"
16
+ end
17
+ ```
18
+
19
+ and update the `markdown` configuration in `_config.yml`
12
20
 
13
- ```bash
14
- bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
21
+ ```yml
22
+ markdown: Markly
15
23
  ```
16
24
 
17
- If bundler is not being used to manage dependencies, install the gem by executing:
25
+ ## Configuration
18
26
 
19
- ```bash
20
- gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
27
+ `cmark-cfm` extensions and options can be configured with the `commonmark`
28
+ configuration in `_config.yml`
29
+
30
+ ```yml
31
+ commonmark:
32
+ extensions: [table, strikethrough, autolink]
33
+ options: [unsafe, footnotes]
21
34
  ```
22
35
 
23
- ## Usage
36
+ The full list of supported extensions and options can be found in the `Markly`
37
+ [documentation][].
24
38
 
25
- TODO: Write usage instructions here
39
+ [documentation]: https://socketry.github.io/markly/guides/getting-started/index.html#options
26
40
 
27
41
  ## Development
28
42
 
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).
43
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run
44
+ `rake test` to run the tests. You can also run `bin/console` for an interactive
45
+ prompt that will allow you to experiment.
32
46
 
33
47
  ## Contributing
34
48
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/jekyll-markly.
49
+ Bug reports and pull requests are welcome on GitHub at
50
+ https://github.com/skipkayhil/jekyll-markly.
36
51
 
37
52
  ## License
38
53
 
39
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
54
+ The gem is available as open source under the terms of the [MIT
55
+ License](https://opensource.org/licenses/MIT).
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Jekyll
4
4
  module Markly
5
- VERSION = "0.1.0"
5
+ VERSION = "0.1.1"
6
6
  end
7
7
  end
data/lib/jekyll/markly.rb CHANGED
@@ -48,11 +48,11 @@ class Jekyll::Markly::HtmlRenderer < Markly::Renderer::HTML
48
48
 
49
49
  def code_block(node)
50
50
  block do
51
- lang = extract_code_lang(node.fence_info)
51
+ lang, lang_with_options = extract_code_lang(node.fence_info)
52
52
 
53
53
  out('<div class="')
54
54
  out("language-", lang, " ") if lang
55
- out('highlighter-rouge"><div class="highlight">')
55
+ out('highlighter-rouge">')
56
56
  out("<pre", source_position(node), ' class="highlight"')
57
57
 
58
58
  if flag_enabled?(Markly::GITHUB_PRE_LANG)
@@ -63,8 +63,8 @@ class Jekyll::Markly::HtmlRenderer < Markly::Renderer::HTML
63
63
  out_data_attr(lang)
64
64
  out(">")
65
65
  end
66
- out(render_with_rouge(node.string_content, lang))
67
- out("</code></pre></div></div>")
66
+ out(render_with_rouge(node.string_content, lang_with_options))
67
+ out("</code></pre></div>")
68
68
  end
69
69
  end
70
70
 
@@ -74,7 +74,10 @@ class Jekyll::Markly::HtmlRenderer < Markly::Renderer::HTML
74
74
  return unless info.is_a?(String)
75
75
  return if info.empty?
76
76
 
77
- info.split(%r{\s+})[0]
77
+ lang_with_options = info.split(%r{\s+})[0]
78
+ lang = lang_with_options.split("?")[0]
79
+
80
+ [lang, lang_with_options]
78
81
  end
79
82
 
80
83
  def out_data_attr(lang)
@@ -98,11 +101,14 @@ end
98
101
 
99
102
  class Jekyll::Converters::Markdown::Markly
100
103
  def initialize(config)
101
- @extensions = config.dig("commonmark", "extensions").map!(&:to_sym)
104
+ @extensions = config.dig("commonmark", "extensions")&.map!(&:to_sym) || [].freeze
102
105
 
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
+ if (symbol_options = config.dig("commonmark", "options")&.map!(&:to_sym))
107
+ @parse_flags = symbol_options.filter_map { |k| Markly::PARSE_FLAGS[k] }.reduce(&:|)
108
+ @render_flags = symbol_options.filter_map { |k| Markly::RENDER_FLAGS[k] }.reduce(&:|)
109
+ else
110
+ @parse_flags = @render_flags = 0
111
+ end
106
112
  end
107
113
 
108
114
  def convert(content)
@@ -1,5 +1,53 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class JekyllMarklyTest < JekyllMarklyTestCase
2
- test "nothing" do
3
- assert true
4
+ test "syntax highlighting" do
5
+ html = md_to_html(<<~MD)
6
+ ```ruby
7
+ 3.times {}
8
+ ```
9
+ MD
10
+
11
+ assert_snapshot(<<~SNAP, html)
12
+ <div class="language-ruby highlighter-rouge"><pre class="highlight"><code data-lang="ruby"><span class="mi">3</span><span class="p">.</span><span class="nf">times</span> <span class="p">{}</span>
13
+ </code></pre></div>
14
+ SNAP
15
+ end
16
+
17
+ test "lang attributes include lexer options" do
18
+ html = md_to_html(<<~MD)
19
+ ```console?comments=true
20
+ # frank
21
+ ```
22
+ MD
23
+
24
+ assert_snapshot(<<~SNAP, html)
25
+ <div class="language-console highlighter-rouge"><pre class="highlight"><code data-lang="console"><span class="c"># frank
26
+ </span></code></pre></div>
27
+ SNAP
28
+ end
29
+
30
+ private
31
+
32
+ def assert_snapshot(expected, actual)
33
+ if expected.empty?
34
+ flunk <<~OUT
35
+ Empty snapshot at line #{caller_locations(1, 1).first.lineno}. Replace with
36
+
37
+ assert_snapshot(<<~SNAP, html)
38
+ #{actual.strip}
39
+ SNAP
40
+ OUT
41
+ end
42
+
43
+ assert_equal expected.strip, actual.strip
44
+ end
45
+
46
+ def md_to_html(md)
47
+ converter.convert(md)
48
+ end
49
+
50
+ def converter(config = {})
51
+ @converter ||= Jekyll::Converters::Markdown::Markly.new(config)
4
52
  end
5
53
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-markly
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hartley McGuire