diff options
author | Brandon Mathis <brandon@imathis.com> | 2011-07-28 14:44:18 -0400 |
---|---|---|
committer | Brandon Mathis <brandon@imathis.com> | 2011-07-28 14:44:48 -0400 |
commit | 7209aaf64c70fdc254b7c3da98703b89296a61db (patch) | |
tree | 7ea865ce1746f1308a167a57adf3bd9932e87062 /plugins | |
parent | b37ce3a8ae9c1f53f27fc936656176cf2c755362 (diff) | |
download | my_new_personal_website-7209aaf64c70fdc254b7c3da98703b89296a61db.tar.xz my_new_personal_website-7209aaf64c70fdc254b7c3da98703b89296a61db.zip |
updated Github style backtick filter to support textile, markdown and html
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/octopress_filters.rb | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/plugins/octopress_filters.rb b/plugins/octopress_filters.rb index 7d73bdec..8c9367ba 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 /<p>`{3}\s(\w+)<\/p>\n\n<pre><code>([^<]+)<\/code><\/pre>\n\n<p>`{3}<\/p>/m do + # Markdown support + input = input.gsub /<p>`{3}\s(\w+)<\/p>\s*<pre><code>\s*(.+?)\s*<\/code><\/pre>\s*<p>`{3}<\/p>/m do lang = $1 str = $2.gsub('<','<').gsub('>','>') highlight(str, lang) end + + # Textile support + input = input.gsub /<p>`{3}\s(\w+)<br\s*\/>\n(.+?)`{3}<\/p>/m do + lang = $1 + str = $2.gsub(/^\s{4}/, '').gsub(/<br\s*\/>$/, '') + 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 |