From 780bf4fe919cde9e793fd4eaa5df20e91b72e783 Mon Sep 17 00:00:00 2001 From: Alexey Verkhovsky Date: Fri, 21 Jan 2005 22:28:37 +0000 Subject: [PATCH] a little golf --- app/models/chunks/wiki.rb | 6 ++++-- app/models/wiki_content.rb | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/models/chunks/wiki.rb b/app/models/chunks/wiki.rb index 28cf3e90..6c5e53b7 100755 --- a/app/models/chunks/wiki.rb +++ b/app/models/chunks/wiki.rb @@ -18,7 +18,7 @@ module WikiChunk # 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 regexp() Regexp.new(pre_mask + '(.*)?' + post_mask) end + def regexp() /#{pre_mask}(.*)?#{post_mask}/ 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. def unmask(content) 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 diff --git a/app/models/wiki_content.rb b/app/models/wiki_content.rb index 93489419..7ad11744 100755 --- a/app/models/wiki_content.rb +++ b/app/models/wiki_content.rb @@ -77,7 +77,7 @@ class WikiContent < String # Call @web.page_link using current options. def page_link(name, text) - @web.make_link(name, text, @options) + @web.make_link(name, text, @options) end # Find all the chunks of the given types