WordPress.org

Ready to get started?Download WordPress

Forums

HTML Tidy (18 posts)

  1. jcwinnie
    Member
    Posted 10 years ago #

    Anyone working on, or know of, a WP plugin for HTML Tidy? There was one recently availabe for MT; I never was able to get it to work properly. It is a nice idea, something that checks your post to ensure that it is compliant.

  2. MathiasBynens
    Member
    Posted 10 years ago #

    Well, there is of course the "WordPress should correct invalidly nested XHTML automatically" option, but I don't see the point wanting such a plugin. Why not just validate your blog after posting a new post, and correct if there are errors?

  3. WeBloGrrl
    Member
    Posted 10 years ago #

    <i>Well, there is of course the "WordPress should correct invalidly nested XHTML automatically" option</i>
    This may sound silly, but: Where is this option available?

  4. ringmaster
    Member
    Posted 10 years ago #

    It's on the Options|Writing page under Formatting. But it doesn't always work that well.
    Can Tidy run on a whole WordPress page? I would think not, but that's an interesting question. A whole-page filter. Does WP output-buffer the whole page? Sorry... I'm develo-rambling.

  5. WeBloGrrl
    Member
    Posted 10 years ago #

    Thanks, ringmaster. Found it. And, it's actually enabled (checked). But, when I run the XHTML validator, it comes up with lots of errors. Also, someone who runs FireFox wrote to me and said that my blog is just 'broken' in his browser. It looks fine on IE and Netscape, though, so... I'm not sure how to fix this as I don't have FireFox and I'm not that familiar with it either.

  6. ringmaster
    Member
    Posted 10 years ago #

    Well... here we go:
    The img tag for your site heading needs an alt="" attribute to validate.
    The text just under your heading incorrectly nests an i and a b tag (bad, like this: <i><b>text</i></b>).
    Apart from that, it seems that the method you're using for putting your painting into WordPress, it's generating bad XHTML. Some of the errors are weird, but that looks like what's going on. It looks like you're using PictPress. Something should be done about that.
    In spite of all that, the site looks just fine to me under FireFox 0.8.

  7. WeBloGrrl
    Member
    Posted 10 years ago #

    Thanks, ringmaster. Yes, I've been learning a few things lately...
    First, I thought I do have an alt attribute. So, not sure how to fix this.
    Yes, I realise there's something wrong with that coding text in the heading. I tried to fix it, but I know I need to fix it some more. :p
    I'm using PictPress, and yes, it was messing some stuff up. But, I fixed some parts of the code as well. But, it looks like there are lots more to be done. :p

  8. WeBloGrrl
    Member
    Posted 10 years ago #

    Oh, and yes, I finally gave in and downloaded FireFox (great move, I think - I'm liking it). And, thank goodness it doesn't look as bad as I thought. Thanks again!

  9. jcwinnie
    Member
    Posted 10 years ago #

    The problem is laziness. If I have WP set to run HTML Tidy before I post, I may correct errors that otherwise I will overlook and only discover if I validate the site or feed or if someone notices something is awry.

  10. SkierX
    Member
    Posted 10 years ago #

    PHP has a HTML Tidy module. I have been playing around with it since there has been some frustration as of late because of commenting throwing off validation. A quick glance at the QuickRef of Tidy will show that there is a wealth of features. Basically tidy will take invalid tag soup and give you some valid XHTML (if you ask nicely of course). Implementing this in PHP Is not rocket science. The biggest problem is that this module is not compiled in by default.
    The only validation issue that remains is that Tidy will not strip things according to the doctype. This kind of stuff would be fairly trivial to implement in XSLT.
    The big question is whether there is interest in this type of thing? I don't know how WordPress handles the tag stripping and validation currently, as I do not have it installed myself. Let me know if there would be interest in this type of a plug-in.

  11. Anonymous
    Unregistered
    Posted 9 years ago #

    I'd like to see Tidy working with WordPress, my current weblog software (home-grown) uses it. As soon as I create a new post it runs through Tidy to check for errors... It's a great feature, IMHO...

  12. Mark (podz)
    Support Maven
    Posted 9 years ago #

    This might be a daft question:
    When I coded my own blog (html / css) I did, at one point use Tidy or something similar. Then I found that it was bulking my code up by a significant % so I dumped it. Since then, I hardly use tabs.
    I know it's important / accepted that code is properly indented, but for an average user, why ?

  13. m0n5t3r
    Member
    Posted 9 years ago #

    I have written a html tidy plugin for wordpress 1.5, it works for me, cleaning my typos and the commentors' ones ;)
    I actually really need that, since I serve pages as application/xhtml+xml, and a typo could stop the whole page from displaying in Firefox, which holds more than 2/3 of my page hits.

  14. yucca
    Member
    Posted 9 years ago #

    That's really a great plugin, but doesn't seem to work for me. Do I need php5? I've got apache2, php4, php_tidy.dll seems to be installed. I get these 2 errors:

    [24-May-2005 12:45:51] PHP Warning: Cannot modify header information - headers already sent by (output started at C:\apache2triad\htdocs\wordpress\wp-content\plugins\wptidy.php:59) in C:\apache2triad\htdocs\wordpress\wp-admin\admin.php on line 13

    [24-May-2005 12:45:51] PHP Fatal error: Cannot instantiate non-existent class: tidy in C:\apache2triad\htdocs\wordpress\wp-content\plugins\wptidy.php on line 43

    The comments on your site don't seem to work either.

  15. m0n5t3r
    Member
    Posted 9 years ago #

    the comments work, I have just tested the system... as for the plugin, check for spaces/newlines at the end of the php file, there should be none (otherwise, the headers can't be sent).
    If the php file is ok, then you may need to check if tidy really works (i.e., is the extension really loaded?), try this php code (taken from the php documentation, save it as a php file):
    <?php
    $html = '<HTML><HEAD></HEAD><BODY>Hello World</BODY></HTML>';
    $config = array('indent'=> TRUE, 'output-xhtml' => TRUE, 'wrap' => 80);
    tidy_set_encoding('UTF8');
    foreach ($config as $key => $value) {
    tidy_setopt($key,$value);
    }
    tidy_parse_string($html);
    tidy_clean_repair();
    echo tidy_get_output();
    ?>

    Resultant HTML should be similar to:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title></title>
    </head>
    <body>
    Hello World
    </body>
    </html>

    if this works, then let me know, it would mean that there is something wrong with my code (the class version may not work with php 4, but I doubt that) and I'll change it.

  16. yucca
    Member
    Posted 9 years ago #

    The problem with the headers was indeed a single space behind the end tag of the php-section. So that error disappeared, many thanks for that.

    Php still complains about the class (with the plugin and the code posted by you here) (I tried my local sever and two other hosts). So it's likely that tidy isn't properly installed at none of them, as you stated above.

    For my locahost (apache, WinXP) I will have to sort it out myself. For the other hosts I 'll try to have my hosting'company' installing Tidy. But wich version of tidy do they need to install? Is it available as a pear-package? Where can I find it?

    the error:

    [Fri May 27 13:52:18 2005] [error] PHP Fatal error: Call to undefined function: tidy_set_encoding() in /scoutnet.be/users/scoutswindeke/public_html/test.php on line 4

    I tried twice to post a comment on your website (http://exotic4.nipne.ro/~iacobs/work/wordpress-plugins/wptidy) a few days ago. Nothing happened, so I posted my questions here. Now I tried again (sorry for the useless comment) and I had no problems commenting. Stange things happens.

    So it seems there was nothing with your code, thanks a lot for this lovely plugin and your help.

    pieter

  17. m0n5t3r
    Member
    Posted 9 years ago #

    you're welcome :D
    yeah, tidy is available as a pear (pecl actually) package, so if the host allows you to use dl(), which I doubt, you can load the library dynamically. All you need to do is either find the .so file compiled for the OS on the host, or grab it and compile it there (you'll need shell access and some development tools, including the php development libraries).
    If you have shell access and the needed tools, installing is as simple as
    pear -v install -R some_root_dir tidy
    -R is needed because you don't have root access ;)
    But you will need access to the dl() function, if the host won't install that extension for you.
    More info is available at http://www.php.net/manual/en/ref.tidy.php

  18. anonymous-surfing-tips
    Member
    Posted 8 years ago #

    I'm also having the same problem with wptidy that yucca had - i'm on a hosted linux box with PHP 4.3.11 (http://carbon.nocdirect.com/phpinfo/)

    Activate the plugin, attempt to edit a post and you get an error:

    Fatal error: Cannot instantiate non-existent class: tidy in wptidy.php on line 46

    I looked at the wptidy.php - no trailing spaces / linefeeds. I also tested the installation with the php snippet described above - it works.

    Any other suggestions?
    (n.b. - sorry for the cross post / multiple posts on your blog - I also had problems posting a complete comment on your blog.)

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.