2005-01-24 19:52:04 +01:00
|
|
|
require 'chunks/chunk'
|
|
|
|
|
|
|
|
# These are basic chunks that have a pattern and can be protected.
|
|
|
|
# They are used by rendering process to prevent wiki rendering
|
|
|
|
# occuring within literal areas such as <code> and <pre> blocks
|
|
|
|
# and within HTML tags.
|
|
|
|
module Literal
|
2005-03-27 20:13:43 +02:00
|
|
|
|
|
|
|
class AbstractLiteral < Chunk::Abstract
|
|
|
|
|
|
|
|
def initialize(match_data, content)
|
|
|
|
super
|
|
|
|
@unmask_text = @text
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2005-01-24 19:52:04 +01:00
|
|
|
# A literal chunk that protects 'code' and 'pre' tags from wiki rendering.
|
2005-03-27 20:13:43 +02:00
|
|
|
class Pre < AbstractLiteral
|
2005-01-24 19:52:04 +01:00
|
|
|
PRE_BLOCKS = "a|pre|code"
|
2005-02-04 20:00:28 +01:00
|
|
|
PRE_PATTERN = Regexp.new('<('+PRE_BLOCKS+')\b[^>]*?>.*?</\1>', Regexp::MULTILINE)
|
|
|
|
def self.pattern() PRE_PATTERN end
|
2005-01-24 19:52:04 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
# A literal chunk that protects HTML tags from wiki rendering.
|
2005-03-27 20:13:43 +02:00
|
|
|
class Tags < AbstractLiteral
|
2005-01-24 19:52:04 +01:00
|
|
|
TAGS = "a|img|em|strong|div|span|table|td|th|ul|ol|li|dl|dt|dd"
|
2005-02-04 20:00:28 +01:00
|
|
|
TAGS_PATTERN = Regexp.new('<(?:'+TAGS+')[^>]*?>', Regexp::MULTILINE)
|
|
|
|
def self.pattern() TAGS_PATTERN end
|
2005-01-24 19:52:04 +01:00
|
|
|
end
|
|
|
|
end
|