Class: TidyMachine

Inherits:
Object
  • Object
show all
Defined in:
lib/tidy-machine.rb

Constant Summary collapse

DEFAULT_OPTIONS =
{ :"tidy_mark" => false, :doctype => "omit" }

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text) ⇒ TidyMachine

Returns a new instance of TidyMachine.



6
7
8
9
10
11
# File 'lib/tidy-machine.rb', line 6

def initialize(text)
  @text = text    
  # TODO: check doctype html5
  #
  # "<!DOCTYPE html>\n<html>\n<head>\n<title></title>\n</head>\n<body>\na string\n</body>\n</html>\n"
end

Class Method Details

.tidy(text) ⇒ Object



17
18
19
# File 'lib/tidy-machine.rb', line 17

def self.tidy(text)
  new(text).tidy
end

Instance Method Details

#tidyObject



13
14
15
# File 'lib/tidy-machine.rb', line 13

def tidy
  TidyFFI::Tidy.with_options(:"tidy_mark" => false, indent: "yes", doctype: "omit").new(@text).clean
end