"Fixing html files"

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John Resler

    "Fixing html files"

    Hi all,
    First I want to say I am fully aware of the huge scope of the problem
    of parsing and correcting files of any sort. I have been using the jTidy
    libraries (Dave Raggett W3C, I believe) to attempt to clean up the html
    I use and convert it to xhtml if possible. Not to complain about Tidy,
    it is the only application I'm aware of that does what it does... I am
    just curious if there are any other applications/libraries that perform
    the same function, more completely?
  • David Carlisle

    #2
    Re: "Fixing html files"

    John Resler <JohnMResler@sb cglobal.net> writes:
    [color=blue]
    > Hi all,
    > First I want to say I am fully aware of the huge scope of the problem
    > of parsing and correcting files of any sort. I have been using the jTidy
    > libraries (Dave Raggett W3C, I believe) to attempt to clean up the html
    > I use and convert it to xhtml if possible. Not to complain about Tidy,
    > it is the only application I'm aware of that does what it does... I am
    > just curious if there are any other applications/libraries that perform
    > the same function, more completely?[/color]


    Hard to quantify "more completely". tidy does a better job than most.
    Alternative route might be for example John Cowan's tagsoup

    which will allow you to parse most html into an xml processing
    pipeline. It doesn't do any cleaning up really, but once you have it as
    xml you just hit it with enough xslt of your choice and it should all
    come out looking lovely, er, in theory....

    If you are feeling really brave there's my htmlparse xslt2 stylesheet
    but this is decidedly unsupported.


    David

    Comment

    • Nick Kew

      #3
      Re: &quot;Fixing html files&quot;

      John Resler wrote:[color=blue]
      > Hi all,
      > First I want to say I am fully aware of the huge scope of the
      > problem of parsing and correcting files of any sort. I have been using
      > the jTidy libraries (Dave Raggett W3C, I believe) to attempt to clean up[/color]

      Dave Raggett wrote the original tidy, but it's been some years since
      he was in charge of it.
      [color=blue]
      > the html I use and convert it to xhtml if possible. Not to complain
      > about Tidy, it is the only application I'm aware of that does what it
      > does... I am just curious if there are any other applications/libraries
      > that perform the same function, more completely?[/color]

      libxml2 parses html, including tagsoup html, and gives you SAX or DOM
      APIs on it. You can then serialise that to better HTML or XHTML.
      It's a different approach to tidy, and shares the same fundamental
      problem of having to guess blindly when presented with heavy-duty
      gibberish.

      A higher-level application based on libxml2 is AccessValet. Its
      real purpose is (X)HTML accessibility analysis and reporting, but it
      will also clean up (x)html. It takes a more brutal approach than
      tidy: instead of attempting to substitute for crap, it strips it.
      So if you take the default - which is strict output - it'll remove
      everything that's deprecated in HTML4/XHTML1, and
      <p align=center><f ont color=black>som e text here<p>some more text
      becomes
      <p>some text here</p><p>some more text</p>

      I wouldn't recommend it over tidy for that particular purpose, but it's
      an option:-)

      You can also fix markup on the fly when serving it. The state of the
      art there is mod_publisher, at

      and is far better than any of the tidy-in-a-webserver options.

      --
      Nick Kew

      Comment

      Working...