Skip to content

Commit 127c395

Browse files
authored
Merge pull request #274 from kivikakk/commonmark
Switch to CommonMark
2 parents 4194367 + 0ab4f81 commit 127c395

File tree

11 files changed

+37
-24
lines changed

11 files changed

+37
-24
lines changed

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ addons:
66
apt:
77
sources:
88
- libicu-dev
9+
- kalakris-cmake
10+
packages:
11+
- cmake
912

1013
script: bundle exec rake
1114

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ group :test do
1414
gem "rinku", "~> 1.7", :require => false
1515
gem "gemoji", "~> 2.0", :require => false
1616
gem "RedCloth", "~> 4.2.9", :require => false
17-
gem "github-markdown", "~> 0.5", :require => false
17+
gem "commonmarker", "~> 0.14", :require => false
1818
gem "email_reply_parser", "~> 0.5", :require => false
1919
gem "sanitize", "~> 2.0", :require => false
2020

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ gem 'github-linguist'
182182
* `AutolinkFilter` - `rinku`
183183
* `EmailReplyFilter` - `escape_utils`, `email_reply_parser`
184184
* `EmojiFilter` - `gemoji`
185-
* `MarkdownFilter` - `github-markdown`
185+
* `MarkdownFilter` - `commonmarker`
186186
* `PlainTextInputFilter` - `escape_utils`
187187
* `SanitizationFilter` - `sanitize`
188188
* `SyntaxHighlightFilter` - `github-linguist`

gemfiles/rails_3.gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ group :test do
1616
gem "rinku", "~> 1.7", :require => false
1717
gem "gemoji", "~> 2.0", :require => false
1818
gem "RedCloth", "~> 4.2.9", :require => false
19-
gem "github-markdown", "~> 0.5", :require => false
19+
gem "commonmarker", "~> 0.14", :require => false
2020
gem "email_reply_parser", "~> 0.5", :require => false
2121
gem "sanitize", "~> 2.0", :require => false
2222
gem "escape_utils", "~> 1.0", :require => false

gemfiles/rails_3.gemfile.lock

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: ../
33
specs:
4-
html-pipeline (2.4.2)
4+
html-pipeline (2.5.0)
55
activesupport (>= 2)
66
nokogiri (>= 1.4)
77

@@ -43,6 +43,8 @@ GEM
4343
arel (3.0.3)
4444
builder (3.0.4)
4545
charlock_holmes (0.7.3)
46+
commonmarker (0.14.15)
47+
ruby-enum (~> 0.5)
4648
email_reply_parser (0.5.8)
4749
erubis (2.7.0)
4850
escape_utils (1.0.1)
@@ -52,7 +54,6 @@ GEM
5254
escape_utils (~> 1.0.1)
5355
mime-types (~> 1.19)
5456
pygments.rb (~> 0.6.0)
55-
github-markdown (0.6.9)
5657
hike (1.2.3)
5758
i18n (0.7.0)
5859
journey (1.0.4)
@@ -99,6 +100,8 @@ GEM
99100
rdoc (3.12.2)
100101
json (~> 1.4)
101102
rinku (1.7.3)
103+
ruby-enum (0.7.1)
104+
i18n
102105
sanitize (2.1.0)
103106
nokogiri (>= 1.4.4)
104107
sprockets (2.2.3)
@@ -121,11 +124,11 @@ DEPENDENCIES
121124
RedCloth (~> 4.2.9)
122125
appraisal
123126
bundler
127+
commonmarker (~> 0.14)
124128
email_reply_parser (~> 0.5)
125129
escape_utils (~> 1.0)
126130
gemoji (~> 2.0)
127131
github-linguist (~> 2.10)
128-
github-markdown (~> 0.5)
129132
html-pipeline!
130133
minitest
131134
rack (< 2)

gemfiles/rails_4.gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ group :test do
1616
gem "rinku", "~> 1.7", :require => false
1717
gem "gemoji", "~> 2.0", :require => false
1818
gem "RedCloth", "~> 4.2.9", :require => false
19-
gem "github-markdown", "~> 0.5", :require => false
19+
gem "commonmarker", "~> 0.14", :require => false
2020
gem "email_reply_parser", "~> 0.5", :require => false
2121
gem "sanitize", "~> 2.0", :require => false
2222
gem "escape_utils", "~> 1.0", :require => false

gemfiles/rails_4.gemfile.lock

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: ../
33
specs:
4-
html-pipeline (2.4.2)
4+
html-pipeline (2.5.0)
55
activesupport (>= 2)
66
nokogiri (>= 1.4)
77

@@ -51,6 +51,8 @@ GEM
5151
arel (6.0.3)
5252
builder (3.2.2)
5353
charlock_holmes (0.7.3)
54+
commonmarker (0.14.15)
55+
ruby-enum (~> 0.5)
5456
concurrent-ruby (1.0.2)
5557
email_reply_parser (0.5.8)
5658
erubis (2.7.0)
@@ -61,7 +63,6 @@ GEM
6163
escape_utils (~> 1.0.1)
6264
mime-types (~> 1.19)
6365
pygments.rb (~> 0.6.0)
64-
github-markdown (0.6.9)
6566
globalid (0.3.6)
6667
activesupport (>= 4.1.0)
6768
i18n (0.7.0)
@@ -110,6 +111,8 @@ GEM
110111
thor (>= 0.18.1, < 2.0)
111112
rake (11.2.2)
112113
rinku (1.7.3)
114+
ruby-enum (0.7.1)
115+
i18n
113116
sanitize (2.1.0)
114117
nokogiri (>= 1.4.4)
115118
sprockets (3.6.2)
@@ -132,11 +135,11 @@ DEPENDENCIES
132135
RedCloth (~> 4.2.9)
133136
appraisal
134137
bundler
138+
commonmarker (~> 0.14)
135139
email_reply_parser (~> 0.5)
136140
escape_utils (~> 1.0)
137141
gemoji (~> 2.0)
138142
github-linguist (~> 2.10)
139-
github-markdown (~> 0.5)
140143
html-pipeline!
141144
minitest
142145
rack (< 2)

gemfiles/rails_5.gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ group :test do
1515
gem "rinku", "~> 1.7", :require => false
1616
gem "gemoji", "~> 2.0", :require => false
1717
gem "RedCloth", "~> 4.2.9", :require => false
18-
gem "github-markdown", "~> 0.5", :require => false
18+
gem "commonmarker", "~> 0.14", :require => false
1919
gem "email_reply_parser", "~> 0.5", :require => false
2020
gem "sanitize", "~> 2.0", :require => false
2121
gem "escape_utils", "~> 1.0", :require => false

gemfiles/rails_5.gemfile.lock

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: ../
33
specs:
4-
html-pipeline (2.4.2)
4+
html-pipeline (2.5.0)
55
activesupport (>= 2)
66
nokogiri (>= 1.4)
77

@@ -53,6 +53,8 @@ GEM
5353
arel (7.0.0)
5454
builder (3.2.2)
5555
charlock_holmes (0.7.3)
56+
commonmarker (0.14.15)
57+
ruby-enum (~> 0.5)
5658
concurrent-ruby (1.0.2)
5759
email_reply_parser (0.5.8)
5860
erubis (2.7.0)
@@ -63,7 +65,6 @@ GEM
6365
escape_utils (~> 1.0.1)
6466
mime-types (~> 1.19)
6567
pygments.rb (> 0.6.0)
66-
github-markdown (0.6.9)
6768
globalid (0.3.6)
6869
activesupport (>= 4.1.0)
6970
i18n (0.7.0)
@@ -111,6 +112,8 @@ GEM
111112
thor (>= 0.18.1, < 2.0)
112113
rake (11.2.2)
113114
rinku (1.7.3)
115+
ruby-enum (0.7.1)
116+
i18n
114117
sanitize (2.1.0)
115118
nokogiri (>= 1.4.4)
116119
sprockets (3.6.2)
@@ -135,11 +138,11 @@ DEPENDENCIES
135138
RedCloth (~> 4.2.9)
136139
appraisal
137140
bundler
141+
commonmarker (~> 0.14)
138142
email_reply_parser (~> 0.5)
139143
escape_utils (~> 1.0)
140144
gemoji (~> 2.0)
141145
github-linguist (~> 2.10)
142-
github-markdown (~> 0.5)
143146
html-pipeline!
144147
minitest
145148
rails (~> 5.0.0)

lib/html/pipeline/markdown_filter.rb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
begin
2-
require "github/markdown"
2+
require "commonmarker"
33
rescue LoadError => _
4-
raise HTML::Pipeline::MissingDependencyError, "Missing dependency 'github-markdown' for MarkdownFilter. See README.md for details."
4+
raise HTML::Pipeline::MissingDependencyError, "Missing dependency 'commonmarker' for MarkdownFilter. See README.md for details."
55
end
66

77
module HTML
@@ -23,8 +23,9 @@ def initialize(text, context = nil, result = nil)
2323
# Convert Markdown to HTML using the best available implementation
2424
# and convert into a DocumentFragment.
2525
def call
26-
mode = (context[:gfm] != false) ? :gfm : :markdown
27-
html = GitHub::Markdown.to_html(@text, mode)
26+
options = [:GITHUB_PRE_LANG]
27+
options << :HARDBREAKS if context[:gfm] != false
28+
html = CommonMarker.render_html(@text, options, [:table, :strikethrough, :tagfilter, :autolink])
2829
html.rstrip!
2930
html
3031
end

0 commit comments

Comments
 (0)