jekyll-commonmark 1.1.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 647af3a419ecde37fd6a43f237daac517b22aa12
4
- data.tar.gz: b85ba6624adf206e2a6d066b212651d13e413106
2
+ SHA256:
3
+ metadata.gz: 1bda6fd984f53c9027917fa0e75046c6962532478d039de9155ac344923d8021
4
+ data.tar.gz: 675a90e1ef61e9c43481208adb3acba8f949383198a4c28d00f7573d59caf9fb
5
5
  SHA512:
6
- metadata.gz: 7375fa11944b9dbdac92031ae3393410186b90935fbbdc8a26ca046d6b6c3547c735536bd347c05fe39a6303f3b29b95140839b62fc0405e0aae946f247661db
7
- data.tar.gz: 64a551c101c3d84045db1f6c6d193d54729ea87f91792f448aad9d34e40aa13bd0c91cb51cb8c77368901886403115dc8795dc5a5c058270dfec3003d8d5bd41
6
+ metadata.gz: 0c4d619ba9bea75f6e74e025ecf1b30f5399412cad0567e3f7c1f92e1507b91c325821e51fb40c5986255871992ab31c417ef791b669dd66551992fe2b372d4e
7
+ data.tar.gz: c13e47638595170762778b8b297dc41a90739161797203300f1f4454720a8743eda74f30cc1665ea5c60e732d2f3f947603f21d796cadb0c9853134e46613bed
data/History.markdown ADDED
@@ -0,0 +1,55 @@
1
+ ## 1.4.0 / 2022-01-30
2
+
3
+ ### Minor Enhancements
4
+
5
+ * Require at least commonmarker-0.22 (#44)
6
+ * Highlight fenced code-block contents with Rouge (#29)
7
+
8
+ ### Bug Fixes
9
+
10
+ * Refactor away extra abstractions (#53)
11
+
12
+ ### Development Fixes
13
+
14
+ * DRY begin-rescue-end block with a private helper (#28)
15
+ * Fix failing CI builds (#33)
16
+ * Remove gemspec dependency on Jekyll (#34)
17
+ * Test rendering with invalid configuration (#27)
18
+ * Refactor to improve readability (#37)
19
+ * Set up Continuous Integration via GH Actions (#46)
20
+ * Clean up gemspec (#47)
21
+ * Add workflow to release gem via GH Actions (#54)
22
+
23
+ ### Documentation
24
+
25
+ * Update README to link to commonmarker (#38)
26
+
27
+ ## 1.3.1 / 2019-03-25
28
+
29
+ ### Bug Fixes
30
+
31
+ * Re-introduce Ruby 2.3 support and test Jekyll 3.7+ (#32)
32
+
33
+ ## 1.3.0 / 2019-03-22
34
+
35
+ ### Development Fixes
36
+
37
+ * Allow Jekyll v4 (still alpha)
38
+ * Drop Ruby < 2.4
39
+ * chore(deps): rubocop-jekyll 0.3.0 (#25)
40
+ * Target Ruby 2.4 (#30)
41
+
42
+ ## 1.2.0 / 2018-03-29
43
+
44
+ ### Minor Enhancements
45
+
46
+ * Allow render options (#4)
47
+ * Only set options once (#17)
48
+
49
+ ### Development Fixes
50
+
51
+ * Test plugin on Windows (#13)
52
+ * Allow options passed to Rubocop (#15)
53
+ * Add tests (#16)
54
+ * Test against Ruby 2.5 (#18)
55
+ * Version with class (#19)
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2015 Pat Hawks
3
+ Copyright (c) 2015-present Pat Hawks and jekyll-commonmark contributors
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/Readme.md CHANGED
@@ -3,10 +3,13 @@
3
3
  *CommonMark Markdown converter for Jekyll*
4
4
 
5
5
  [![Gem Version](https://img.shields.io/gem/v/jekyll-commonmark.svg)](https://rubygems.org/gems/jekyll-commonmark)
6
- [![Build Status](https://img.shields.io/travis/pathawks/jekyll-commonmark/master.svg)](https://travis-ci.org/pathawks/jekyll-commonmark)
7
- [![Dependency Status](https://img.shields.io/gemnasium/pathawks/jekyll-commonmark.svg)](https://gemnasium.com/pathawks/jekyll-commonmark)
6
+ [![Build Status](https://img.shields.io/travis/jekyll/jekyll-commonmark/master.svg)](https://travis-ci.org/jekyll/jekyll-commonmark)
7
+ [![Windows Build status](https://img.shields.io/appveyor/ci/pathawks/jekyll-commonmark/master.svg?label=Windows%20build)](https://ci.appveyor.com/project/pathawks/jekyll-commonmark)
8
8
 
9
- Jekyll Markdown converter that uses [libcmark](https://github.com/jgm/CommonMark), the reference parser for CommonMark.
9
+ Jekyll Markdown converter that uses [libcmark-gfm](https://github.com/github/cmark-gfm) (via [commonmarker](https://github.com/gjtorikian/commonmarker)).
10
+ As a result, it is faster than Kramdown.
11
+
12
+ GitHub Pages supports CommonMark through https://github.com/github/jekyll-commonmark-ghpages
10
13
 
11
14
  ## Installation
12
15
 
@@ -23,3 +26,13 @@ and modify your `_config.yml` to use **CommonMark** as your Markdown converter
23
26
  ```yaml
24
27
  markdown: CommonMark
25
28
  ```
29
+
30
+ ## Configuration
31
+
32
+ To specify [extensions](https://github.com/gjtorikian/commonmarker#extensions) and [options](https://github.com/gjtorikian/commonmarker#options) for use in converting Markdown to HTML, supply options to the Markdown converter:
33
+
34
+ ```yaml
35
+ commonmark:
36
+ options: ["SMART", "FOOTNOTES"]
37
+ extensions: ["strikethrough", "autolink", "table"]
38
+ ```
@@ -0,0 +1,62 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Jekyll
4
+ module Converters
5
+ class Markdown
6
+ class CommonMark
7
+ class HtmlRenderer < CommonMarker::HtmlRenderer
8
+ def code_block(node)
9
+ block do
10
+ lang = extract_code_lang(node.fence_info)
11
+
12
+ out('<div class="')
13
+ out("language-", lang, " ") if lang
14
+ out('highlighter-rouge"><div class="highlight">')
15
+ out("<pre", sourcepos(node), ' class="highlight"')
16
+
17
+ if option_enabled?(:GITHUB_PRE_LANG)
18
+ out_data_attr(lang)
19
+ out("><code>")
20
+ else
21
+ out("><code")
22
+ out_data_attr(lang)
23
+ out(">")
24
+ end
25
+ out(render_with_rouge(node.string_content, lang))
26
+ out("</code></pre></div></div>")
27
+ end
28
+ end
29
+
30
+ private
31
+
32
+ def extract_code_lang(info)
33
+ return unless info.is_a?(String)
34
+ return if info.empty?
35
+
36
+ info.split(%r!\s+!)[0]
37
+ end
38
+
39
+ def out_data_attr(lang)
40
+ return unless lang
41
+
42
+ out(' data-lang="', lang, '"')
43
+ end
44
+
45
+ def render_with_rouge(code, lang)
46
+ require "rouge"
47
+
48
+ formatter = Rouge::Formatters::HTMLLegacy.new(
49
+ :line_numbers => false,
50
+ :wrap => false,
51
+ :css_class => "highlight",
52
+ :gutter_class => "gutter",
53
+ :code_class => "code"
54
+ )
55
+ lexer = Rouge::Lexer.find_fancy(lang, code) || Rouge::Lexers::PlainText
56
+ formatter.format(lexer.lex(code))
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Jekyll
4
+ module CommonMark
5
+ VERSION = "1.4.0"
6
+ end
7
+ end
@@ -1,41 +1,65 @@
1
- # Frozen-string-literal: true
2
- # Encoding: utf-8
1
+ # frozen-string-literal: true
3
2
 
4
3
  module Jekyll
5
4
  module Converters
6
- class Markdown::CommonMark
7
- def initialize(config)
8
- Jekyll::External.require_with_graceful_fail "commonmarker"
9
- begin
10
- @options = config['commonmark']['options'].collect { |e| e.upcase.to_sym }
11
- rescue NoMethodError
12
- @options = [:DEFAULT]
13
- else
14
- @options.reject! do |e|
15
- unless CommonMarker::Config::Parse.keys.include? e
16
- Jekyll.logger.warn "CommonMark:", "#{e} is not a valid option"
17
- Jekyll.logger.info "Valid options:", CommonMarker::Config::Parse.keys.join(", ")
18
- true
19
- end
5
+ class Markdown
6
+ class CommonMark
7
+ autoload :HtmlRenderer, "jekyll-commonmark/html_renderer"
8
+
9
+ def initialize(config)
10
+ Jekyll::External.require_with_graceful_fail "commonmarker"
11
+
12
+ parse_keys = CommonMarker::Config::OPTS[:parse].keys
13
+ render_keys = CommonMarker::Config::OPTS[:render].keys
14
+
15
+ options = setup_options(config, parse_keys, render_keys)
16
+ options_set = Set.new(options)
17
+
18
+ @extensions = setup_extensions(config)
19
+
20
+ @parse_options = (options_set & parse_keys).to_a
21
+ @render_options = (options_set & render_keys).to_a
22
+
23
+ @parse_options = :DEFAULT if @parse_options.empty?
24
+ @render_options = :DEFAULT if @render_options.empty?
25
+ end
26
+
27
+ def convert(content)
28
+ HtmlRenderer.new(
29
+ :options => @render_options,
30
+ :extensions => @extensions
31
+ ).render(
32
+ CommonMarker.render_doc(content, @parse_options, @extensions)
33
+ )
34
+ end
35
+
36
+ private
37
+
38
+ def validate(list, bucket, type)
39
+ list.reject do |item|
40
+ next if bucket.include?(item)
41
+
42
+ Jekyll.logger.warn "CommonMark:", "#{item} is not a valid #{type}"
43
+ Jekyll.logger.info "Valid #{type}s:", bucket.join(", ")
44
+ true
20
45
  end
21
46
  end
22
- begin
23
- @extensions = config['commonmark']['extensions'].collect { |e| e.to_sym }
47
+
48
+ def setup_options(config, parse_keys, render_keys)
49
+ options = config["commonmark"]["options"].collect { |e| e.upcase.to_sym }
50
+ valid_opts = Set.new(parse_keys + render_keys).to_a
51
+ validate(options, valid_opts, "option")
24
52
  rescue NoMethodError
25
- @extensions = []
26
- else
27
- @extensions.reject! do |e|
28
- unless CommonMarker.extensions.include? e.to_s
29
- Jekyll.logger.warn "CommonMark:", "#{e} is not a valid extension"
30
- Jekyll.logger.info "Valid extensions:", CommonMarker.extensions.join(", ")
31
- true
32
- end
33
- end
53
+ []
34
54
  end
35
- end
36
55
 
37
- def convert(content)
38
- CommonMarker.render_doc(content, @options, @extensions).to_html
56
+ def setup_extensions(config)
57
+ extensions = config["commonmark"]["extensions"].collect(&:to_sym)
58
+ valid_extensions = CommonMarker.extensions.collect(&:to_sym)
59
+ validate(extensions, valid_extensions, "extension")
60
+ rescue NoMethodError
61
+ []
62
+ end
39
63
  end
40
64
  end
41
65
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-commonmark
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pat Hawks
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-17 00:00:00.000000000 Z
11
+ date: 2022-01-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: commonmarker
@@ -16,95 +16,103 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.14'
19
+ version: '0.22'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.14'
26
+ version: '0.22'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: jekyll
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
45
  - - ">="
32
46
  - !ruby/object:Gem::Version
33
- version: '3.0'
47
+ version: '3.7'
34
48
  - - "<"
35
49
  - !ruby/object:Gem::Version
36
- version: '4.0'
37
- type: :runtime
50
+ version: '5.0'
51
+ type: :development
38
52
  prerelease: false
39
53
  version_requirements: !ruby/object:Gem::Requirement
40
54
  requirements:
41
55
  - - ">="
42
56
  - !ruby/object:Gem::Version
43
- version: '3.0'
57
+ version: '3.7'
44
58
  - - "<"
45
59
  - !ruby/object:Gem::Version
46
- version: '4.0'
60
+ version: '5.0'
47
61
  - !ruby/object:Gem::Dependency
48
- name: rspec
62
+ name: rake
49
63
  requirement: !ruby/object:Gem::Requirement
50
64
  requirements:
51
65
  - - "~>"
52
66
  - !ruby/object:Gem::Version
53
- version: '3.0'
67
+ version: '12.0'
54
68
  type: :development
55
69
  prerelease: false
56
70
  version_requirements: !ruby/object:Gem::Requirement
57
71
  requirements:
58
72
  - - "~>"
59
73
  - !ruby/object:Gem::Version
60
- version: '3.0'
74
+ version: '12.0'
61
75
  - !ruby/object:Gem::Dependency
62
- name: rake
76
+ name: rspec
63
77
  requirement: !ruby/object:Gem::Requirement
64
78
  requirements:
65
- - - ">="
79
+ - - "~>"
66
80
  - !ruby/object:Gem::Version
67
- version: '0'
81
+ version: '3.0'
68
82
  type: :development
69
83
  prerelease: false
70
84
  version_requirements: !ruby/object:Gem::Requirement
71
85
  requirements:
72
- - - ">="
86
+ - - "~>"
73
87
  - !ruby/object:Gem::Version
74
- version: '0'
88
+ version: '3.0'
75
89
  - !ruby/object:Gem::Dependency
76
- name: bundler
90
+ name: rubocop-jekyll
77
91
  requirement: !ruby/object:Gem::Requirement
78
92
  requirements:
79
93
  - - "~>"
80
94
  - !ruby/object:Gem::Version
81
- version: '1.6'
95
+ version: 0.12.0
82
96
  type: :development
83
97
  prerelease: false
84
98
  version_requirements: !ruby/object:Gem::Requirement
85
99
  requirements:
86
100
  - - "~>"
87
101
  - !ruby/object:Gem::Version
88
- version: '1.6'
102
+ version: 0.12.0
89
103
  description:
90
104
  email: pat@pathawks.com
91
105
  executables: []
92
106
  extensions: []
93
107
  extra_rdoc_files: []
94
108
  files:
95
- - ".gitignore"
96
- - ".travis.yml"
97
- - Gemfile
109
+ - History.markdown
98
110
  - LICENSE
99
- - Rakefile
100
111
  - Readme.md
101
- - jekyll-commonmark.gemspec
102
112
  - lib/jekyll-commonmark.rb
103
- - script/bootstrap
104
- - script/cibuild
105
- - script/console
106
- - script/release
107
- homepage: https://github.com/pathawks/jekyll-commonmark
113
+ - lib/jekyll-commonmark/html_renderer.rb
114
+ - lib/jekyll-commonmark/version.rb
115
+ homepage: https://github.com/jekyll/jekyll-commonmark
108
116
  licenses:
109
117
  - MIT
110
118
  metadata: {}
@@ -116,15 +124,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
116
124
  requirements:
117
125
  - - ">="
118
126
  - !ruby/object:Gem::Version
119
- version: '0'
127
+ version: 2.6.0
120
128
  required_rubygems_version: !ruby/object:Gem::Requirement
121
129
  requirements:
122
130
  - - ">="
123
131
  - !ruby/object:Gem::Version
124
132
  version: '0'
125
133
  requirements: []
126
- rubyforge_project:
127
- rubygems_version: 2.6.8
134
+ rubygems_version: 3.1.6
128
135
  signing_key:
129
136
  specification_version: 4
130
137
  summary: CommonMark generator for Jekyll
data/.gitignore DELETED
@@ -1,4 +0,0 @@
1
- *.gem
2
- Gemfile.lock
3
- spec/dest
4
- .bundle
data/.travis.yml DELETED
@@ -1,24 +0,0 @@
1
- language: ruby
2
- cache: bundler
3
- rvm:
4
- - 2.2
5
- - 2.1
6
- - 2.0
7
- git:
8
- depth: 10
9
-
10
- sudo: false
11
-
12
- # we need a more recent cmake than travis/linux provides (at least 2.8.9):
13
- addons:
14
- apt:
15
- sources:
16
- - kalakris-cmake
17
- packages:
18
- - cmake
19
-
20
- before_install:
21
- - gem install bundler
22
-
23
- before_script: bundle update
24
- script: script/cibuild
data/Gemfile DELETED
@@ -1,3 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gemspec
data/Rakefile DELETED
@@ -1,6 +0,0 @@
1
- require "bundler/gem_tasks"
2
- require 'rspec/core/rake_task'
3
-
4
- RSpec::Core::RakeTask.new(:spec)
5
-
6
- task :default => :spec
@@ -1,23 +0,0 @@
1
- # coding: utf-8
2
-
3
- Gem::Specification.new do |spec|
4
- spec.name = "jekyll-commonmark"
5
- spec.summary = "CommonMark generator for Jekyll"
6
- spec.version = "1.1.0"
7
- spec.authors = ["Pat Hawks"]
8
- spec.email = "pat@pathawks.com"
9
- spec.homepage = "https://github.com/pathawks/jekyll-commonmark"
10
- spec.licenses = ["MIT"]
11
-
12
- spec.files = `git ls-files -z`.split("\x0")
13
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
14
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
15
- spec.require_paths = ["lib"]
16
-
17
- spec.add_runtime_dependency "commonmarker", "~> 0.14"
18
- spec.add_runtime_dependency "jekyll", [">= 3.0", "< 4.0"]
19
-
20
- spec.add_development_dependency "rspec", "~> 3.0"
21
- spec.add_development_dependency "rake"
22
- spec.add_development_dependency "bundler", "~> 1.6"
23
- end
data/script/bootstrap DELETED
@@ -1,3 +0,0 @@
1
- #! /bin/bash
2
-
3
- bundle install
data/script/cibuild DELETED
@@ -1,3 +0,0 @@
1
- #! /bin/bash
2
-
3
- bundle exec rspec
data/script/console DELETED
@@ -1,34 +0,0 @@
1
- #! /usr/bin/env ruby
2
-
3
- def relative_to_root(path)
4
- File.expand_path(path, File.dirname(File.dirname(__FILE__)))
5
- end
6
-
7
- require 'jekyll'
8
- require relative_to_root('lib/jekyll-smartify.rb')
9
- require 'pry-debugger'
10
-
11
- SOURCE_DIR = relative_to_root('spec/fixtures')
12
- DEST_DIR = relative_to_root('spec/dest')
13
-
14
- def source_dir(*files)
15
- File.join(SOURCE_DIR, *files)
16
- end
17
-
18
- def dest_dir(*files)
19
- File.join(DEST_DIR, *files)
20
- end
21
-
22
- def config(overrides = {})
23
- Jekyll.configuration({
24
- "source" => source_dir,
25
- "destination" => dest_dir,
26
- "url" => "http://example.org"
27
- }).merge(overrides)
28
- end
29
-
30
- def site(configuration = config)
31
- Jekyll::Site.new(configuration)
32
- end
33
-
34
- binding.pry
data/script/release DELETED
@@ -1,7 +0,0 @@
1
- #!/bin/sh
2
- # Tag and push a release.
3
-
4
- set -e
5
-
6
- script/cibuild
7
- bundle exec rake release