... | ... |
@@ -26,11 +26,25 @@ module OctopressFilters |
26 | 26 |
# code snippet |
27 | 27 |
# ``` |
28 | 28 |
def backtick_codeblock(input) |
29 |
- input.gsub /<p>`{3}\s(\w+)<\/p>\n\n<pre><code>([^<]+)<\/code><\/pre>\n\n<p>`{3}<\/p>/m do |
|
29 |
+ # Markdown support |
|
30 |
+ input = input.gsub /<p>`{3}\s(\w+)<\/p>\s*<pre><code>\s*(.+?)\s*<\/code><\/pre>\s*<p>`{3}<\/p>/m do |
|
30 | 31 |
lang = $1 |
31 | 32 |
str = $2.gsub('<','<').gsub('>','>') |
32 | 33 |
highlight(str, lang) |
33 | 34 |
end |
35 |
+ |
|
36 |
+ # Textile support |
|
37 |
+ input = input.gsub /<p>`{3}\s(\w+)<br\s*\/>\n(.+?)`{3}<\/p>/m do |
|
38 |
+ lang = $1 |
|
39 |
+ str = $2.gsub(/^\s{4}/, '').gsub(/<br\s*\/>$/, '') |
|
40 |
+ highlight(str, lang) |
|
41 |
+ end |
|
42 |
+ |
|
43 |
+ input.gsub /^`{3}\s(\w+)\n(.+?)\n`{3}/m do |
|
44 |
+ lang = $1 |
|
45 |
+ str = $2.gsub(/^\s{4}/, '') |
|
46 |
+ highlight(str, lang) |
|
47 |
+ end |
|
34 | 48 |
end |
35 | 49 |
|
36 | 50 |
# Replaces relative urls with full urls |