aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrandon Mathis <brandon@imathis.com>2011-09-07 23:29:54 -0500
committerBrandon Mathis <brandon@imathis.com>2011-09-07 23:30:09 -0500
commita289c909092ff025e7444fa73b4039d112ecbce8 (patch)
tree453be50ae0bdf3d27412cf57aef5d54553245c62
parent3d2d1a8be49f3d2db16618014d38d5b93ef0c58f (diff)
downloadmy_new_personal_website-a289c909092ff025e7444fa73b4039d112ecbce8.tar.xz
my_new_personal_website-a289c909092ff025e7444fa73b4039d112ecbce8.zip
improved backtick codeblock's handling of the raw option
Diffstat (limited to '')
-rw-r--r--plugins/backtick_code_block.rb9
1 files changed, 5 insertions, 4 deletions
diff --git a/plugins/backtick_code_block.rb b/plugins/backtick_code_block.rb
index c7a83435..7f5076df 100644
--- a/plugins/backtick_code_block.rb
+++ b/plugins/backtick_code_block.rb
@@ -5,18 +5,19 @@ module BacktickCodeBlock
AllOptions = /([^\s]+)\s+(.+?)(https?:\/\/\S+)\s*(.+)?/i
LangCaption = /([^\s]+)\s*(.+)?/i
def render_code_block(input)
+ @options = nil
@caption = nil
@lang = nil
@url = nil
@title = nil
input.gsub /^`{3} *([^\n]+)?\n(.+?)\n`{3}/m do
- options = $1
+ @options = $1 || ''
str = $2
- if options =~ AllOptions
+ if @options =~ AllOptions
@lang = $1
@caption = "<figcaption><span>#{$2}</span><a href='#{$3}'>#{$4 || 'link'}</a></figcaption>"
- elsif options =~ LangCaption
+ elsif @options =~ LangCaption
@lang = $1
@caption = "<figcaption><span>#{$2}</span></figcaption>"
end
@@ -29,7 +30,7 @@ module BacktickCodeBlock
"<figure role=code>#{@caption}#{code}</figure>"
else
if @lang.include? "-raw"
- raw = "``` #{@lang.sub('-raw', '')}\n"
+ raw = "``` #{@options.sub('-raw', '')}\n"
raw += str
raw += "\n```\n"
else