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.5"

Instance Method Summary collapse

Methods included from TeX

#tex, #tex_escape

Constructor Details

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

Returns a new instance of HTML2TeX.



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

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

Instance Method Details

#to_tex(buffer = "") ⇒ Object



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

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