pax_global_header00006660000000000000000000000064141754760770014534gustar00rootroot0000000000000052 comment=26a431595c15b0b27e3c9e85c2d3c1e83526010d jekyll-commonmark-1.4.0/000077500000000000000000000000001417547607700151715ustar00rootroot00000000000000jekyll-commonmark-1.4.0/.github/000077500000000000000000000000001417547607700165315ustar00rootroot00000000000000jekyll-commonmark-1.4.0/.github/stale.yml000066400000000000000000000012541417547607700203660ustar00rootroot00000000000000# 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/000077500000000000000000000000001417547607700205665ustar00rootroot00000000000000jekyll-commonmark-1.4.0/.github/workflows/ci.yml000066400000000000000000000040421417547607700217040ustar00rootroot00000000000000name: 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.yml000066400000000000000000000014371417547607700227360ustar00rootroot00000000000000name: 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/.gitignore000066400000000000000000000000631417547607700171600ustar00rootroot00000000000000.bundle *.gem Gemfile.lock spec/dest vendor/bundle jekyll-commonmark-1.4.0/.rubocop.yml000066400000000000000000000012361417547607700174450ustar00rootroot00000000000000require: 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/Gemfile000066400000000000000000000002031417547607700164570ustar00rootroot00000000000000# frozen_string_literal: true source "https://rubygems.org" gemspec gem "jekyll", ENV["JEKYLL_VERSION"] if ENV["JEKYLL_VERSION"] jekyll-commonmark-1.4.0/History.markdown000066400000000000000000000023141417547607700203760ustar00rootroot00000000000000## 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/LICENSE000066400000000000000000000021371417547607700162010ustar00rootroot00000000000000The 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/Rakefile000066400000000000000000000002241417547607700166340ustar00rootroot00000000000000# 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.md000066400000000000000000000025431417547607700167140ustar00rootroot00000000000000# jekyll-commonmark *CommonMark Markdown converter for Jekyll* [![Gem Version](https://img.shields.io/gem/v/jekyll-commonmark.svg)](https://rubygems.org/gems/jekyll-commonmark) [![Build Status](https://img.shields.io/travis/jekyll/jekyll-commonmark/master.svg)](https://travis-ci.org/jekyll/jekyll-commonmark) [![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) 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.yml000066400000000000000000000011401417547607700175550ustar00rootroot00000000000000version: "{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.gemspec000066400000000000000000000017001417547607700221670ustar00rootroot00000000000000# 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/000077500000000000000000000000001417547607700157375ustar00rootroot00000000000000jekyll-commonmark-1.4.0/lib/jekyll-commonmark.rb000077500000000000000000000040061417547607700217220ustar00rootroot00000000000000# 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/000077500000000000000000000000001417547607700213725ustar00rootroot00000000000000jekyll-commonmark-1.4.0/lib/jekyll-commonmark/html_renderer.rb000066400000000000000000000032621417547607700245540ustar00rootroot00000000000000# 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('
') out("") else out(">") end out(render_with_rouge(node.string_content, lang)) out("
") end end private def extract_code_lang(info) return unless info.is_a?(String) return if info.empty? info.split(%r!\s+!)[0] end def out_data_attr(lang) return unless lang out(' data-lang="', lang, '"') end def render_with_rouge(code, lang) require "rouge" formatter = Rouge::Formatters::HTMLLegacy.new( :line_numbers => false, :wrap => false, :css_class => "highlight", :gutter_class => "gutter", :code_class => "code" ) lexer = Rouge::Lexer.find_fancy(lang, code) || Rouge::Lexers::PlainText formatter.format(lexer.lex(code)) end end end end end end jekyll-commonmark-1.4.0/lib/jekyll-commonmark/version.rb000066400000000000000000000001411417547607700234000ustar00rootroot00000000000000# frozen_string_literal: true module Jekyll module CommonMark VERSION = "1.4.0" end end jekyll-commonmark-1.4.0/script/000077500000000000000000000000001417547607700164755ustar00rootroot00000000000000jekyll-commonmark-1.4.0/script/bootstrap000077500000000000000000000000351417547607700204360ustar00rootroot00000000000000#! /bin/bash bundle install jekyll-commonmark-1.4.0/script/cibuild000077500000000000000000000000531417547607700200340ustar00rootroot00000000000000#! /bin/bash script/fmt bundle exec rspec jekyll-commonmark-1.4.0/script/console000077500000000000000000000013111417547607700200610ustar00rootroot00000000000000#! /usr/bin/env ruby # frozen_string_literal: true def relative_to_root(path) File.expand_path(path, File.dirname(File.dirname(__FILE__))) end require "jekyll" require relative_to_root("lib/jekyll-smartify.rb") require "pry-debugger" SOURCE_DIR = relative_to_root("spec/fixtures") DEST_DIR = relative_to_root("spec/dest") def source_dir(*files) File.join(SOURCE_DIR, *files) end def dest_dir(*files) File.join(DEST_DIR, *files) end def config(overrides = {}) Jekyll.configuration( "source" => source_dir, "destination" => dest_dir, "url" => "http://example.org" ).merge(overrides) end def site(configuration = config) Jekyll::Site.new(configuration) end binding.pry jekyll-commonmark-1.4.0/script/fmt000077500000000000000000000001361417547607700172110ustar00rootroot00000000000000#!/bin/sh set -e echo "RuboCop $(bundle exec rubocop --version)" bundle exec rubocop -DES $@ jekyll-commonmark-1.4.0/script/release000077500000000000000000000001251417547607700200410ustar00rootroot00000000000000#!/bin/sh # Tag and push a release. set -e script/cibuild bundle exec rake release jekyll-commonmark-1.4.0/spec/000077500000000000000000000000001417547607700161235ustar00rootroot00000000000000jekyll-commonmark-1.4.0/spec/jekyll_commonmark_spec.rb000066400000000000000000000102311417547607700231740ustar00rootroot00000000000000# frozen_string_literal: true require "spec_helper" describe(Jekyll::Converters::Markdown::CommonMark) do let(:options) { [] } let(:extensions) { [] } let(:config) do { "commonmark" => { "options" => options, "extensions" => extensions, }, } end let(:commonmark) { described_class.new(config) } let(:output) { commonmark.convert(content) } context "with default configuration" do it "produces the correct script tag" do actual = commonmark.convert("# Heading") expected = "

Heading

" expect(actual).to match(expected) end it "does not treat newlines as hardbreaks" do actual = commonmark.convert("a\nb") expected = "

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

\n

b

" 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
              
            
HTML expect(commonmark.convert(content).gsub(%r!\s+!, "")).to match(output.gsub(%r!\s+!, "")) end end context "with SmartyPants enabled" do let(:options) { ["SMART"] } it "makes quotes curly" do actual = commonmark.convert('"SmartyPants"') expected = "

“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

" expect(actual).to match(expected) end end context "with nobreaks enabled" do let(:options) { ["NOBREAKS"] } it "treats newlines as a single space" do actual = commonmark.convert("a\nb") expected = "

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 = '

https://example.com

' 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 = "

Heading

\n

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 = "

Heading

\n

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.rb000066400000000000000000000010311417547607700207340ustar00rootroot00000000000000# 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