pax_global_header 0000666 0000000 0000000 00000000064 14175476077 0014534 g ustar 00root root 0000000 0000000 52 comment=26a431595c15b0b27e3c9e85c2d3c1e83526010d jekyll-commonmark-1.4.0/ 0000775 0000000 0000000 00000000000 14175476077 0015171 5 ustar 00root root 0000000 0000000 jekyll-commonmark-1.4.0/.github/ 0000775 0000000 0000000 00000000000 14175476077 0016531 5 ustar 00root root 0000000 0000000 jekyll-commonmark-1.4.0/.github/stale.yml 0000664 0000000 0000000 00000001254 14175476077 0020366 0 ustar 00root root 0000000 0000000 # Number of days of inactivity before an issue becomes stale daysUntilStale: 60 # Number of days of inactivity before a stale issue is closed daysUntilClose: 7 # Issues with these labels will never be considered stale exemptLabels: - pinned - security # Label to use when marking an issue as stale staleLabel: wontfix # Comment to post when marking an issue as stale. Set to `false` to disable markComment: > This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. # Comment to post when closing a stale issue. Set to `false` to disable closeComment: false jekyll-commonmark-1.4.0/.github/workflows/ 0000775 0000000 0000000 00000000000 14175476077 0020566 5 ustar 00root root 0000000 0000000 jekyll-commonmark-1.4.0/.github/workflows/ci.yml 0000664 0000000 0000000 00000004042 14175476077 0021704 0 ustar 00root root 0000000 0000000 name: Continuous Integration on: push: branches: - master pull_request: branches: - master jobs: ci: name: "Unit Tests w/ Jekyll ${{ matrix.jekyll_version }} (Ruby ${{ matrix.ruby_version }})" runs-on: "ubuntu-latest" strategy: fail-fast: false matrix: ruby_version: - 2.6 - 2.7 - 3.0 jekyll_version: - "~> 4.2" include: - ruby_version: 2.6 jekyll_version: "~> 3.9" env: JEKYLL_VERSION: ${{ matrix.jekyll_version }} steps: - uses: actions/checkout@v2 with: fetch-depth: 3 - name: "Set up Ruby ${{ matrix.ruby_version }}" uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby_version }} bundler-cache: true - name: Execute tests run: bundle exec rspec style_check: name: "Style Check (Ruby ${{ matrix.ruby_version }})" runs-on: "ubuntu-latest" strategy: fail-fast: false matrix: ruby_version: - 2.6 steps: - uses: actions/checkout@v2 with: fetch-depth: 3 - name: "Set up Ruby ${{ matrix.ruby_version }}" uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby_version }} bundler-cache: true - name: Run RuboCop run: bash script/fmt gem_build_install: name: "Test gem build and install (Ruby ${{ matrix.ruby_version }})" runs-on: "ubuntu-latest" strategy: fail-fast: false matrix: ruby_version: - 2.6 steps: - uses: actions/checkout@v2 with: fetch-depth: 3 - name: "Set up Ruby ${{ matrix.ruby_version }}" uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby_version }} bundler-cache: true - name: Test gem build run: bundle exec gem build jekyll-commonmark.gemspec - name: Test gem install run: bundle exec gem install jekyll-commonmark --local --verbose jekyll-commonmark-1.4.0/.github/workflows/release.yml 0000664 0000000 0000000 00000001437 14175476077 0022736 0 ustar 00root root 0000000 0000000 name: Release Gem on: push: branches: ["master"] paths: ["lib/**/version.rb"] jobs: release: if: "github.repository_owner == 'jekyll'" name: "Release Gem (Ruby ${{ matrix.ruby_version }})" runs-on: "ubuntu-latest" strategy: fail-fast: true matrix: ruby_version: ["2.7"] steps: - name: Checkout Repository uses: actions/checkout@v2 - name: "Set up Ruby ${{ matrix.ruby_version }}" uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby_version }} bundler-cache: true - name: Build and Publish Gem uses: ashmaroli/release-gem@dist with: gemspec_name: "jekyll-commonmark" env: GEM_HOST_API_KEY: ${{ secrets.RUBYGEMS_GEM_PUSH_API_KEY }} jekyll-commonmark-1.4.0/.gitignore 0000664 0000000 0000000 00000000063 14175476077 0017160 0 ustar 00root root 0000000 0000000 .bundle *.gem Gemfile.lock spec/dest vendor/bundle jekyll-commonmark-1.4.0/.rubocop.yml 0000664 0000000 0000000 00000001236 14175476077 0017445 0 ustar 00root root 0000000 0000000 require: rubocop-jekyll inherit_gem: rubocop-jekyll: .rubocop.yml AllCops: TargetRubyVersion: 2.6 SuggestExtensions: false Exclude: - script/**/* - vendor/**/* Layout/LineEndStringConcatenationIndentation: Enabled: true Layout/LineLength: Exclude: - jekyll-commonmark.gemspec Lint/EmptyInPattern: Enabled: false Naming/InclusiveLanguage: Enabled: false Performance/MapCompact: Enabled: true Performance/RedundantEqualityComparisonBlock: Enabled: true Performance/RedundantSplitRegexpArgument: Enabled: true Style/InPatternThen: Enabled: false Style/MultilineInPatternThen: Enabled: false Style/QuotedSymbols: Enabled: true jekyll-commonmark-1.4.0/Gemfile 0000664 0000000 0000000 00000000203 14175476077 0016457 0 ustar 00root root 0000000 0000000 # frozen_string_literal: true source "https://rubygems.org" gemspec gem "jekyll", ENV["JEKYLL_VERSION"] if ENV["JEKYLL_VERSION"] jekyll-commonmark-1.4.0/History.markdown 0000664 0000000 0000000 00000002314 14175476077 0020376 0 ustar 00root root 0000000 0000000 ## 1.4.0 / 2022-01-30 ### Minor Enhancements * Require at least commonmarker-0.22 (#44) * Highlight fenced code-block contents with Rouge (#29) ### Bug Fixes * Refactor away extra abstractions (#53) ### Development Fixes * DRY begin-rescue-end block with a private helper (#28) * Fix failing CI builds (#33) * Remove gemspec dependency on Jekyll (#34) * Test rendering with invalid configuration (#27) * Refactor to improve readability (#37) * Set up Continuous Integration via GH Actions (#46) * Clean up gemspec (#47) * Add workflow to release gem via GH Actions (#54) ### Documentation * Update README to link to commonmarker (#38) ## 1.3.1 / 2019-03-25 ### Bug Fixes * Re-introduce Ruby 2.3 support and test Jekyll 3.7+ (#32) ## 1.3.0 / 2019-03-22 ### Development Fixes * Allow Jekyll v4 (still alpha) * Drop Ruby < 2.4 * chore(deps): rubocop-jekyll 0.3.0 (#25) * Target Ruby 2.4 (#30) ## 1.2.0 / 2018-03-29 ### Minor Enhancements * Allow render options (#4) * Only set options once (#17) ### Development Fixes * Test plugin on Windows (#13) * Allow options passed to Rubocop (#15) * Add tests (#16) * Test against Ruby 2.5 (#18) * Version with class (#19) jekyll-commonmark-1.4.0/LICENSE 0000664 0000000 0000000 00000002137 14175476077 0016201 0 ustar 00root root 0000000 0000000 The MIT License (MIT) Copyright (c) 2015-present Pat Hawks and jekyll-commonmark contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. jekyll-commonmark-1.4.0/Rakefile 0000664 0000000 0000000 00000000224 14175476077 0016634 0 ustar 00root root 0000000 0000000 # frozen_string_literal: true require "bundler/gem_tasks" require "rspec/core/rake_task" RSpec::Core::RakeTask.new(:spec) task :default => :spec jekyll-commonmark-1.4.0/Readme.md 0000664 0000000 0000000 00000002543 14175476077 0016714 0 ustar 00root root 0000000 0000000 # jekyll-commonmark *CommonMark Markdown converter for Jekyll* [](https://rubygems.org/gems/jekyll-commonmark) [](https://travis-ci.org/jekyll/jekyll-commonmark) [](https://ci.appveyor.com/project/pathawks/jekyll-commonmark) Jekyll Markdown converter that uses [libcmark-gfm](https://github.com/github/cmark-gfm) (via [commonmarker](https://github.com/gjtorikian/commonmarker)). As a result, it is faster than Kramdown. GitHub Pages supports CommonMark through https://github.com/github/jekyll-commonmark-ghpages ## Installation Add the following to your `Gemfile` ```ruby group :jekyll_plugins do gem 'jekyll-commonmark' end ``` and modify your `_config.yml` to use **CommonMark** as your Markdown converter ```yaml markdown: CommonMark ``` ## Configuration 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: ```yaml commonmark: options: ["SMART", "FOOTNOTES"] extensions: ["strikethrough", "autolink", "table"] ``` jekyll-commonmark-1.4.0/appveyor.yml 0000664 0000000 0000000 00000001140 14175476077 0017555 0 ustar 00root root 0000000 0000000 version: "{build}" clone_depth: 5 build: off install: - SET PATH=C:\Ruby%RUBY_FOLDER_VER%-x64\bin;%PATH% - bundle install --retry 5 --jobs=%NUMBER_OF_PROCESSORS% --clean --path vendor\bundle environment: JEKYLL_VERSION: "~> 4.0" matrix: - RUBY_FOLDER_VER: "26" JEKYLL_VERSION : "~> 3.9.0" - RUBY_FOLDER_VER: "26" JEKYLL_VERSION : "~> 3.8.7" - RUBY_FOLDER_VER: "26" JEKYLL_VERSION : "~> 3.7.4" test_script: - ruby --version - gem --version - bundler --version - bash script/cibuild cache: - 'vendor\bundle -> appveyor.yml,Gemfile,jekyll-commonmark.gemspec' jekyll-commonmark-1.4.0/jekyll-commonmark.gemspec 0000664 0000000 0000000 00000001700 14175476077 0022167 0 ustar 00root root 0000000 0000000 # frozen_string_literal: true require_relative "lib/jekyll-commonmark/version" Gem::Specification.new do |spec| spec.name = "jekyll-commonmark" spec.summary = "CommonMark generator for Jekyll" spec.version = Jekyll::CommonMark::VERSION spec.authors = ["Pat Hawks"] spec.email = "pat@pathawks.com" spec.homepage = "https://github.com/jekyll/jekyll-commonmark" spec.licenses = ["MIT"] spec.files = `git ls-files lib -z`.split("\x0").concat(%w(LICENSE Readme.md History.markdown)) spec.require_paths = ["lib"] spec.required_ruby_version = ">= 2.6.0" spec.add_runtime_dependency "commonmarker", "~> 0.22" spec.add_development_dependency "bundler" spec.add_development_dependency "jekyll", ">= 3.7", "< 5.0" spec.add_development_dependency "rake", "~> 12.0" spec.add_development_dependency "rspec", "~> 3.0" spec.add_development_dependency "rubocop-jekyll", "~> 0.12.0" end jekyll-commonmark-1.4.0/lib/ 0000775 0000000 0000000 00000000000 14175476077 0015737 5 ustar 00root root 0000000 0000000 jekyll-commonmark-1.4.0/lib/jekyll-commonmark.rb 0000775 0000000 0000000 00000004006 14175476077 0021722 0 ustar 00root root 0000000 0000000 # frozen-string-literal: true module Jekyll module Converters class Markdown class CommonMark autoload :HtmlRenderer, "jekyll-commonmark/html_renderer" def initialize(config) Jekyll::External.require_with_graceful_fail "commonmarker" parse_keys = CommonMarker::Config::OPTS[:parse].keys render_keys = CommonMarker::Config::OPTS[:render].keys options = setup_options(config, parse_keys, render_keys) options_set = Set.new(options) @extensions = setup_extensions(config) @parse_options = (options_set & parse_keys).to_a @render_options = (options_set & render_keys).to_a @parse_options = :DEFAULT if @parse_options.empty? @render_options = :DEFAULT if @render_options.empty? end def convert(content) HtmlRenderer.new( :options => @render_options, :extensions => @extensions ).render( CommonMarker.render_doc(content, @parse_options, @extensions) ) end private def validate(list, bucket, type) list.reject do |item| next if bucket.include?(item) Jekyll.logger.warn "CommonMark:", "#{item} is not a valid #{type}" Jekyll.logger.info "Valid #{type}s:", bucket.join(", ") true end end def setup_options(config, parse_keys, render_keys) options = config["commonmark"]["options"].collect { |e| e.upcase.to_sym } valid_opts = Set.new(parse_keys + render_keys).to_a validate(options, valid_opts, "option") rescue NoMethodError [] end def setup_extensions(config) extensions = config["commonmark"]["extensions"].collect(&:to_sym) valid_extensions = CommonMarker.extensions.collect(&:to_sym) validate(extensions, valid_extensions, "extension") rescue NoMethodError [] end end end end end jekyll-commonmark-1.4.0/lib/jekyll-commonmark/ 0000775 0000000 0000000 00000000000 14175476077 0021372 5 ustar 00root root 0000000 0000000 jekyll-commonmark-1.4.0/lib/jekyll-commonmark/html_renderer.rb 0000664 0000000 0000000 00000003262 14175476077 0024554 0 ustar 00root root 0000000 0000000 # frozen_string_literal: true module Jekyll module Converters class Markdown class CommonMark class HtmlRenderer < CommonMarker::HtmlRenderer def code_block(node) block do lang = extract_code_lang(node.fence_info) out('
")
else
out(">")
end
out(render_with_rouge(node.string_content, lang))
out("
a\nb
" expect(actual).to match(expected) end it "treats double linebreaks as a new paragraph" do actual = commonmark.convert("a\n\nb") expected = "a
\nb
" expect(actual).to match(expected) end it "escapes quotes" do actual = commonmark.convert('"SmartyPants"') expected = ""SmartyPants"
" expect(actual).to match(expected) end it "does not link urls" do actual = commonmark.convert("https://example.com") expected = "https://example.com" expect(actual).to match(expected) end it "highlights fenced code-block" do content = <<~CODE ```yaml # Sample configuration title: CommonMark Test verbose: true atm_pin: 1234 ``` CODE output = <<~HTML
# Sample configuration
title:
CommonMark Test
verbose:
true
atm_pin:
1234
“SmartyPants”
" expect(actual).to match(expected) end end context "with hardbreaks enabled" do let(:options) { ["HARDBREAKS"] } it "treats newlines as hardbreaks" do actual = commonmark.convert("a\nb") expected = "a
\nb
a b
" expect(actual).to match(expected) end end context "with autolink enabled" do let(:extensions) { ["autolink"] } it "links urls" do actual = commonmark.convert("https://example.com") expected = '' expect(actual).to match(expected) end end context "with invalid config" do let(:config) { "DEFAULT" } it "renders correct markup" do actual = commonmark.convert("# Heading\n\nhttps://example.com") expected = "https://example.com
" expect(actual).to match(expected) end end context "with invalid options and extensions" do let(:options) { ["SOFTBREAKS"] } let(:extensions) { ["SOFTBREAKS"] } it "outputs warning messages but renders correct markup" do actual, output = capture_stdout { commonmark.convert("# Heading\n\nhttps://example.com") } expected = "https://example.com
" expect(output).to match("CommonMark: SOFTBREAKS is not a valid option") expect(output).to match("CommonMark: SOFTBREAKS is not a valid extension") expect(actual).to match(expected) end end end jekyll-commonmark-1.4.0/spec/spec_helper.rb 0000664 0000000 0000000 00000001031 14175476077 0020734 0 ustar 00root root 0000000 0000000 # frozen_string_literal: true require "jekyll" require_relative "../lib/jekyll-commonmark" Jekyll.logger.log_level = :info RSpec.configure do |config| config.run_all_when_everything_filtered = true config.filter_run :focus config.order = "random" def capture_stdout(level = :debug) buffer = StringIO.new Jekyll.logger = Logger.new(buffer) Jekyll.logger.log_level = level result = yield buffer.rewind [result, buffer.string.to_s] ensure Jekyll.logger = Logger.new(StringIO.new, :error) end end