2008-11-12 16:47:24 +01:00
|
|
|
#coding: utf-8
|
2007-01-22 14:43:50 +01:00
|
|
|
# Contains all the methods for finding and replacing wiki words
|
2009-12-12 22:28:05 +01:00
|
|
|
|
2010-06-09 18:47:39 +02:00
|
|
|
require 'instiki_stringsupport'
|
2009-12-12 22:28:05 +01:00
|
|
|
|
2007-01-22 14:43:50 +01:00
|
|
|
module WikiWords
|
2008-11-24 22:53:39 +01:00
|
|
|
# In order of appearance: Latin, greek, cyrillic, armenian
|
2007-01-22 14:43:50 +01:00
|
|
|
I18N_HIGHER_CASE_LETTERS =
|
2008-11-12 16:47:24 +01:00
|
|
|
"ÀÁÂÃÄÅĀĄĂÆÇĆČĈĊĎĐÈÉÊËĒĘĚĔĖĜĞĠĢĤĦÌÍÎÏĪĨĬĮİIJĴĶŁĽĹĻĿÑŃŇŅŊÒÓÔÕÖØŌŐŎŒŔŘŖŚŠŞŜȘŤŢŦȚÙÚÛÜŪŮŰŬŨŲŴŶŸȲÝŹŽŻ" +
|
|
|
|
"ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ" +
|
|
|
|
"ΆΈΉΊΌΎΏѠѢѤѦѨѪѬѮѰѲѴѶѸѺѼѾҀҊҌҎҐҒҔҖҘҚҜҞҠҢҤҦҨҪҬҮҰҲҴҶҸҺҼҾӁӃӅӇӉӋӍӏӐӒӔӖӘӚӜӞӠӢӤӦӨӪӬӮӰӲӴӸЖ" +
|
|
|
|
"ԱԲԳԴԵԶԷԸԹԺԻԼԽԾԿՀՁՂՃՄՅՆՇՈՉՊՋՌՍՎՏՐՑՒՓՔՕՖ"
|
2007-01-22 14:43:50 +01:00
|
|
|
|
|
|
|
I18N_LOWER_CASE_LETTERS =
|
2008-11-12 16:47:24 +01:00
|
|
|
"àáâãäåāąăæçćĉċčďđèéêëēęěĕėƒĝğġģĥħìíîïīĩĭįıijĵķĸłľĺļŀñńňņʼnŋòóôõöøōŏőœŕřŗśŝšşșťţŧțùúûüūůűŭũųŵýÿŷžżźÞþßſð" +
|
|
|
|
"άέήίΰαβγδεζηθικλμνξοπρςστυφχψωϊϋόύώΐ" +
|
|
|
|
"абвгдежзийклмнопрстуфхцчшщъыьэюяѐёђѓєѕіїјљћќѝўџѡѣѥѧѩѫѭѯѱѳѵѷѹѻѽѿҁҋҌҍҏґғҕҗҙқҝҟҡңҥҧҩҫҭүұҳҵҷҹһҽҿӀӂӄӆӈӊӌӎӑӓӕӗәӛӝӟӡӣӥӧөӫӭӯӱӳӵӹ" +
|
|
|
|
"աբգդեզէըթժիլխծկհձղճմյնշոչպջռսվտրցւփքօֆև"
|
2007-01-22 14:43:50 +01:00
|
|
|
|
2008-12-26 00:41:35 +01:00
|
|
|
WIKI_WORD_PATTERN = '[A-Z' + I18N_HIGHER_CASE_LETTERS + ']+[a-z' + I18N_LOWER_CASE_LETTERS + ']+[A-Z' + I18N_HIGHER_CASE_LETTERS + ']\w+'
|
2007-01-22 14:43:50 +01:00
|
|
|
CAMEL_CASED_WORD_BORDER = /([a-z#{I18N_LOWER_CASE_LETTERS}])([A-Z#{I18N_HIGHER_CASE_LETTERS}])/u
|
|
|
|
|
|
|
|
def self.separate(wiki_word)
|
2009-12-12 22:28:05 +01:00
|
|
|
wiki_word.dup.as_utf8.gsub(CAMEL_CASED_WORD_BORDER, '\1 \2')
|
2007-01-22 14:43:50 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|