Module: Tidylib
- Extended by:
- DL::Importable
- Defined in:
- lib/tidy/tidylib.rb
Overview
Ruby wrapper for HTML Tidy Library Project (tidy.sf.net)
Class Method Summary collapse
-
.buf_free(buf) ⇒ Object
tidyBufFree.
-
.clean_and_repair(doc) ⇒ Object
tidyCleanAndRepair.
-
.create ⇒ Object
tidyCreate.
-
.load ⇒ Object
Load library (requires that $TIDYLIB be defined).
-
.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 replacing underscores with dashes.
Class Method Details
.buf_free(buf) ⇒ Object
tidyBufFree
35 36 37 |
# File 'lib/tidy/tidylib.rb', line 35 def buf_free(buf) tidyBufFree(buf) end |
.clean_and_repair(doc) ⇒ Object
tidyCleanAndRepair
47 48 49 |
# File 'lib/tidy/tidylib.rb', line 47 def clean_and_repair(doc) tidyCleanAndRepair(doc) end |
.create ⇒ Object
tidyCreate
41 42 43 |
# File 'lib/tidy/tidylib.rb', line 41 def create() tidyCreate() end |
.load ⇒ Object
Load library (requires that $TIDYLIB be defined)
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/tidy/tidylib.rb', line 11 def load() raise LoadError, 'Tidy requires that $TIDYLIB be defined' if $TIDYLIB.nil? begin dlload($TIDYLIB) rescue raise LoadError, sprintf('Unable to load %s', $TIDYLIB) 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 |
.load_config(doc, file) ⇒ Object
tidyLoadConfig
53 54 55 |
# File 'lib/tidy/tidylib.rb', line 53 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)
65 66 67 68 |
# File 'lib/tidy/tidylib.rb', line 65 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
59 60 61 |
# File 'lib/tidy/tidylib.rb', line 59 def opt_parse_value(doc, name, value) tidyOptParseValue(doc, translate_name(name), value.to_s) end |
.parse_string(doc, str) ⇒ Object
tidyParseString
72 73 74 |
# File 'lib/tidy/tidylib.rb', line 72 def parse_string(doc, str) tidyParseString(doc, str.to_s) end |
.release(doc) ⇒ Object
tidyRelease
78 79 80 |
# File 'lib/tidy/tidylib.rb', line 78 def release(doc) tidyRelease(doc) end |
.release_date ⇒ Object
tidyReleaseDate
84 85 86 |
# File 'lib/tidy/tidylib.rb', line 84 def release_date() tidyReleaseDate() end |
.run_diagnostics(doc) ⇒ Object
tidyRunDiagnostics
90 91 92 |
# File 'lib/tidy/tidylib.rb', line 90 def run_diagnostics(doc) tidyRunDiagnostics(doc) end |
.save_buffer(doc, buf) ⇒ Object
tidySaveBuffer
96 97 98 |
# File 'lib/tidy/tidylib.rb', line 96 def save_buffer(doc, buf) tidySaveBuffer(doc, buf) end |
.set_error_buffer(doc, buf) ⇒ Object
tidySetErrorBuffer
102 103 104 |
# File 'lib/tidy/tidylib.rb', line 102 def set_error_buffer(doc, buf) tidySetErrorBuffer(doc, buf) end |
.translate_name(name) ⇒ Object
Convert to string replacing underscores with dashes. :output_xml becomes ‘output-xml’
109 110 111 |
# File 'lib/tidy/tidylib.rb', line 109 def translate_name(name) name.to_s.sub('_', '-') end |