Sha256: c693a4f4bca55febcaa612f8a76f357a628865a2b5db0fb9ad877a556a179d81

Contents?: true

Size: 1.18 KB

Versions: 3

Compression:

Stored size: 1.18 KB

Contents

require 'rdocsupport'
require 'chunks/chunk'

# The markup engines are Chunks that call the one of RedCloth, BlueCloth
# or RDoc to convert text. This markup occurs when the chunk is required
# to mask itself.
module Engines
  
  class MarkupEngine < Chunk::Abstract
    def self.pattern() /^(.*)$/m end
    def unmask(content) self end
  end
  
  class Textile < MarkupEngine
    def mask(content)
      rc = RedCloth.new(text,content.options[:engine_opts])
      rc.rules = [:textile] if RedCloth::VERSION >= '3.0.0'
      rc.to_html
    end
  end

  class RedMarkdown < MarkupEngine
    def mask(content)
      rc = RedCloth.new(text,content.options[:engine_opts])
      rc.rules = [:markdown]
      rc.to_html
    end
  end

  class BlueMarkdown < MarkupEngine
    def mask(content)
      BlueCloth.new(text,content.options[:engine_opts]).to_html
    end
  end

  class RDoc < MarkupEngine
    def mask(content)
      RDocSupport::RDocFormatter.new(text).to_html
    end
  end

  MAP = { :textile => Textile, 
          :red_markdown => RedMarkdown, 
          :blue_markdown => BlueMarkdown,
          :markdown => BlueMarkdown,
          :rdoc => RDoc }
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
Pimki-1.5.092 app/models/chunks/engines.rb
Pimki-1.6.092 app/models/chunks/engines.rb
Pimki-1.7.092 app/models/chunks/engines.rb