updated Github style backtick filter to support textile, markdown and html
This commit is contained in:
parent
b37ce3a8ae
commit
7209aaf64c
@ -26,11 +26,25 @@ module OctopressFilters
|
|||||||
# code snippet
|
# code snippet
|
||||||
# ```
|
# ```
|
||||||
def backtick_codeblock(input)
|
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
|
lang = $1
|
||||||
str = $2.gsub('<','<').gsub('>','>')
|
str = $2.gsub('<','<').gsub('>','>')
|
||||||
highlight(str, lang)
|
highlight(str, lang)
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
# Replaces relative urls with full urls
|
# Replaces relative urls with full urls
|
||||||
|
Loading…
Reference in New Issue
Block a user