Skip to content

Commit

Permalink
Calebthompson use gfm (#55)
Browse files Browse the repository at this point in the history
* Use GFM for parsing

Change the default HTML block to use the Kramdown GFM parser, which
supports things like fenced code blocks.

* Fix test

Co-authored-by: Caleb Hearth <[email protected]>
  • Loading branch information
schneems and calebhearth authored Jun 11, 2020
1 parent a71449c commit e0753e8
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 18 deletions.
14 changes: 11 additions & 3 deletions gemfiles/rails_5.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ PATH
specs:
maildown (3.1.0)
actionmailer (>= 4.0.0)
kramdown
kramdown-parser-gfm

GEM
remote: https://rubygems.org/
Expand Down Expand Up @@ -58,10 +58,16 @@ GEM
activesupport (>= 4.2.0)
i18n (1.6.0)
concurrent-ruby (~> 1.0)
kramdown (2.1.0)
kramdown (2.2.1)
rexml
kramdown-parser-gfm (1.1.0)
kramdown (~> 2.0)
loofah (2.2.3)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
m (1.5.1)
method_source (>= 0.6.7)
rake (>= 0.9.2.2)
mail (2.7.1)
mini_mime (>= 0.1.1)
method_source (0.9.2)
Expand Down Expand Up @@ -98,6 +104,7 @@ GEM
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (12.3.2)
rexml (3.2.4)
sprockets (3.7.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
Expand All @@ -119,11 +126,12 @@ PLATFORMS

DEPENDENCIES
appraisal
m
maildown!
rails (= 5.0.7.2)
railties
rake
sqlite3 (~> 1.3.6)

BUNDLED WITH
2.0.2
2.1.4
14 changes: 11 additions & 3 deletions gemfiles/rails_51.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ PATH
specs:
maildown (3.1.0)
actionmailer (>= 4.0.0)
kramdown
kramdown-parser-gfm

GEM
remote: https://rubygems.org/
Expand Down Expand Up @@ -58,10 +58,16 @@ GEM
activesupport (>= 4.2.0)
i18n (1.6.0)
concurrent-ruby (~> 1.0)
kramdown (2.1.0)
kramdown (2.2.1)
rexml
kramdown-parser-gfm (1.1.0)
kramdown (~> 2.0)
loofah (2.2.3)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
m (1.5.1)
method_source (>= 0.6.7)
rake (>= 0.9.2.2)
mail (2.7.1)
mini_mime (>= 0.1.1)
method_source (0.9.2)
Expand Down Expand Up @@ -98,6 +104,7 @@ GEM
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (12.3.2)
rexml (3.2.4)
sprockets (3.7.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
Expand All @@ -119,11 +126,12 @@ PLATFORMS

DEPENDENCIES
appraisal
m
maildown!
rails (= 5.1.7)
railties
rake
sqlite3 (~> 1.3.6)

BUNDLED WITH
2.0.2
2.1.4
14 changes: 11 additions & 3 deletions gemfiles/rails_52.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ PATH
specs:
maildown (3.1.0)
actionmailer (>= 4.0.0)
kramdown
kramdown-parser-gfm

GEM
remote: https://rubygems.org/
Expand Down Expand Up @@ -62,10 +62,16 @@ GEM
activesupport (>= 4.2.0)
i18n (1.6.0)
concurrent-ruby (~> 1.0)
kramdown (2.1.0)
kramdown (2.2.1)
rexml
kramdown-parser-gfm (1.1.0)
kramdown (~> 2.0)
loofah (2.2.3)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
m (1.5.1)
method_source (>= 0.6.7)
rake (>= 0.9.2.2)
mail (2.7.1)
mini_mime (>= 0.1.1)
marcel (0.3.3)
Expand Down Expand Up @@ -106,6 +112,7 @@ GEM
rake (>= 0.8.7)
thor (>= 0.19.0, < 2.0)
rake (12.3.2)
rexml (3.2.4)
sprockets (3.7.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
Expand All @@ -127,11 +134,12 @@ PLATFORMS

DEPENDENCIES
appraisal
m
maildown!
rails (= 5.2.3)
railties
rake
sqlite3 (~> 1.3.6)

BUNDLED WITH
2.0.2
2.1.4
14 changes: 11 additions & 3 deletions gemfiles/rails_6.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ PATH
specs:
maildown (3.1.0)
actionmailer (>= 4.0.0)
kramdown
kramdown-parser-gfm

GEM
remote: https://rubygems.org/
Expand Down Expand Up @@ -75,10 +75,16 @@ GEM
activesupport (>= 4.2.0)
i18n (1.6.0)
concurrent-ruby (~> 1.0)
kramdown (2.1.0)
kramdown (2.2.1)
rexml
kramdown-parser-gfm (1.1.0)
kramdown (~> 2.0)
loofah (2.3.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
m (1.5.1)
method_source (>= 0.6.7)
rake (>= 0.9.2.2)
mail (2.7.1)
mini_mime (>= 0.1.1)
marcel (0.3.3)
Expand Down Expand Up @@ -121,6 +127,7 @@ GEM
rake (>= 0.8.7)
thor (>= 0.20.3, < 2.0)
rake (13.0.0)
rexml (3.2.4)
sprockets (3.7.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
Expand All @@ -143,11 +150,12 @@ PLATFORMS

DEPENDENCIES
appraisal
m
maildown!
rails (= 6.0.0)
railties
rake
sqlite3 (~> 1.4)

BUNDLED WITH
2.0.2
2.1.4
14 changes: 11 additions & 3 deletions gemfiles/rails_head.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ PATH
specs:
maildown (3.1.0)
actionmailer (>= 4.0.0)
kramdown
kramdown-parser-gfm

GEM
remote: https://rubygems.org/
Expand All @@ -101,10 +101,16 @@ GEM
activesupport (>= 4.2.0)
i18n (1.6.0)
concurrent-ruby (~> 1.0)
kramdown (2.1.0)
kramdown (2.2.1)
rexml
kramdown-parser-gfm (1.1.0)
kramdown (~> 2.0)
loofah (2.2.3)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
m (1.5.1)
method_source (>= 0.6.7)
rake (>= 0.9.2.2)
mail (2.7.1)
mini_mime (>= 0.1.1)
marcel (0.3.3)
Expand All @@ -126,6 +132,7 @@ GEM
rails-html-sanitizer (1.0.4)
loofah (~> 2.2, >= 2.2.2)
rake (12.3.2)
rexml (3.2.4)
sprockets (3.7.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
Expand All @@ -148,11 +155,12 @@ PLATFORMS

DEPENDENCIES
appraisal
m
maildown!
rails!
railties
rake
sqlite3 (~> 1.4)

BUNDLED WITH
2.0.2
2.1.4
2 changes: 1 addition & 1 deletion lib/maildown/markdown_engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def self.text_block
end

def self.default_html_block
->(string) { Kramdown::Document.new(string).to_html }
->(string) { Kramdown::Document.new(string, input: "GFM").to_html }
end

def self.default_text_block
Expand Down
3 changes: 2 additions & 1 deletion maildown.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ Gem::Specification.new do |s|
s.test_files = Dir["test/**/*"]

s.add_dependency "actionmailer", ">= 4.0.0"
s.add_dependency "kramdown"
s.add_dependency "kramdown-parser-gfm"

s.add_development_dependency "railties"
s.add_development_dependency "m"
s.add_development_dependency "sqlite3"
s.add_development_dependency "rake"
end
2 changes: 1 addition & 1 deletion test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

require File.expand_path("../dummy/config/environment.rb", __FILE__)
require "rails/test_help"
require "kramdown"
require "kramdown-parser-gfm"

Rails.backtrace_cleaner.remove_silencers!

Expand Down
7 changes: 7 additions & 0 deletions test/unit/markdown_engine_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,11 @@ def teardown
end
thread.join
end

test "handles code fences (GFM)" do
markdown = "```\nbar\n```"

actual = Maildown::MarkdownEngine.to_html(markdown)
assert_equal "<pre><code>bar\n</code></pre>\n", actual
end
end

0 comments on commit e0753e8

Please sign in to comment.