Module: Jekyll::Latex::Pdf::Utilities

Included in:
Figure::FigRefTag, Figure::FigureTag, Latex, Scholar::Bibliography, Scholar::Cite, Tikz::TikzHtml, Tikz::TikzPdf
Defined in:
lib/jekyll/latex/pdf/utilities.rb

Overview

Add methods which can be useful anywhere in the package.

Instance Method Summary collapse

Instance Method Details

#nomarkdown(string_to_wrap) ⇒ Object

Surround a string with nomarkdown tags to tell kramdown that this is plain latex.



10
11
12
# File 'lib/jekyll/latex/pdf/utilities.rb', line 10

def nomarkdown(string_to_wrap)
  "{::nomarkdown type=\"latex\"}" + string_to_wrap + "{:/}"
end

#nomarkdown_p(string_to_wrap) ⇒ Object



14
15
16
# File 'lib/jekyll/latex/pdf/utilities.rb', line 14

def nomarkdown_p(string_to_wrap)
  "\n{::nomarkdown type=\"latex\"}\n" + string_to_wrap + "\n{:/}\n"
end

#run_cmds(cmds, tempdir) ⇒ Object

Run some commands und stop on errors.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/jekyll/latex/pdf/utilities.rb', line 19

def run_cmds(cmds, tempdir)
  status = 0
  out = "\n"
  cmds.each do |cmd|
    Open3.popen2(*cmd, chdir: tempdir) do |_i, oe, t|
      oe.each {|l| out += l + "\n" }

      status = t.value
    end
    unless 0 == status
      Jekyll.logger.warn "jekyll-latex-pdf", "Error running #{cmd.join ' '}"
      Jekyll.logger.warn "Return status: #{status}"
      Jekyll.logger.warn out
    end
  end
  [out, status]
end

#set_context_to(context) ⇒ Object

stolen from jekyll-scholar



38
39
40
41
42
# File 'lib/jekyll/latex/pdf/utilities.rb', line 38

def set_context_to(context)
  @context, @site, = context, context.registers[:site]
  config.merge!(site.config['scholar'] || {})
  self
end