Sha256: ffa45a168d328687948c3c125c7ec2e31764fa3f42f6bb849145c6d2e41ad0a1

Contents?: true

Size: 1.14 KB

Versions: 2

Compression:

Stored size: 1.14 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

2 entries across 2 versions & 1 rubygems

Version Path
Pimki-1.8.092 app/models/chunks/engines.rb
Pimki-1.8.200 app/models/chunks/engines.rb