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