views:

470

answers:

2

Is there a way to strip HTML tags selectively in TextMate - you can easily do this in Dreamweaver. TextMate allows you to strip all HTML tags but I would like to get rid of only, let's say all the <span>'s and <font>'s.

On a similar topic, is there a way to get rid of all the inline css styles?

+2  A: 

Not that I'm aware of, but there's always the option of doing a Find/Replace for <span> (and </span>, obviously) and leaving the "Replace" field empty. Of course, this becomes a little more problematic if you've got spans with varying class/id attributes or what-have-you, then you're getting into RegExp territory.

That should at least give you a start, though. I'd be interested to hear what anyone else has to offer, though. Textmate is so customizable that I'm sure there's a better solution than what I've offered!

Scottie
+1  A: 

Why not use replace with regular expressions? E.g. to get rid of all inline css styles you would just replace

 style=".*"

with nothing (empty string). Note the leading space.

AlexH
Quantors are greedy by default.
Gumbo
Here at work I'm on Windows. I just tested on Notepad++. If TextMate does greedy matching by default, just use the non-greedy version: style=".*?"
AlexH
Notepad++ has a very limited regular expression support. http://notepad-plus.sourceforge.net/uk/regExpList.php
Gumbo
In contrast to that: TextMate’s regular expression support http://manual.macromates.com/en/regular_expressions
Gumbo