a little golf

This commit is contained in:
Alexey Verkhovsky 2005-01-21 22:28:37 +00:00
parent 75b6d30d80
commit 780bf4fe91
2 changed files with 5 additions and 3 deletions

View file

@ -18,7 +18,7 @@ module WikiChunk
# the word is escaped. In that case, just return the link text # the word is escaped. In that case, just return the link text
def mask(content) escaped_text || pre_mask + link_text + post_mask end def mask(content) escaped_text || pre_mask + link_text + post_mask end
def regexp() Regexp.new(pre_mask + '(.*)?' + post_mask) end def regexp() /#{pre_mask}(.*)?#{post_mask}/ end
def revert(content) content.sub!(regexp, text) end def revert(content) content.sub!(regexp, text) end
@ -27,7 +27,9 @@ module WikiChunk
# get back a string of HTML to replace the mask with. # get back a string of HTML to replace the mask with.
def unmask(content) def unmask(content)
return nil if escaped_text return nil if escaped_text
return self if content.sub!(regexp) { |match| content.page_link(page_name, $1) } return self if content.sub!(regexp) do |match|
content.page_link(page_name, $1)
end
end end
end end