aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorBrandon Mathis <brandon@imathis.com>2011-07-26 23:37:31 -0400
committerBrandon Mathis <brandon@imathis.com>2011-07-26 23:37:31 -0400
commit6e2beaa969d6dd68652fa2cd79ad4eb6eeeaae49 (patch)
treecd7bd3f5dce02c36501738cdeae3633a2c0d5128 /plugins
parent786b8e8783cb596f8c375b8ba6dea9123ae9620a (diff)
downloadmy_new_personal_website-6e2beaa969d6dd68652fa2cd79ad4eb6eeeaae49.tar.xz
my_new_personal_website-6e2beaa969d6dd68652fa2cd79ad4eb6eeeaae49.zip
added support for github style backtick code blocks
Diffstat (limited to 'plugins')
-rw-r--r--plugins/octopress_filters.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/plugins/octopress_filters.rb b/plugins/octopress_filters.rb
index 429e505c..e85466e3 100644
--- a/plugins/octopress_filters.rb
+++ b/plugins/octopress_filters.rb
@@ -1,6 +1,8 @@
#custom filters for Octopress
+require './plugins/pygments_code'
module OctopressFilters
+ include HighlightCode
# Used on the blog index to split posts on the <!--more--> marker
def excerpt(input)
if input.index(/<!--\s*more\s*-->/i)
@@ -19,6 +21,18 @@ module OctopressFilters
end
end
+ # for Github style codeblocks eg.
+ # ``` ruby
+ # code snippet
+ # ```
+ def backtick_codeblock(input)
+ input.gsub /<p>`{3}\s(\w+)<\/p>.+<pre><code>(.+)<\/code><\/pre>.+`{3}<\/p>/m do
+ lang = $1
+ str = $2.gsub(/^\s{4}/, '').gsub('&lt;','<').gsub('&gt;','>')
+ highlight(str, lang)
+ end
+ end
+
# Replaces relative urls with full urls
def expand_urls(input, url='')
url ||= '/'