class Latexpdf::Escaper

Constants

ESCAPE_RE
ESC_MAP

Public Instance Methods

remove_non_printable_chars(text) click to toggle source
# File lib/latexpdf/escaper.rb, line 17
def remove_non_printable_chars(text)
  pattern = /([\x00-\x08\x0B-\x1F\x7F])/
  text.gsub(pattern, "")
end
tab_newline_to_space(text) click to toggle source
# File lib/latexpdf/escaper.rb, line 13
def tab_newline_to_space(text)
  text.gsub(/[\x09\x0A]/, " ")
end
tex_safe(text) click to toggle source
# File lib/latexpdf/escaper.rb, line 22
def tex_safe(text)
  text = text.gsub(ESCAPE_RE) { |m|
    if $1
      "\\#{m}"
    else
      "\\text#{ESC_MAP[m]}{}"
    end
  }
  text = tab_newline_to_space(text)
  text = remove_non_printable_chars(text)
  text.html_safe
end