Module: HTML2TeX::TeX

Included in:
HTML2TeX, BasicProcessor
Defined in:
lib/html2tex/tex.rb

Instance Method Summary collapse

Instance Method Details

#tex(name, param = nil) ⇒ Object



3
4
5
6
7
# File 'lib/html2tex/tex.rb', line 3

def tex(name, param=nil)
  directive = "\\" + name.to_s
  directive << "{" << tex_escape(param) << "}" if param
  directive
end

#tex_escape(s) ⇒ Object



9
10
11
12
13
# File 'lib/html2tex/tex.rb', line 9

def tex_escape(s)
  return nil if s.nil?
  s.gsub(/\\/, "\\\\textbackslash\\").
    gsub(/[{}$&#%^_~]/, '\\\\\\0')
end