Class: Publishr::LatexRenderer
- Inherits:
-
Object
- Object
- Publishr::LatexRenderer
- Defined in:
- lib/publishr/latex_renderer.rb
Instance Method Summary collapse
-
#initialize(name, path, metadata) ⇒ LatexRenderer
constructor
A new instance of LatexRenderer.
- #make_tex_directory_structure ⇒ Object
- #render ⇒ Object
- #render_tex ⇒ Object
Constructor Details
#initialize(name, path, metadata) ⇒ LatexRenderer
Returns a new instance of LatexRenderer.
20 21 22 23 24 25 26 |
# File 'lib/publishr/latex_renderer.rb', line 20 def initialize(name,path,) @name = name @inpath = path @outpath = File.join(@inpath,'latex') @gempath = Publishr::Project.gempath @metadata = end |
Instance Method Details
#make_tex_directory_structure ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/publishr/latex_renderer.rb', line 33 def make_tex_directory_structure FileUtils.mkdir_p @outpath FileUtils.cp Dir[File.join(@inpath,'images','*.jpg')], @outpath FileUtils.cp Dir[File.join(@inpath,'images','*.eps')], @outpath FileUtils.cp_r File.join(@gempath,'lib','tex_templates','book.tex'), @outpath FileUtils.cp_r Dir[File.join(@inpath,'*.tex')], @outpath end |
#render ⇒ Object
28 29 30 31 |
# File 'lib/publishr/latex_renderer.rb', line 28 def render make_tex_directory_structure render_tex end |
#render_tex ⇒ Object
41 42 43 44 45 46 47 48 49 |
# File 'lib/publishr/latex_renderer.rb', line 41 def render_tex Dir[File.join(@inpath,'*.txt')].each do |infilepath| kramdown = File.open(infilepath, 'r').read latex = Kramdown::Document.new(kramdown, @metadata['kramdown_options']).to_latex fixed_latex = LatexProcessor.new(latex,@inpath,File.basename(infilepath)).fix outfilepath = File.join(@outpath, File.basename(infilepath).gsub(/(.*).txt/, '\1.tex')) File.open(outfilepath, 'w'){ |f| f.write fixed_latex } end end |