Test and find a flaw in this.

Soldato
Joined
12 Jun 2005
Posts
5,361
Hi there,

I am creating the add bit of my CMS and I am parsing the text that is put in. The function i have created is supposed to do the following:

  • Put it in valid xHTML
  • Put it in paragraphs where appropriate.
  • Put linebreaks where appropriate.
  • Strip any unnecessary line breaks and paragraphs.
  • Use BB Code (this won't product valid HTML yet as i haven't done that bit yet, but it should still display ok)

So could you test it and see if it's doing what its supposed to:

http://customised.live-host.org/test.php

Thanks.
 
Hi peeps....

Sorry for not explaining very well.

Basically, I want the articles to be formatted properly.

So instead of using a conventional nl2br() function (which would just have <br />'s all over the place), I have created my own which formats the text in paragraphs (how it should be done).

Just wanted to check it works properly.

Thanks for looking.
 
Seems fine so far.

I notice slashes are being escaped, which wouldn't be desirable behaviour - may be worth doing a quick check while parsing if you're not already doing this in the proper app.
Code:
this is a slash \
=
Code:
this is a slash \\

Additionally, i18n strings such as:
Code:
東京事変
are converted to their character entity equivalent, but appear to be double-escaped, incorrectly producing:
Code:
<p>&amp;#26481;&amp;#20140;&amp;#20107;&amp;#22793;</p>
 
I like the fact it splits by <p> rather than using <br />, but the stripping of linebreaks means I can't double space, which I think if you've got a lot of text split by titled paragraphs would be needed.
 
Augmented said:

Thanks.

I am not sure exactly why its adding slashes because i havent run the addslashes or mysql escape functions anyways, but when i run the stripslashes() function it removes that. Thanks.

I can't seem to reproduce the second point you made.


EDIT:

I think i have fixed this.
 
Last edited:
paulsheffII said:
I like the fact it splits by <p> rather than using <br />, but the stripping of linebreaks means I can't double space, which I think if you've got a lot of text split by titled paragraphs would be needed.

Do you mean double space between paragraphs...yeah?

I could just remove the part where it removes:
Code:
<p><br />
...that will let you double space.
 
Have updated this now (see link).

It should use BB code: quote, url, bold, italic, underline and format them properly with valid xHTML.

Also fixed any issues stated in this thread. Thanks to those that pointed them out (+solutions).

It also now formats the HTML so when you view the source it's layered.

If anyone else notices anything wrong/needs updating/.... just say....

Thanks for looking.
 
Back
Top Bottom