Welcome! » Log In » Create A New Profile

Stand alone version how to enable auto paragraph

Posted by echpoh 
Stand alone version how to enable auto paragraph
April 27, 2011 01:55PM

From -> http://htmlpurifier.org/live/INSTALL

it says...................

Standalone version ------------------

HTML Purifier has a standalone distribution; you can also generate a standalone file from the full version by running the script maintenance/generate-standalone.php . The standalone version has the benefit of having most of its code in one file, so parsing is much faster and the library is easier to manage.

If HTMLPurifier.standalone.php exists in the library directory, you can use it like this:

require '/path/to/HTMLPurifier.standalone.php';

This is equivalent to including HTMLPurifier.includes.php, except that the contents of standalone/ will be added to your path. To override this behavior, specify a new HTMLPURIFIER_PREFIX where standalone files can be found (usually, this will be one directory up, the "true" library directory in full distributions). Don't forget to set your path too!

The autoloader can be added to the end to ensure the classes are loaded when necessary; otherwise you can manually include them. To use the autoloader, use this:

require 'HTMLPurifier.autoload.php';

...................."The autoloader can be added to the end ..............." but END OF WHAT MAY I ASK, END OF WHAT???!!! im so frustrated reading your instructions which has alot of gaps and assumes alot from the reader

and u tell ppl to add this and that lines to do this and that BUT CAN U PLEASE SPECIFY WHERE THE HECK TO PUT IT

i tried

$config = HTMLPurifier_Config::createDefault(); $config->set('AutoFormat.AutoParagraph', true);

and it has no effect whatsoever!!!!!!

Re: Stand alone version how to enable auto paragraph
April 27, 2011 05:09PM

I don't understand your question. Are you just trying to configure HTML Purifier? That has nothing to do with autoloaders. Have you passed the config option to purifier? Can you post full code?

Re: Stand alone version how to enable auto paragraph
April 27, 2011 10:56PM

#1 I wanted to know how to load autoloader since the stand alone deployment package does not come with an autoloader file.php

because i thought this was needed before i could enable those directives...

it turns out i dont need it.. but still how to load an auto loader file should have been made clear for the benefit of other users if we were to follow straight from the instructions which was to

require 'HTMLPurifier.autoload.php';

then we would definitely get an error since there is no such file. This is Bad documentation, if uve come such a long way in making a good html purifier but then just deliver sloppy user guide, that is just quite irresponsible.

#2 after digging tru the source-code i only realized that i should pass the config variable to purifier, yet again this was made very vague on the installation guide. it is very sickening to have to go tru a badly put together user guide, and it makes u feel like u want to punch whoever that wrote it.

after a long time only i figured out how it was done, no thanks to the guide, it was tru my own digging

Re: Stand alone version how to enable auto paragraph
April 28, 2011 04:48AM

From the manual:

    HTML Purifier has a standalone distribution; you can also generate
    a standalone file from the full version by running the script
    maintenance/generate-standalone.php . The standalone version has the
    benefit of having most of its code in one file, so parsing is much
    faster and the library is easier to manage.

    If HTMLPurifier.standalone.php exists in the library directory, you
    can use it like this:

        require '/path/to/HTMLPurifier.standalone.php';

Perhaps we should have separate INSTALL files for the standalone/normal distributions?

Failing to pass the configuration object to HTML Purifier itself is a mistake I occasionally see users making, which I always find a bit puzzling. I've reworded the end section of the INSTALL file so I don't ever give an example of creating an HTMLPurifier object without passing a config object in.

UniversallyConfused
Re: Stand alone version how to enable auto paragraph
July 13, 2011 11:57PM

I recently ran into the same problem. I think it is unclear on the INSTALL page under the sixth section:

quoted:

"6. Using the code

The interface is mind-numbingly simple:

$purifier = new HTMLPurifier(); $clean_html = $purifier->purify( $dirty_html );

...or, if you're using the configuration object:

$purifier = new HTMLPurifier($config); $clean_html = $purifier->purify( $dirty_html );"

I didn't think that I needed a configuration object because under the fourth section:

quoted:

"4. Configuration

HTML Purifier is designed to run out-of-the-box, but occasionally HTML Purifier needs to be told what to do. If you answer no to any of these questions, read on; otherwise, you can skip to the next section (or, if you're into configuring things just for the heck of it, skip to 4.3).

* Am I using UTF-8? * Am I using XHTML 1.0 Transitional?"

I am using XHTML1.0 Transitional with a UTF-8 charset. So onto section 5. In section five, it mentions caching and my directory should have write permissions and so I didn't think I needed to disable caching. Therefore, I figured I didn't need a config object, so I just copied and pasted the first suggested code in section 6 into my php code.

quoted:

"$purifier = new HTMLPurifier(); $clean_html = $purifier->purify( $dirty_html );"

I included the standalone file correctly because an instance of the HTMLpurifier class was being created successfully. However, the dirty html was just passing through the purify method and being returned from the function unchanged. I haven't fixed the problem yet, but I'll try adding a config object.

I really think that this HTMLPurifier is a great tool to use, but the documentation would be much better if there were a full version, and a condensed version that paraphrased the purposes of all the relevant methods with their Pre and Post statements and possibly some sample displayed with sample output. Another thing that would be really good is maybe a 3-5 minute video walking a user through how to set up HTMLPurifier. It wouldn't take to long and a lot of people learn better when someone is talking to them rather than reading documentation.

UniversallyConfused
Re: Stand alone version how to enable auto paragraph
July 14, 2011 12:26AM

Yep, I tried the standalone version and the autoload version using the config object and without the config object. In both cases the HTMLPurifier object is created, but no code gets purified. I'm using a basic to test my output. Nothing is being filtered. Somebody please post back with simple and clear instructions.

UniversallyConfused
Re: Stand alone version how to enable auto paragraph
July 14, 2011 12:28AM

FORGOT THE CDATA STUFF:

I'm using

<script>window.alert("test");</script>

Re: Stand alone version how to enable auto paragraph
July 14, 2011 08:13AM

Please post precisely the PHP you are using to test HTML Purifier.

Sorry, you do not have permission to post/reply in this forum.