Module: Wptemplates::Regexes

Included in:
Parser
Defined in:
lib/wptemplates/regexes.rb

Class Method Summary collapse

Class Method Details

.a_doubleclosingbraceObject



52
53
54
# File 'lib/wptemplates/regexes.rb', line 52

def a_doubleclosingbrace
  /}}/
end

.a_doubleopenbraceObject



48
49
50
# File 'lib/wptemplates/regexes.rb', line 48

def a_doubleopenbrace
  /{{/
end


56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/wptemplates/regexes.rb', line 56

def a_link
  /
    \[\[
      (?<link>
        # ([% title-legal-chars])+
        [%\ !"$&'()*,\-.\/0-9:;=?@A-Z\\^_`a-z~\u0080-\uFFFF+]+
        # ("#" [# % title-legal-chars]+)?
        ( \# [\#%\ !"$&'()*,\-.\/0-9:;=?@A-Z\\^_`a-z~\u0080-\uFFFF+]+ )?
      )
      (
        # "|" LEGAL_ARTICLE_ENTITY*
        \| (?<link-description>([^\]]|\](?!\]))*)
      )?
    \]\]
    (?<extra_letters>\p{L}*)
  /x
end

.a_pipeObject



44
45
46
# File 'lib/wptemplates/regexes.rb', line 44

def a_pipe
  /\|/
end

.after_hashObject



78
79
80
# File 'lib/wptemplates/regexes.rb', line 78

def after_hash
  /(?<=#).*/
end

.first_commaObject



86
87
88
# File 'lib/wptemplates/regexes.rb', line 86

def first_comma
  /^(?<before>([^,]|,(?! ))*)(, |$)/
end

.from_pipe_till_equals_no_doubleclosebrace_or_pipeObject



33
34
35
36
37
38
39
40
41
42
# File 'lib/wptemplates/regexes.rb', line 33

def from_pipe_till_equals_no_doubleclosebrace_or_pipe
  /
    \| # Pipe
    ((
     [^|=}]   # Unproblematic chars
    |}(?!})   # A lone close brace
    )*)
    = # Equals
  /x
end

.has_parensObject



82
83
84
# File 'lib/wptemplates/regexes.rb', line 82

def has_parens
  /^(?<no_parens>.*?) *\(.*\) *$/
end

.parensObject



90
91
92
# File 'lib/wptemplates/regexes.rb', line 90

def parens
  /^(?<before>.*?)(\(.*\) *)?$/
end

.till_doublebrace_doubleopenbrackets_or_pipeObject



7
8
9
10
11
12
13
14
15
# File 'lib/wptemplates/regexes.rb', line 7

def till_doublebrace_doubleopenbrackets_or_pipe
  /(
     [^{}\[|] # Unproblematic chars
  |  { (?!{ ) # A lone open brace
  |  } (?!} ) # A lone close brace
  |  \[(?!\[) # A lone open bracket
  |  ^\[\[    # Doubleopenbrackets at start
  )+/x
end

.till_doubleclosebrace_or_pipeObject



26
27
28
29
30
31
# File 'lib/wptemplates/regexes.rb', line 26

def till_doubleclosebrace_or_pipe
  /(
     [^|}]    # Unproblematic chars
  |  } (?!} ) # A lone close brace
  )+/x
end

.till_doubleopenbrace_or_doubleopenbracketsObject



17
18
19
20
21
22
23
24
# File 'lib/wptemplates/regexes.rb', line 17

def till_doubleopenbrace_or_doubleopenbrackets
  /(
     [^{\[]   # Unproblematic chars
  |  { (?!{ ) # A lone open brace
  |  \[(?!\[) # A lone open bracket
  |  ^\[\[    # Doubleopenbrackets at start
  )+/x
end

.until_hashObject



74
75
76
# File 'lib/wptemplates/regexes.rb', line 74

def until_hash
  /[^#]*/
end