mirror of
https://github.com/WatchOutNewsAgency/wona.github.com.git
synced 2026-02-11 08:20:53 +00:00
Codeblock regex improved to better detect extensions fixes #96, added support for tableizing non highlighted code blocks from liquid codeblock tag and backtick code blocks
This commit is contained in:
@ -26,14 +26,17 @@ module OctopressFilters
|
||||
# code snippet
|
||||
# ```
|
||||
def backtick_codeblock(input)
|
||||
code = nil
|
||||
# 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
|
||||
if lang != ''
|
||||
str = $2.gsub('<','<').gsub('>','>').gsub('&','&')
|
||||
highlight(str, lang)
|
||||
code = highlight(str, lang)
|
||||
"<figure role=code>#{code}</figure>"
|
||||
else
|
||||
"<pre><code>#{$2}</code></pre>"
|
||||
code = tableize_code($2)
|
||||
"<figure role=code>#{code}</figure>"
|
||||
end
|
||||
end
|
||||
|
||||
@ -48,9 +51,11 @@ module OctopressFilters
|
||||
lang = $1
|
||||
str = $2.gsub(/^\s{4}/, '')
|
||||
if lang != ''
|
||||
highlight(str, lang)
|
||||
code = highlight(str, lang)
|
||||
"<figure role=code>#{code}</figure>"
|
||||
else
|
||||
"<pre><code>#{$2.gsub('<','<').gsub('>','>')}</code></pre>"
|
||||
code = tableize_code($2.gsub('<','<').gsub('>','>'))
|
||||
"<figure role=code>#{code}</figure>"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user