This commit is contained in:
r888888888
2014-02-27 13:41:36 -08:00
parent e53f19d9dd
commit 165e3a4efa
4 changed files with 36 additions and 3 deletions

View File

@@ -10,6 +10,28 @@ class DText
CGI.escapeHTML(string)
end
def self.strip_blocks(string, tag)
blocks = string.scan(/\[\/?#{tag}\]|.+?(?=\[\/?#{tag}\]|$)/m)
n = 0
stripped = ""
blocks.each do |block|
case block
when "[#{tag}]"
n += 1
when "[/#{tag}]"
n -= 1
else
if n == 0
stripped += block
end
end
end
stripped.strip
end
def self.parse_inline(str, options = {})
str.gsub!(/&/, "&")
str.gsub!(/</, "&lt;")