jekyll-commonmark-ghpages 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c780cb17633fa27a1f3886464808fd5e86fae540
4
+ data.tar.gz: 9a1e6f8304237daeb268971d26be53eee813ab8c
5
+ SHA512:
6
+ metadata.gz: 4929460a719c3245cb06cd51e688e534782f4d2c103e00a10e8c590cb3bfa4eca0c82b9968531869e6d9224434dec75a03468c51a2d32a4e1cd36ba7a01163b4
7
+ data.tar.gz: b3fdf15208da60ad54a024905fd75b1a2726f624e7126add1cce14fdff499b417dc7b3a9e880a9b5dabcd3af3652bf611e52c02267acf0f51f7b512d23a35a0d
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ Gemfile.lock
3
+ spec/dest
4
+ .bundle
@@ -0,0 +1,24 @@
1
+ language: ruby
2
+ cache: bundler
3
+ rvm:
4
+ - 2.4
5
+ - 2.3
6
+ - 2.2
7
+ - 2.1
8
+ git:
9
+ depth: 1
10
+
11
+ sudo: false
12
+
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 ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 GitHub
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 all
13
+ 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 THE
21
+ SOFTWARE.
@@ -0,0 +1,35 @@
1
+ # jekyll-commonmark-ghpages
2
+
3
+ *GitHub Flavored Markdown converter for Jekyll, based on [`jekyll-commonmark`](https://github.com/jekyll/jekyll-commonmark)*
4
+
5
+ [![Gem Version](https://img.shields.io/gem/v/jekyll-commonmark-ghpages.svg)](https://rubygems.org/gems/jekyll-commonmark-ghpages)
6
+ [![Build Status](https://img.shields.io/travis/github/jekyll-commonmark-ghpages/master.svg)](https://travis-ci.org/github/jekyll-commonmark-ghpages)
7
+ [![Windows Build status](https://img.shields.io/appveyor/ci/github/jekyll-commonmark-ghpages/master.svg?label=Windows%20build)](https://ci.appveyor.com/project/github/jekyll-commonmark-ghpages)
8
+
9
+ Jekyll Markdown converter that uses [libcmark-gfm](https://github.com/github/cmark), GitHub's fork of [cmark](https://github.com/commonmark/cmark), the reference parser for CommonMark, with some additions to ensure compatibility with existing Kramdown-based sites.
10
+
11
+ ## Installation
12
+
13
+ Add the following to your `Gemfile`:
14
+
15
+ ```ruby
16
+ group :jekyll_plugins do
17
+ gem 'jekyll-commonmark-ghpages'
18
+ end
19
+ ```
20
+
21
+ and modify your `_config.yml` to use **CommonMarkGhPages** as your Markdown converter:
22
+
23
+ ```yaml
24
+ markdown: CommonMarkGhPages
25
+ ```
26
+
27
+ This processor is currently in testing for use in GitHub Pages.
28
+
29
+ To specify extensions and options for use in converting Markdown to HTML, supply options to the Markdown converter:
30
+
31
+ ```yaml
32
+ commonmark:
33
+ options: ["SMART", "FOOTNOTES"]
34
+ extensions: ["strikethrough", "autolink", "tables"]
35
+ ```
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,24 @@
1
+ version: "{build}"
2
+ clone_depth: 5
3
+ build: off
4
+
5
+ install:
6
+ - SET PATH=C:\Ruby%RUBY_FOLDER_VER%\bin;%PATH%
7
+ - bundle install --retry 5 --jobs=%NUMBER_OF_PROCESSORS% --clean --path vendor\bundle
8
+
9
+ environment:
10
+ matrix:
11
+ - RUBY_FOLDER_VER: "24"
12
+ - RUBY_FOLDER_VER: "24-x64"
13
+ - RUBY_FOLDER_VER: "23"
14
+ - RUBY_FOLDER_VER: "22"
15
+ - RUBY_FOLDER_VER: "21"
16
+
17
+ test_script:
18
+ - ruby --version
19
+ - gem --version
20
+ - bundler --version
21
+ - bash script/cibuild
22
+
23
+ cache:
24
+ - 'vendor\bundle -> appveyor.yml,Gemfile,jekyll-commonmark-ghpages.gemspec'
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "jekyll-commonmark-ghpages"
5
+ spec.summary = "CommonMark generator for Jekyll"
6
+ spec.version = "0.1.0"
7
+ spec.authors = ["Ashe Connor"]
8
+ spec.email = "kivikakk@github.com"
9
+ spec.homepage = "https://github.com/github/jekyll-commonmark-ghpages"
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 "jekyll-commonmark", "~> 1"
18
+ spec.add_runtime_dependency "commonmarker", "~> 0.17.6"
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
@@ -0,0 +1,64 @@
1
+ # frozen-string-literal: true
2
+ # encoding: utf-8
3
+
4
+ require "commonmarker"
5
+ require "jekyll"
6
+ require "jekyll-commonmark"
7
+
8
+ # A customized version of CommonMarker::HtmlRenderer which outputs
9
+ # Kramdown-style header IDs.
10
+ class JekyllCommonMarkCustomRenderer < ::CommonMarker::HtmlRenderer
11
+ def header(node)
12
+ block do
13
+ old_stream = @stream
14
+ @stream = StringIO.new(String.new.force_encoding("utf-8"))
15
+ out(:children)
16
+ content = @stream.string
17
+ @stream = old_stream
18
+
19
+ id = generate_id(content)
20
+ out("<h", node.header_level, "#{sourcepos(node)} id=\"#{id}\">",
21
+ content, "</h", node.header_level, ">")
22
+ end
23
+ end
24
+
25
+ private
26
+
27
+ def generate_id(str)
28
+ gen_id = basic_generate_id(str)
29
+ gen_id = "section" if gen_id.empty?
30
+ @used_ids ||= {}
31
+ if @used_ids.key?(gen_id)
32
+ gen_id += "-" << (@used_ids[gen_id] += 1).to_s
33
+ else
34
+ @used_ids[gen_id] = 0
35
+ end
36
+ gen_id
37
+ end
38
+
39
+ def basic_generate_id(str)
40
+ gen_id = str.gsub(/^[^a-zA-Z]+/, "")
41
+ gen_id.tr!("^a-zA-Z0-9 -", "")
42
+ gen_id.tr!(" ", "-")
43
+ gen_id.downcase!
44
+ gen_id
45
+ end
46
+ end
47
+
48
+ class Jekyll::Converters::Markdown
49
+ # A Markdown renderer which uses JekyllCommonMarkCustomRenderer to output the
50
+ # final document.
51
+ class CommonMarkGhPages < CommonMark
52
+ def convert(content)
53
+ parse_options = (Set.new(@options) & CommonMarker::Config::Parse.keys).to_a
54
+ render_options = (Set.new(@options) & CommonMarker::Config::Render.keys).to_a
55
+ parse_options = :DEFAULT if parse_options.empty?
56
+ render_options = :DEFAULT if render_options.empty?
57
+ doc = CommonMarker.render_doc(content, parse_options, @extensions)
58
+ JekyllCommonMarkCustomRenderer.new(
59
+ :options => render_options,
60
+ :extensions => @extensions
61
+ ).render(doc)
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,3 @@
1
+ #!/bin/bash
2
+
3
+ bundle exec rspec
@@ -0,0 +1,7 @@
1
+ require "rspec/expectations"
2
+ require File.expand_path("../lib/jekyll-commonmark-ghpages.rb", File.dirname(__FILE__))
3
+
4
+ RSpec.configure do |config|
5
+ config.run_all_when_everything_filtered = true
6
+ config.order = "random"
7
+ end
@@ -0,0 +1,23 @@
1
+ require "spec_helper"
2
+
3
+ describe JekyllCommonMarkCustomRenderer do
4
+ let(:renderer) { JekyllCommonMarkCustomRenderer.new }
5
+ let(:doc) { CommonMarker.render_doc("# Hello\n\n## Hi, world!") }
6
+ subject { renderer.render(doc) }
7
+
8
+ it { is_expected.to match %r{<h1 id="hello">Hello</h1>} }
9
+ it { is_expected.to match %r{<h2 id="hi-world">Hi, world!</h2>} }
10
+ end
11
+
12
+ describe Jekyll::Converters::Markdown::CommonMarkGhPages do
13
+ let(:converter) { Jekyll::Converters::Markdown::CommonMarkGhPages.new(config) }
14
+ let(:config) {
15
+ {"commonmark" => {
16
+ "options" => ["SMART", "FOOTNOTES"],
17
+ "extensions" => ["tagfilter"],
18
+ }}
19
+ }
20
+ subject { converter.convert("### \"Hi\" <xmp>[^nb]\n\n[^nb]: Yes.\n") }
21
+
22
+ it { is_expected.to match %r{<h3 id="[^"]*">“Hi” &lt;xmp><sup[^>]*><a href="#fn1"[^>]*>\[1\]</a></sup></h3>\n<section class="footnotes">\n<ol>\n<li id="fn1">\n<p>Yes. <a href="#fnref1".*</a></p>} }
23
+ end
metadata ADDED
@@ -0,0 +1,127 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-commonmark-ghpages
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Ashe Connor
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-11-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: jekyll-commonmark
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: commonmarker
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.17.6
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.17.6
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: bundler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.6'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.6'
83
+ description:
84
+ email: kivikakk@github.com
85
+ executables: []
86
+ extensions: []
87
+ extra_rdoc_files: []
88
+ files:
89
+ - ".gitignore"
90
+ - ".travis.yml"
91
+ - Gemfile
92
+ - LICENSE
93
+ - README.md
94
+ - Rakefile
95
+ - appveyor.yml
96
+ - jekyll-commonmark-ghpages.gemspec
97
+ - lib/jekyll-commonmark-ghpages.rb
98
+ - script/cibuild
99
+ - spec/spec_helper.rb
100
+ - spec/test_spec.rb
101
+ homepage: https://github.com/github/jekyll-commonmark-ghpages
102
+ licenses:
103
+ - MIT
104
+ metadata: {}
105
+ post_install_message:
106
+ rdoc_options: []
107
+ require_paths:
108
+ - lib
109
+ required_ruby_version: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ version: '0'
114
+ required_rubygems_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ requirements: []
120
+ rubyforge_project:
121
+ rubygems_version: 2.5.1
122
+ signing_key:
123
+ specification_version: 4
124
+ summary: CommonMark generator for Jekyll
125
+ test_files:
126
+ - spec/spec_helper.rb
127
+ - spec/test_spec.rb