Class: BlueCloth

Inherits:
Object
  • Object
show all
Defined in:
lib/shinmun/bluecloth_coderay.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#code_cssObject

Returns the value of attribute code_css.



3
4
5
# File 'lib/shinmun/bluecloth_coderay.rb', line 3

def code_css
  @code_css
end

Instance Method Details

#transform_code_blocks(str, rs) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/shinmun/bluecloth_coderay.rb', line 5

def transform_code_blocks( str, rs )
  @log.debug " Transforming code blocks"

  str.gsub(CodeBlockRegexp) {|block|
    codeblock = $1
    remainder = $2

    # Generate the codeblock
    if codeblock =~ /^(?:[ ]{4}|\t)@@(.*?)\n\n(.*)\n\n/m
       "\n\n<pre class='highlight'>%s</pre>\n\n%s" %
        [CodeRay.scan(outdent($2), $1).html(:css => (code_css || :class), :line_numbers => :list).delete("\n"), remainder]
    else
       "\n\n<pre><code>%s\n</code></pre>\n\n%s" %
        [encode_code(outdent(codeblock), rs).rstrip, remainder]
    end
  }
end