From 7209aaf64c70fdc254b7c3da98703b89296a61db Mon Sep 17 00:00:00 2001 From: Brandon Mathis Date: Thu, 28 Jul 2011 14:44:18 -0400 Subject: [PATCH] updated Github style backtick filter to support textile, markdown and html --- plugins/octopress_filters.rb | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/plugins/octopress_filters.rb b/plugins/octopress_filters.rb index 7d73bde..8c9367b 100644 --- a/plugins/octopress_filters.rb +++ b/plugins/octopress_filters.rb @@ -26,11 +26,25 @@ module OctopressFilters # code snippet # ``` def backtick_codeblock(input) - input.gsub /

`{3}\s(\w+)<\/p>\n\n

([^<]+)<\/code><\/pre>\n\n

`{3}<\/p>/m do + # Markdown support + input = input.gsub /

`{3}\s(\w+)<\/p>\s*

\s*(.+?)\s*<\/code><\/pre>\s*

`{3}<\/p>/m do lang = $1 str = $2.gsub('<','<').gsub('>','>') highlight(str, lang) end + + # Textile support + input = input.gsub /

`{3}\s(\w+)\n(.+?)`{3}<\/p>/m do + lang = $1 + str = $2.gsub(/^\s{4}/, '').gsub(/$/, '') + highlight(str, lang) + end + + input.gsub /^`{3}\s(\w+)\n(.+?)\n`{3}/m do + lang = $1 + str = $2.gsub(/^\s{4}/, '') + highlight(str, lang) + end end # Replaces relative urls with full urls