From a289c909092ff025e7444fa73b4039d112ecbce8 Mon Sep 17 00:00:00 2001 From: Brandon Mathis Date: Wed, 7 Sep 2011 23:29:54 -0500 Subject: [PATCH] improved backtick codeblock's handling of the raw option --- plugins/backtick_code_block.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/plugins/backtick_code_block.rb b/plugins/backtick_code_block.rb index c7a8343..7f5076d 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 = "
#{$2}#{$4 || 'link'}
" - elsif options =~ LangCaption + elsif @options =~ LangCaption @lang = $1 @caption = "
#{$2}
" end @@ -29,7 +30,7 @@ module BacktickCodeBlock "
#{@caption}#{code}
" else if @lang.include? "-raw" - raw = "``` #{@lang.sub('-raw', '')}\n" + raw = "``` #{@options.sub('-raw', '')}\n" raw += str raw += "\n```\n" else