diff --git a/app/models/chunks/wiki.rb b/app/models/chunks/wiki.rb index 82042acd..28cf3e90 100755 --- a/app/models/chunks/wiki.rb +++ b/app/models/chunks/wiki.rb @@ -62,11 +62,12 @@ module WikiChunk # NOTE: This chunk must be tested before WikiWord since # a WikiWords can be a substring of a WikiLink. class Link < WikiLink - def self.pattern() /\[\[([^\]]+)\]\]/ end - unless defined? ALIASED_LINK_PATTERN - ALIASED_LINK_PATTERN = Regexp.new('^(.*)?\|(.*)$', 0, 'utf-8') - end + WIKI_LINK = /\[\[([^\]]+)\]\]/ unless defined? WIKI_LINK + ALIASED_LINK_PATTERN = + Regexp.new('^(.*)?\|(.*)$', 0, 'utf-8') unless defined? ALIASED_LINK_PATTERN + + def self.pattern() WIKI_LINK end attr_reader :page_name, :link_text diff --git a/app/models/wiki_words.rb b/app/models/wiki_words.rb index 5cb60ac8..352d3763 100755 --- a/app/models/wiki_words.rb +++ b/app/models/wiki_words.rb @@ -14,12 +14,13 @@ module WikiWords "աբգդեզէըթժիլխծկհձղճմյնշոչպջռսվտրցւփքօֆև" WIKI_WORD_PATTERN = '[A-Z' + I18N_HIGHER_CASE_LETTERS + '][a-z' + I18N_LOWER_CASE_LETTERS + ']+[A-Z' + I18N_HIGHER_CASE_LETTERS + ']\w+' + CAMEL_CASED_WORD_BORDER = /([a-z#{I18N_LOWER_CASE_LETTERS}])([A-Z#{I18N_HIGHER_CASE_LETTERS}])/u def self.separate(wiki_word, ignore_separation = false) if ignore_separation wiki_word else - wiki_word.gsub(/([a-z#{I18N_LOWER_CASE_LETTERS}])([A-Z#{I18N_HIGHER_CASE_LETTERS}])/u, '\1 \2') + wiki_word.gsub(CAMEL_CASED_WORD_BORDER, '\1 \2') end end end \ No newline at end of file