Sha256: 20c7d3640cc256b0658f24a376ca88119c8bb7103589f65b89f6eb089b5251d0

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 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]
      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, :rdoc => RDoc }
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
Pimki-1.4.092 app/models/chunks/engines.rb