From bc93d842dc0ee8b06d75efe685f63ab815b466c3 Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Wed, 14 Dec 2011 10:22:06 -0800 Subject: [PATCH] Fix redcarpet 2 extensions and add test cases. Fixes #200 --- features/markdown.feature | 26 ++++++++++++++++--- fixtures/markdown-app/config.rb | 9 +++++++ .../source/autolink.html.markdown | 5 ++++ .../source/fenced_code_blocks.html.markdown | 7 +++++ .../markdown-app/source/index.html.markdown | 4 +++ .../source/no_intra_emphasis.html.markdown | 5 ++++ .../source/smarty_pants.html.markdown | 5 ++++ .../source/space_after_headers.html.markdown | 5 ++++ .../source/strikethrough.html.markdown | 5 ++++ .../source/superscript.html.markdown | 5 ++++ .../markdown-app/source/tables.html.markdown | 8 ++++++ fixtures/test-app/config.rb | 1 - .../test-app/source/markdown.html.markdown | 1 - lib/middleman/renderers/markdown.rb | 6 +++++ 14 files changed, 87 insertions(+), 5 deletions(-) create mode 100644 fixtures/markdown-app/config.rb create mode 100755 fixtures/markdown-app/source/autolink.html.markdown create mode 100755 fixtures/markdown-app/source/fenced_code_blocks.html.markdown create mode 100755 fixtures/markdown-app/source/index.html.markdown create mode 100755 fixtures/markdown-app/source/no_intra_emphasis.html.markdown create mode 100755 fixtures/markdown-app/source/smarty_pants.html.markdown create mode 100755 fixtures/markdown-app/source/space_after_headers.html.markdown create mode 100755 fixtures/markdown-app/source/strikethrough.html.markdown create mode 100755 fixtures/markdown-app/source/superscript.html.markdown create mode 100755 fixtures/markdown-app/source/tables.html.markdown delete mode 100644 fixtures/test-app/source/markdown.html.markdown diff --git a/features/markdown.feature b/features/markdown.feature index ee11a120..722a9139 100644 --- a/features/markdown.feature +++ b/features/markdown.feature @@ -2,6 +2,26 @@ Feature: Markdown support In order to test included Maruku support Scenario: Rendering html - Given the Server is running at "test-app" - When I go to "/markdown.html" - Then I should see "

Hello World

" \ No newline at end of file + Given the Server is running at "markdown-app" + When I go to "/index.html" + Then I should see "

Hello World

" + + Scenario: Redcarpet 2 extensions + Given the Server is running at "markdown-app" + When I go to "/smarty_pants.html" + Then I should see "“" + When I go to "/no_intra_emphasis.html" + Then I should not see "" + When I go to "/tables.html" + Then I should see "" + When I go to "/fenced_code_blocks.html" + Then I should see "" + When I go to "/autolink.html" + Then I should see "" + When I go to "/space_after_headers.html" + Then I should not see "

" + When I go to "/superscript.html" + Then I should see "" + \ No newline at end of file diff --git a/fixtures/markdown-app/config.rb b/fixtures/markdown-app/config.rb new file mode 100644 index 00000000..3dbc5c06 --- /dev/null +++ b/fixtures/markdown-app/config.rb @@ -0,0 +1,9 @@ +set :markdown, :smartypants => true, + :no_intra_emphasis => true, + :tables => true, + :fenced_code_blocks => true, + :autolink => true, + :strikethrough => true, + :lax_html_blocks => true, + :space_after_headers => true, + :superscript => true \ No newline at end of file diff --git a/fixtures/markdown-app/source/autolink.html.markdown b/fixtures/markdown-app/source/autolink.html.markdown new file mode 100755 index 00000000..c42567ed --- /dev/null +++ b/fixtures/markdown-app/source/autolink.html.markdown @@ -0,0 +1,5 @@ +--- +layout: false +--- + +http://example.com \ No newline at end of file diff --git a/fixtures/markdown-app/source/fenced_code_blocks.html.markdown b/fixtures/markdown-app/source/fenced_code_blocks.html.markdown new file mode 100755 index 00000000..70b66179 --- /dev/null +++ b/fixtures/markdown-app/source/fenced_code_blocks.html.markdown @@ -0,0 +1,7 @@ +--- +layout: false +--- + +~~~~~~~~~~~~~~~~~~~~~ +a one-line code block +~~~~~~~~~~~~~~~~~~~~~ \ No newline at end of file diff --git a/fixtures/markdown-app/source/index.html.markdown b/fixtures/markdown-app/source/index.html.markdown new file mode 100755 index 00000000..4f970c47 --- /dev/null +++ b/fixtures/markdown-app/source/index.html.markdown @@ -0,0 +1,4 @@ +--- +layout: false +--- +Hello World \ No newline at end of file diff --git a/fixtures/markdown-app/source/no_intra_emphasis.html.markdown b/fixtures/markdown-app/source/no_intra_emphasis.html.markdown new file mode 100755 index 00000000..88840eb2 --- /dev/null +++ b/fixtures/markdown-app/source/no_intra_emphasis.html.markdown @@ -0,0 +1,5 @@ +--- +layout: false +--- + +foo_bar_baz \ No newline at end of file diff --git a/fixtures/markdown-app/source/smarty_pants.html.markdown b/fixtures/markdown-app/source/smarty_pants.html.markdown new file mode 100755 index 00000000..2dadeba1 --- /dev/null +++ b/fixtures/markdown-app/source/smarty_pants.html.markdown @@ -0,0 +1,5 @@ +--- +layout: false +--- + +"Hello" \ No newline at end of file diff --git a/fixtures/markdown-app/source/space_after_headers.html.markdown b/fixtures/markdown-app/source/space_after_headers.html.markdown new file mode 100755 index 00000000..8b51ca67 --- /dev/null +++ b/fixtures/markdown-app/source/space_after_headers.html.markdown @@ -0,0 +1,5 @@ +--- +layout: false +--- + +#this is my header \ No newline at end of file diff --git a/fixtures/markdown-app/source/strikethrough.html.markdown b/fixtures/markdown-app/source/strikethrough.html.markdown new file mode 100755 index 00000000..7ca9ac84 --- /dev/null +++ b/fixtures/markdown-app/source/strikethrough.html.markdown @@ -0,0 +1,5 @@ +--- +layout: false +--- + +~~Nope~~ \ No newline at end of file diff --git a/fixtures/markdown-app/source/superscript.html.markdown b/fixtures/markdown-app/source/superscript.html.markdown new file mode 100755 index 00000000..f6c7df70 --- /dev/null +++ b/fixtures/markdown-app/source/superscript.html.markdown @@ -0,0 +1,5 @@ +--- +layout: false +--- + +this is the 2^(nd) time \ No newline at end of file diff --git a/fixtures/markdown-app/source/tables.html.markdown b/fixtures/markdown-app/source/tables.html.markdown new file mode 100755 index 00000000..033fba90 --- /dev/null +++ b/fixtures/markdown-app/source/tables.html.markdown @@ -0,0 +1,8 @@ +--- +layout: false +--- + +First Header | Second Header +------------- | ------------- +Content Cell | Content Cell +Content Cell | Content Cell \ No newline at end of file diff --git a/fixtures/test-app/config.rb b/fixtures/test-app/config.rb index ac793ef7..72043ec3 100644 --- a/fixtures/test-app/config.rb +++ b/fixtures/test-app/config.rb @@ -23,7 +23,6 @@ end with_layout false do page "/request-path.html" page "/lorem.html" - page "/markdown.html" page "/relative_image.html" page "/inline-css.html" page "/inline-js.html" diff --git a/fixtures/test-app/source/markdown.html.markdown b/fixtures/test-app/source/markdown.html.markdown deleted file mode 100644 index 5e1c309d..00000000 --- a/fixtures/test-app/source/markdown.html.markdown +++ /dev/null @@ -1 +0,0 @@ -Hello World \ No newline at end of file diff --git a/lib/middleman/renderers/markdown.rb b/lib/middleman/renderers/markdown.rb index 3852b08a..163ac87e 100644 --- a/lib/middleman/renderers/markdown.rb +++ b/lib/middleman/renderers/markdown.rb @@ -2,6 +2,12 @@ module Middleman::Renderers::Markdown class << self def registered(app) require "redcarpet" + + # Forcably disable Redcarpet1 support. + # Tilt defaults to this if available, but the compat + # layer disables extensions. + Object.send(:remove_const, :RedcarpetCompat) if defined? ::RedcarpetCompat + app.set :markdown_engine, :redcarpet app.set :markdown_engine_prefix, ::Tilt