Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

Tidy2: A new HTML-Tidy plugin

2012-09-08
2014-03-26
  • Hi,
    As the old tidy plugin has had some issues reported, and difficulties getting a working tidy.dll (not to mention it's embedded in TextFX, which is no longer supported), I've thrown together a new HTML-Tidy plugin, which has everything in a single DLL. 

    It uses the new tidy-html5 fork from w3c, so hopefully it should be better than the existing solution anyway. If the config doesn't exist it will create a little default.  It detects UTF8/ANSI encodings, and sets the appropriate options.

    You can have 3 different configs, which should be enough for most people.

    Just drop the DLL in the Notepad++\plugins directory.

    https://github.com/downloads/davegb3/NppTidy2/Tidy2_0.1.zip

    Please let me know if you experience any issues.  The code needs some tidy up, I've just thrown it together this morning, so expect a 0.2 at some point (famous last words…)

    Cheers,
    Dave.

    PS. This is version 0.1 of the plugin called "Tidy2".  It's called Tidy2, to distinguish it from the embedded version in TextFX.

     
    • Thanks a lot for this Dave, It's making my life much easier!

      Now would any one know if it's possible for tidy2 to not delete plain text?
      I have this huge log to analyze which mostly contains XML but it also has some plain text with important procedural description (see little example attached). I've set the following settings for a Tidy2 config file and I'm getting beautifully formatted XML (thanks again btw).

      [Tidy Config]
      input-xml:yes
      bare:no
      clean:no
      fix-bad-comments:no
      fix-backslash:no
      indent:yes
      indent-attributes:no
      indent-spaces:4
      char-encoding:raw
      replace-color:no
      wrap:0
      wrap-asp:no
      wrap-jste:no
      wrap-php:no

      But sadly besides doing this excellent job, Tidy2 also deletes every plain text found in the file. Is there a way I can set it to leave plain text be?

      I'm using notepad++ v6.3.1 and Tidy2 V0.2.0.0

      Thanks a lot!!!

       
      Last edit: SERGIO A TORRES CRUZ 2013-04-04
      Attachments
      • I'm not sure. As this isn't valid XML as a complete document, I don't know
        how html5-tidy copes with it. You could try setting input-xml to no, but
        that's just a guess. You could also try asking on the html5-tidy project,
        they'll know better.

        As a sneaky alternative, you could wrap the whole file with a <document>
        element, then it is valid XML (maybe the text is not properly encoded
        though, I've only had a quick look). You could probably script something in
        python script to add the tags, call tidy, then strip the tags off.

        Dave

         
  • Dilip
    Dilip
    2012-09-22

    I used this but I am not able to cleanup large HTML files (the code stretches to 49 mb). I like the HTML5 part conversion but output code gets truncated!

     
  • Dilip
    Dilip
    2012-09-22

    Also how do I check for errors? Where is the error output file?

     
  • I'll take a look at big files, it does need to copy the text once, but I can't see 49mb being an issue.

    Errors aren't output yet. I'm most of the way to converting the code to use a new plugin template. When that's done I'll add an error output. I'm also making it so you can have as many named configurations as you want.

    Cheers,
    Dave

     

  • Anonymous
    2012-11-08

    Thanks loads for this.  Been trying to get the old version to work for a while.

     
  • Dave
    Dave
    2013-06-24

    Hey Dave,

    I really LOVE the Tidy2 plugin for the Notepad++. As a beginner to coding it has really helped me with a nice and easy way to see a great way to organize things.

    One thing that I had a question on is the "indent-spaces:" parameter. Is there any way to change it from spaces to a tab? I prefer using a 4 space tab so that when there are a lot of indents from nested tags I hit backspace and it backs up quick and easy with a few key strokes vs. using spaces where it can take up to 16 taps on backspace to back up 4 indent levels. Any input would be great!!

    Thanks,
    Dave

     
  • Danny
    Danny
    2014-03-26

    Is there a way to configure this plugin so that it does not add the self-advertising meta tag to the file? I really just want the HTML tidied. I don't want extra data added to it.

     
  • Danny
    Danny
    2014-03-26

    I found the configuration options and set tidy-mark to no. Thanks for this great utility and for making the configuration so flexible.