Sha256: 2b4b443781cf1c4322170578b43c1dfe860d4bfd405c0a413f8575ced795a28b

Contents?: true

Size: 582 Bytes

Versions: 1

Compression:

Stored size: 582 Bytes

Contents

module Blocks
  BLOCK_TABLE = {
    ">>"      => '<blockquote>',
    "<<"      => '</blockquote>',
    ">||"     => '<pre>',
    "||<"     => '</pre>',
    ">|code|" => '<pre class="prettyprint">',
    "|code|<" => '</pre>'
  }

  def parse text
    block_rex = %r! 
      (^>>)|(^<<)                 # blockquote
      |
      (^>\|\|)|(^\|\|<)           # pre
      |
      (^\>\|code\|)|(^\|code\|\<) # google-code-prettify
    !x

    parse_text = text.gsub(block_rex){|s| BLOCK_TABLE[s]}
    return text if parse_text == nil
    parse_text
  end 

  module_function :parse
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wparser-0.0.2 lib/wparser/block/blocks.rb