Class: JsonResume::FormatterLatex

Inherits:
Formatter show all
Defined in:
lib/json_resume/formatter_latex.rb

Instance Attribute Summary

Attributes inherited from Formatter

#hash

Instance Method Summary collapse

Methods inherited from Formatter

#add_last_marker_on_field, #add_last_marker_on_skills, #add_last_marker_on_stars, #add_last_marker_on_tools, #add_linkedin_github_url, #add_padding, #cleanse, #format_to_output_type, #initialize, #is_false?, #purge_gpa

Constructor Details

This class inherits a constructor from JsonResume::Formatter

Instance Method Details

#formatObject


48
49
50
51
52
# File 'lib/json_resume/formatter_latex.rb', line 48

def format
  super

  return self
end

16
17
18
# File 'lib/json_resume/formatter_latex.rb', line 16

def format_autolink str
    str.gsub!(/<<(\S*?)>>/, '{\color{see} \url{\1}}')
end

#format_emphasis(str) ⇒ Object


20
21
22
23
# File 'lib/json_resume/formatter_latex.rb', line 20

def format_emphasis str
  str.gsub!(/\b_(.+?)_\b/, '\textit{\1}')
  str.gsub!(/\*\*(.+?)\*\*/, '\textbf{\1}')
end

12
13
14
# File 'lib/json_resume/formatter_latex.rb', line 12

def format_link str
    str.gsub!(/\[(.*?)\]\((.*?)\)/, '{\color{see} \href{\2}{\1}}')
end

#format_slashes(str) ⇒ Object


6
7
8
9
10
# File 'lib/json_resume/formatter_latex.rb', line 6

def format_slashes str
    str.gsub!(/\\/, '\textbackslash')
    str.gsub!(/\{/, '\{')
    str.gsub!(/\}/, '\}')
end

#format_string(str) ⇒ Object


39
40
41
42
43
44
45
46
# File 'lib/json_resume/formatter_latex.rb', line 39

def format_string str
  format_slashes str
  format_link str
  format_autolink str
  format_emphasis str
  format_symbols str
  format_superscripts str
end

#format_superscripts(str) ⇒ Object


25
26
27
28
# File 'lib/json_resume/formatter_latex.rb', line 25

def format_superscripts str
  str.gsub!(/<sup>(.*?)<\/sup>/, '$^{\1}$')
  str.gsub!(/<sub>(.*?)<\/sub>/, '$_{\1}$')
end

#format_symbols(str) ⇒ Object


30
31
32
33
34
35
36
37
# File 'lib/json_resume/formatter_latex.rb', line 30

def format_symbols str
  str.gsub!(/#/, '\#')
  str.gsub!(/\$/, '\$')
  str.gsub!(/&/, '\\\\&')
  str.gsub!(/\|/, '\textbar')
  str.gsub!(/%/, '\%')
  str.gsub!(/_/, '\_')
end