[TxMt] Re: Configuring HTML Tidy

Steve King sking at arbor.net
Mon Sep 14 19:59:06 UTC 2009


3zzy wrote:
> Thanks Steve, but I'm not sure what to change in that code snippet, following
> is the full command source:
>   

Don't change anything in the command.  Run the Tidy command as normal,
then follow it by doing a Find & Replace operation. So, say you start
with the following HTML:

    <h1>
    Hello, world!
    </h1><ul><li>
    first
    </li>
    <li>second</li><li>third
    </li>
    </ul>

Now, run the Tidy command from the HTML bundle. Your output may be
slightly different, but when I run it I get:

    <h1>
        Hello, world!
    </h1>
    <ul>
        <li>first
        </li>
        <li>second
        </li>
        <li>third
        </li>
    </ul>

Now, to fix up the ugly list formatting I do ⌘F to open the Find dialog.

    Find: <li>[ \n]*(.*?)[ \n]*</li>
    Replace: <li>$1</li>
    Regular expression: checked

Hit "Replace All", and the list elements are lined up like they should be.

    <h1>
        Hello, world!
    </h1>
    <ul>
        <li>first</li>
        <li>second</li>
        <li>third</li>
    </ul>

The Find expression above is a little more complex than the one I posted
earlier, but it should handle some wackier formats.

-- 
Steve King
Sr. Software Engineer
Arbor Networks
+1 734 821 1461
www.arbornetworks.com <http://www.arbornetworks.com/>




More information about the textmate mailing list