How to call HTML Tidy?


(Nic Hubbard) #1

Could someone tell me how I can call HTML Tidy on a string?


(Ashish Karelia) #2

[quote]
Could someone tell me how I can call HTML Tidy on a string?

[/quote]



If you are doing it within Matrix, process() is the function that takes care of it. All you pass in it is string.

Class : [system_root]/fudge/wysiwyg/plugins/html_tidy/html_tidy.inc


(Nic Hubbard) #3

[quote]
If you are doing it within Matrix, process() is the function that takes care of it. All you pass in it is string.

Class : [system_root]/fudge/wysiwyg/plugins/html_tidy/html_tidy.inc

[/quote]



Well that is easy enough. And process() returns a string?


(Benjamin Pearson) #4

[quote]
Well that is easy enough. And process() returns a string?

[/quote]



The doc comment is slightly misleading (this could be because of the many changes to it). But you must pass a variable into the process() function, the variable will be changed (it is assigned by reference). The function itself will return nothing, but errors and status can be checked by the object variables (var_dump() the object to see what variables are available).



HTH


(Nic Hubbard) #5

[quote]
The doc comment is slightly misleading (this could be because of the many changes to it). But you must pass a variable into the process() function, the variable will be changed (it is assigned by reference). The function itself will return nothing, but errors and status can be checked by the object variables (var_dump() the object to see what variables are available).



HTH

[/quote]



Got it. What is the performance on tidy? Is it pretty quick to process?



I am thinking about writing a keyword modifier that would use tidy.


(Benjamin Pearson) #6

[quote]
Got it. What is the performance on tidy? Is it pretty quick to process?



I am thinking about writing a keyword modifier that would use tidy.

[/quote]



I think it is, you can check by putting a speed_check('', FALSE) either side of the actual call and look at the times in the error log.


(Nic Hubbard) #7

[quote]
I think it is, you can check by putting a speed_check('', FALSE) either side of the actual call and look at the times in the error log.

[/quote]



Thanks Ben.



Can I not include the html_tidy.inc file directly? When trying to do the following it can never find the file:


    include SQ_FUDGE_PATH.'/wysiwyg/plugins/html_tidy/html_tidy.inc';


Error:

    Notice: Undefined index: SQ_SYSTEM in /home/websites/mysource_matrix/core/include/general.inc on line 1141
Notice: Trying to get property of non-object in /home/websites/mysource_matrix/core/include/general.inc on line 1141

PHP Warning
File:	[SYSTEM_ROOT]/fudge/wysiwyg/plugins/html_tidy/html_tidy.inc	Line:	19
Message:	include_once() [function.include]: Failed opening 'wysiwyg_plugin.inc' for inclusion (include_path='.:[SYSTEM_ROOT]/php_includes:/usr/share/php:/usr/share/pear')
Backtrace:	Show


Fatal error: Class 'Wysiwyg_Plugin' not found in /home/websites/mysource_matrix/fudge/wysiwyg/plugins/html_tidy/html_tidy.inc on line 37</pre><br />

What else do I need to be including?

(Nic Hubbard) #8

I figured it out, I needed:

    $ROOT_PATH = SQ_FUDGE_PATH.'/wysiwyg/';
    include SQ_FUDGE_PATH.'/wysiwyg/plugins/html_tidy/html_tidy.inc';

(Rhulse) #9

[quote]
Got it. What is the performance on tidy? Is it pretty quick to process?



I am thinking about writing a keyword modifier that would use tidy.

[/quote]

Tidy - if you use the binary package - is fast because it's written in C.



If you are writing your own wrapper you have the option to add other features.



We overlaid a tag stripper and semantic parser to allow reformatting based on known input formats.



The code is on github as a couple of gists if you want to sneak a look



Richard


(Nic Hubbard) #10

[quote]
Tidy - if you use the binary package - is fast because it's written in C.



If you are writing your own wrapper you have the option to add other features.



We overlaid a tag stripper and semantic parser to allow reformatting based on known input formats.



The code is on github as a couple of gists if you want to sneak a look



Richard

[/quote]



Thanks Richard, I will give it a look this weekend.