Module Tidylib
In: lib/tidy/tidylib.rb

Ruby wrapper for HTML Tidy Library Project (tidy.sf.net).

Methods

Public Instance methods

tidyBufFree

[Source]

# File lib/tidy/tidylib.rb, line 34
  def buf_free(buf)
    tidyBufFree(buf)
  end

tidyCleanAndRepair

[Source]

# File lib/tidy/tidylib.rb, line 46
  def clean_and_repair(doc)
    tidyCleanAndRepair(doc)
  end

tidyCreate

[Source]

# File lib/tidy/tidylib.rb, line 40
  def create
    tidyCreate
  end

Load the library.

[Source]

# File lib/tidy/tidylib.rb, line 11
  def load(path)
    begin
      dlload(path)
    rescue
      raise LoadError, "Unable to load #{path}"
    end
    extern "void *tidyCreate()"
    extern "void tidyBufFree(void*)"
    extern "int tidyCleanAndRepair(void*)"
    extern "int tidyLoadConfig(void*, char*)"
    extern "int tidyOptGetIdForName(char*)"
    extern "char tidyOptGetValue(void*, unsigned int)"
    extern "int tidyOptParseValue(void*, char*, char*)"
    extern "int tidyParseString(void*, char*)"
    extern "void tidyRelease(void*)"
    extern "char* tidyReleaseDate()"
    extern "int tidyRunDiagnostics(void*)"
    extern "int tidySaveBuffer(void*, void*)"
    extern "int tidySetErrorBuffer(void*, void*)"
  end

tidyLoadConfig

[Source]

# File lib/tidy/tidylib.rb, line 52
  def load_config(doc, file)
    tidyLoadConfig(doc, file.to_s)
  end

tidyOptGetValue (returns true/false instead of 1/0)

[Source]

# File lib/tidy/tidylib.rb, line 64
  def opt_get_value(doc, name)
    value = tidyOptGetValue(doc, tidyOptGetIdForName(translate_name(name)))
    Tidy.to_b(value)
  end

tidyOptParseValue

[Source]

# File lib/tidy/tidylib.rb, line 58
  def opt_parse_value(doc, name, value)
    tidyOptParseValue(doc, translate_name(name), value.to_s)
  end

tidyParseString

[Source]

# File lib/tidy/tidylib.rb, line 71
  def parse_string(doc, str)
    tidyParseString(doc, str.to_s)
  end

tidyRelease

[Source]

# File lib/tidy/tidylib.rb, line 77
  def release(doc)
    tidyRelease(doc)
  end

tidyReleaseDate

[Source]

# File lib/tidy/tidylib.rb, line 83
  def release_date
    tidyReleaseDate
  end

tidyRunDiagnostics

[Source]

# File lib/tidy/tidylib.rb, line 89
  def run_diagnostics(doc)
    tidyRunDiagnostics(doc)
  end

tidySaveBuffer

[Source]

# File lib/tidy/tidylib.rb, line 95
  def save_buffer(doc, buf)
    tidySaveBuffer(doc, buf)
  end

tidySetErrorBuffer

[Source]

# File lib/tidy/tidylib.rb, line 101
  def set_error_buffer(doc, buf)
    tidySetErrorBuffer(doc, buf)
  end

Convert to string, replace underscores with dashes (:output_xml => ‘output-xml’).

[Source]

# File lib/tidy/tidylib.rb, line 107
  def translate_name(name)
    name.to_s.gsub('_', '-')
  end

[Validate]