Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Jul 2002
    Location
    The Netherlands
    Posts
    252
    Thanks
    0
    Thanked 0 Times in 0 Posts

    php-script with html-tidy functionality

    Hi,

    Some time ago I created a very light-weight cms system for a client of mine, so he can easily edit the content of his website. While editing the content he can add html tags as well.

    To prevent the client from adding incorrect or 'ugly' html I'm looking for a tool that can check the input and can correct the html and/ or can convert it to valid xhtml.

    I found an extension for php that will do exactly what I want (http://pear.php.net/package-info.php?package=tidy). The only problem with this extension is that it is only supported bij php 5.0, which I and my client don't have.

    Now I'm looking for a php-script that will have the same, or similar, functionality, but is also supported by php 4. I doesn't really matter if it isn't as extensive as the package above, as long as it can convert the html to valid (x)html.

    Does anyone know of such a project? Or does anyone know whether it's very hard to create something like this yourself?

    Thanks in advance!


    Michiel

  • #2
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,055
    Thanks
    10
    Thanked 95 Times in 93 Posts
    Hi , I am doing something similar at the moment , but its not as straightforward as I was hoping

    I am using the current XML parser functions to create an xml parser then look at each tag as it is parsed and try and fix known issues , some are easy some not , eg some require ridiculous regex and some just simple str_replace()ments.

    The main problem I am having (aside from the regex) is that if there is say a mismatched tag in the html stream then the parser breaks , ok it gives an error which you can detect , then try and fix within the script and re-run the parser but endless loops seem to crop up quite easily and quickly

    If I get any further then I will post here , until then have you checked out hotscripts or phpclasses.org ?
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #3
    Regular Coder
    Join Date
    Jul 2002
    Location
    The Netherlands
    Posts
    252
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi Firepages,

    thanks for your reply. What I hear from you it isn't as easy as I thought it would be I'd like it if you could keep me posted on your progress!

    I did in fact check out hotscript and phpclasses.org, but unfortunatelly I didn't get any results. As soon as I find something usefull I'll post it here as well!

    Cheers, Michiel

  • #4
    Senior Coder
    Join Date
    Jun 2002
    Location
    frankfurt, german banana republic
    Posts
    1,848
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Maybe your host is so flexible to have tidy installed on the server, so you could call it with system(), shell_exec() or popen()? There's an example how to do this in the usernotes on http://us2.php.net/manual/en/ref.outcontrol.php
    De gustibus non est disputandum.

  • #5
    Regular Coder
    Join Date
    Jul 2002
    Location
    The Netherlands
    Posts
    252
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Mordred,

    that might be a good solution, though it isn't as flexible as I would like it to be. The thing is that I want to add this tool to other cms-systems, for other clients as well, who might not have a host that wants to install tidy on the server.

    I will give it a shot though in this particular situation, but I'll keep looking for a php 4 solution!

    Thanks Michiel

    PS: did you notice that you've posted exactly 1100 posts more than I did (1189 vs 89), and you registered only 1 month earlier than I did? I think we can state that you are only a teeny-tiny bit more active than I am


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •