Module: Tidylib
- Extended by:
- DL::Importable
- Defined in:
- lib/tidy/tidylib.rb
Overview
Ruby wrapper for HTML Tidy Library Project (http://tidy.sf.net).
Class Method Summary collapse
-
.buf_free(buf) ⇒ Object
tidyBufFree.
-
.buf_init(buf) ⇒ Object
tidyBufInit, using default allocator.
-
.clean_and_repair(doc) ⇒ Object
tidyCleanAndRepair.
-
.create ⇒ Object
tidyCreate.
-
.load(path) ⇒ Object
Load the library.
-
.load_config(doc, file) ⇒ Object
tidyLoadConfig.
-
.opt_get_value(doc, name) ⇒ Object
tidyOptGetValue (returns true/false instead of 1/0).
-
.opt_parse_value(doc, name, value) ⇒ Object
tidyOptParseValue.
-
.parse_string(doc, str) ⇒ Object
tidyParseString.
-
.release(doc) ⇒ Object
tidyRelease.
-
.release_date ⇒ Object
tidyReleaseDate.
-
.run_diagnostics(doc) ⇒ Object
tidyRunDiagnostics.
-
.save_buffer(doc, buf) ⇒ Object
tidySaveBuffer.
-
.set_error_buffer(doc, buf) ⇒ Object
tidySetErrorBuffer.
-
.translate_name(name) ⇒ Object
Convert to string, replace underscores with dashes (:output_xml => 'output-xml').
Class Method Details
.buf_free(buf) ⇒ Object
tidyBufFree
42 43 44 |
# File 'lib/tidy/tidylib.rb', line 42 def buf_free(buf) tidyBufFree(buf) end |
.buf_init(buf) ⇒ Object
tidyBufInit, using default allocator
36 37 38 |
# File 'lib/tidy/tidylib.rb', line 36 def buf_init(buf) tidyBufInit(buf) end |
.clean_and_repair(doc) ⇒ Object
tidyCleanAndRepair
54 55 56 |
# File 'lib/tidy/tidylib.rb', line 54 def clean_and_repair(doc) tidyCleanAndRepair(doc) end |
.create ⇒ Object
tidyCreate
48 49 50 |
# File 'lib/tidy/tidylib.rb', line 48 def create tidyCreate end |
.load(path) ⇒ Object
Load the library.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# 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*)" extern "void tidyBufInit(void*)" end |
.load_config(doc, file) ⇒ Object
tidyLoadConfig
60 61 62 |
# File 'lib/tidy/tidylib.rb', line 60 def load_config(doc, file) tidyLoadConfig(doc, file.to_s) end |
.opt_get_value(doc, name) ⇒ Object
tidyOptGetValue (returns true/false instead of 1/0)
72 73 74 75 |
# File 'lib/tidy/tidylib.rb', line 72 def opt_get_value(doc, name) value = tidyOptGetValue(doc, tidyOptGetIdForName(translate_name(name))) Tidy.to_b(value) end |
.opt_parse_value(doc, name, value) ⇒ Object
tidyOptParseValue
66 67 68 |
# File 'lib/tidy/tidylib.rb', line 66 def opt_parse_value(doc, name, value) tidyOptParseValue(doc, translate_name(name), value.to_s) end |
.parse_string(doc, str) ⇒ Object
tidyParseString
79 80 81 |
# File 'lib/tidy/tidylib.rb', line 79 def parse_string(doc, str) tidyParseString(doc, str.to_s) end |
.release(doc) ⇒ Object
tidyRelease
85 86 87 |
# File 'lib/tidy/tidylib.rb', line 85 def release(doc) tidyRelease(doc) end |
.release_date ⇒ Object
tidyReleaseDate
91 92 93 |
# File 'lib/tidy/tidylib.rb', line 91 def release_date tidyReleaseDate end |
.run_diagnostics(doc) ⇒ Object
tidyRunDiagnostics
97 98 99 |
# File 'lib/tidy/tidylib.rb', line 97 def run_diagnostics(doc) tidyRunDiagnostics(doc) end |
.save_buffer(doc, buf) ⇒ Object
tidySaveBuffer
103 104 105 |
# File 'lib/tidy/tidylib.rb', line 103 def save_buffer(doc, buf) tidySaveBuffer(doc, buf) end |
.set_error_buffer(doc, buf) ⇒ Object
tidySetErrorBuffer
109 110 111 |
# File 'lib/tidy/tidylib.rb', line 109 def set_error_buffer(doc, buf) tidySetErrorBuffer(doc, buf) end |
.translate_name(name) ⇒ Object
Convert to string, replace underscores with dashes (:output_xml => 'output-xml').
115 116 117 |
# File 'lib/tidy/tidylib.rb', line 115 def translate_name(name) name.to_s.gsub('_', '-') end |