mirror of
https://github.com/moparisthebest/android.moparisthebest.org
synced 2024-11-17 14:45:01 -05:00
Add support using github backtick code blocks without supplying a language
This commit is contained in:
parent
2af038a725
commit
49a67785dc
@ -27,24 +27,36 @@ module OctopressFilters
|
|||||||
# ```
|
# ```
|
||||||
def backtick_codeblock(input)
|
def backtick_codeblock(input)
|
||||||
# Markdown support
|
# Markdown support
|
||||||
input = input.gsub /<p>`{3}\s(\w+)<\/p>\s*<pre><code>\s*(.+?)\s*<\/code><\/pre>\s*<p>`{3}<\/p>/m do
|
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
|
||||||
|
if lang != ''
|
||||||
str = $2.gsub('<','<').gsub('>','>')
|
str = $2.gsub('<','<').gsub('>','>')
|
||||||
highlight(str, lang)
|
highlight(str, lang)
|
||||||
|
else
|
||||||
|
"<pre><code>#{$2}</code></pre>"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Textile support
|
# Textile support
|
||||||
input = input.gsub /<p>`{3}\s(\w+)<br\s*\/>\n(.+?)`{3}<\/p>/m do
|
input = input.gsub /<p>`{3}\s*(\w+)?<br\s*\/>\n(.+?)`{3}<\/p>/m do
|
||||||
lang = $1
|
lang = $1
|
||||||
str = $2.gsub('<','<').gsub('>','>').gsub(/^\s{4}/, '').gsub(/(<br\s\/>)?$/, '')
|
str = $2.gsub('<','<').gsub('>','>').gsub(/^\s{4}/, '').gsub(/(<br\s\/>)?$/, '')
|
||||||
|
if lang != ''
|
||||||
highlight(str, lang)
|
highlight(str, lang)
|
||||||
|
else
|
||||||
|
"<pre><code>#{$2}</code></pre>"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Regular HTML support
|
# Regular HTML support
|
||||||
input.gsub /^`{3}\s(\w+)\n(.+?)\n`{3}/m do
|
input.gsub /^`{3}\s*(\w+)?\n(.+?)\n`{3}/m do
|
||||||
lang = $1
|
lang = $1
|
||||||
str = $2.gsub(/^\s{4}/, '')
|
str = $2.gsub(/^\s{4}/, '')
|
||||||
|
if lang != ''
|
||||||
highlight(str, lang)
|
highlight(str, lang)
|
||||||
|
else
|
||||||
|
"<pre><code>#{$2.gsub('<','<').gsub('>','>')}</code></pre>"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user