more regexp caching
This commit is contained in:
parent
9ea307b9d2
commit
ace569ae05
4 changed files with 10 additions and 6 deletions
|
@ -8,7 +8,8 @@ require 'chunks/chunk'
|
||||||
#
|
#
|
||||||
# Category lines can be hidden using ':category: news', for example
|
# Category lines can be hidden using ':category: news', for example
|
||||||
class Category < Chunk::Abstract
|
class Category < Chunk::Abstract
|
||||||
def self.pattern() return /^(:)?category\s*:(.*)$/i end
|
CATEGORY_PATTERN = /^(:)?category\s*:(.*)$/i
|
||||||
|
def self.pattern() CATEGORY_PATTERN end
|
||||||
|
|
||||||
attr_reader :hidden, :list
|
attr_reader :hidden, :list
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,8 @@ require 'chunks/wiki'
|
||||||
# of changes to that page.
|
# of changes to that page.
|
||||||
# If the included page could not be found, a warning is displayed.
|
# If the included page could not be found, a warning is displayed.
|
||||||
class Include < WikiChunk::WikiLink
|
class Include < WikiChunk::WikiLink
|
||||||
def self.pattern() /^\[\[!include(.*)\]\]\s*$/i end
|
INCLUDE_PATTERN = /^\[\[!include(.*)\]\]\s*$/i
|
||||||
|
def self.pattern() INCLUDE_PATTERN end
|
||||||
|
|
||||||
attr_reader :page_name
|
attr_reader :page_name
|
||||||
|
|
||||||
|
|
|
@ -8,12 +8,14 @@ module Literal
|
||||||
# A literal chunk that protects 'code' and 'pre' tags from wiki rendering.
|
# A literal chunk that protects 'code' and 'pre' tags from wiki rendering.
|
||||||
class Pre < Chunk::Abstract
|
class Pre < Chunk::Abstract
|
||||||
PRE_BLOCKS = "a|pre|code"
|
PRE_BLOCKS = "a|pre|code"
|
||||||
def self.pattern() Regexp.new('<('+PRE_BLOCKS+')\b[^>]*?>.*?</\1>', Regexp::MULTILINE) end
|
PRE_PATTERN = Regexp.new('<('+PRE_BLOCKS+')\b[^>]*?>.*?</\1>', Regexp::MULTILINE)
|
||||||
|
def self.pattern() PRE_PATTERN end
|
||||||
end
|
end
|
||||||
|
|
||||||
# A literal chunk that protects HTML tags from wiki rendering.
|
# A literal chunk that protects HTML tags from wiki rendering.
|
||||||
class Tags < Chunk::Abstract
|
class Tags < Chunk::Abstract
|
||||||
TAGS = "a|img|em|strong|div|span|table|td|th|ul|ol|li|dl|dt|dd"
|
TAGS = "a|img|em|strong|div|span|table|td|th|ul|ol|li|dl|dt|dd"
|
||||||
def self.pattern() Regexp.new('<(?:'+TAGS+')[^>]*?>', Regexp::MULTILINE) end
|
TAGS_PATTERN = Regexp.new('<(?:'+TAGS+')[^>]*?>', Regexp::MULTILINE)
|
||||||
|
def self.pattern() TAGS_PATTERN end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -14,8 +14,8 @@ require 'chunks/chunk'
|
||||||
# Author: Mark Reid <mark at threewordslong dot com>
|
# Author: Mark Reid <mark at threewordslong dot com>
|
||||||
# Created: 8th June 2004
|
# Created: 8th June 2004
|
||||||
class NoWiki < Chunk::Abstract
|
class NoWiki < Chunk::Abstract
|
||||||
|
NOWIKI_PATTERN = Regexp.new('<nowiki>(.*?)</nowiki>')
|
||||||
def self.pattern() Regexp.new('<nowiki>(.*?)</nowiki>') end
|
def self.pattern() NOWIKI_PATTERN end
|
||||||
|
|
||||||
attr_reader :plain_text
|
attr_reader :plain_text
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue