Method: Prawn::Text::Formatted::Parser.to_array

Defined in:
lib/prawn/text/formatted/parser.rb

.to_array(string) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/prawn/text/formatted/parser.rb', line 17

def self.to_array(string)
  regex_string = "\n|" +
                 "<b>|</b>|" +
                 "<i>|</i>|" +
                 "<u>|</u>|" +
                 "<strikethrough>|</strikethrough>|" +
                 "<sub>|</sub>|" +
                 "<sup>|</sup>|" +
                 "<link[^>]*>|</link>|" +
                 "<color[^>]*>|</color>|" +
                 "<font[^>]*>|</font>|" +
                 "<strong>|</strong>|" +
                 "<em>|</em>|" +
                 "<a[^>]*>|</a>|" +
                 "[^<\n]+"
  regex = Regexp.new(regex_string, Regexp::MULTILINE)
  tokens = string.scan(regex)
  self.array_from_tokens(tokens)
end