Class: HTML2TeX

Inherits:
Object
  • Object
show all
Includes:
TeX
Defined in:
lib/html2tex.rb,
lib/html2tex/cli.rb,
lib/html2tex/tex.rb,
lib/html2tex/version.rb,
lib/html2tex/null_processor.rb,
lib/html2tex/basic_processor.rb,
lib/html2tex/heading_processor.rb,
lib/html2tex/preamble_processor.rb

Defined Under Namespace

Modules: TeX Classes: BasicProcessor, CLI, HeadingProcessor, NullProcessor, PreambleProcessor

Constant Summary collapse

DEFAULT_OPTIONS =
{
  :document => true,
  :class    => "book"
}
VERSION =
"0.1.8"

Instance Method Summary collapse

Methods included from TeX

#tex, #tex_escape

Constructor Details

#initialize(html, options = {}) ⇒ HTML2TeX

Returns a new instance of HTML2TeX.



17
18
19
20
# File 'lib/html2tex.rb', line 17

def initialize(html, options={})
  @html    = html
  @options = DEFAULT_OPTIONS.merge(options)
end

Instance Method Details

#to_tex(buffer = "") ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/html2tex.rb', line 22

def to_tex(buffer="")
  scanner = StringScanner.new(@html)

  if @options[:document]
    PreambleProcessor.new(scanner, @options).to_tex(buffer)
  end

  BasicProcessor.new(scanner, @options).to_tex(buffer)

  if @options[:document]
    buffer << "\n\n" << tex(:end, "document")
  end

  buffer << "\n"
  buffer
end