1

Topic: htmLawed -- allowing PHP fields

How would I prevent cleaning of HTML Fields I'm embedding into an internal database so I can create dynamic output for my users.

EXAMPLE - my HTML contains the following (NOTE OVERLY SIMPLIFIED);

<h1>$FieldOutput</h1>

The result of the cleaning
<h1></h1>

(I need the field!)

I'm going to be compressing using 'tidy'=>'-1' but the users need to manipulate the HTML in a readable fashion.

2

Re: htmLawed -- allowing PHP fields

Can you clarify if it is <h1>$FieldOutput</h1> that gets filtered into <h1></h1>, or is it <h1>XXX</h1> with XXX being the dynamic value of $FieldOutput? There is no reason for the former to occur, at least as per the htmLawed test page. Also, are you sure that htmLawed is not improperly set.... may be it is filtering out XXX for this reason.

3

Re: htmLawed -- allowing PHP fields

$FieldName is cleaned out.  Escaping the $, and the field comes out verbatim.

The Word FieldName is left alone probably... put a Dollar next to it, and BAM!

4

Re: htmLawed -- allowing PHP fields

So it is an issue elsewhere. Can you check if it is due to PHP magic quotes? See this post.

5

Re: htmLawed -- allowing PHP fields

OK ok ok.  I removed quite a bit of options, and BAM - it came out right.  The $ parms in my file were being turned into fields appropriately - which is why they weren't there.

NOW one last problem!
I'm using the following settings;
$out = htmLawed($tidy, array('tidy'=>1, 'safe'=>1, 'style_pass'=>1, 'css_expression'=>1, 'balance'=>0, 'keep_bad'=>0, 'no_deprecated_attr'=>0));

AND it's turning the following line of code;
BEFORE;
<th><u>Birthdate</u> </th>

INTO
AFTER;
<th><span style=
                        "text-decoration: underline;">Birthdate</span></th>

HOW do I make that leave that stuff alone?!?

6

Re: htmLawed -- allowing PHP fields

So - my GOAL is;
Compress the HTML before storing it - ignoring ONLY the $code's so I can put dynamic content edited by the users.
EXPAND (ie PRETTIFY!) when I show the users their handy work - so they can edit it without worry... AND without the system modifying it.

7

Re: htmLawed -- allowing PHP fields

For the 'u' tag issue, add the config. parameter 'make_tag_strict' and set it to 0. By default, htmLawed transforms deprecated tags like 'u'. The rest of your config. settings seem to be fine.

8

Re: htmLawed -- allowing PHP fields

AHAHA!!!!

I did a compare between pretified, unpretified, and minified - and found little changes between all three (after doing minimum HTML Tidy in an HTML editor I have to make sure the playing field was even!)

Is there a way of increasing "Tab's" so it really spaces the code out?

9

Re: htmLawed -- allowing PHP fields

You have to appropriately set the 'tidy' parameter in 'config'. Also, see some examples here.

You can look at the hl_tidy function of htmLawed to see the HTML tags/elements that get indentations, their own blocks, etc.