How to collectively remove all HTML and CSS comments from a file?


#1

Hello,

first of all, thank you for creating such an amazing editor!

I am not exactly a coder (certainly not a programmer).

As a marketer in our company though, it is my job to send newsletters to our customers. I coded an HTML template, and numerous HTML (+CSS) comments in it help me immensely.

However, it is not a good idea to keep comments in the final code (SPAM filters may block you). Therefore, I would like to ask you - is there a simple way to remove all the comments from an HTML file?

Ideally, if you could provide a little tutorial on how to bind such a “macro” with a certain keystroke.

Thank you very much :slight_smile:

Peter.


#2

I did a quick Google search and found this http://stackoverflow.com/questions/5989315/regex-for-match-replacing-javascript-comments-both-multiline-and-inline

In Atom you can find for regular expressions .* and use this:

(\/\*[\w\'\s\r\n\*]*\*\/)|(\/\/[\w\s\']*)|(\<![\-\-\s\w\>\/]*\>)

That expression is going to find all the comments and you can replace them with “nothing”.

I hope that helps.


#3

Multi Lang comment removal package would be nice.
Would only need a selector for comment and remove them all.


#4

Since it’s not a package (yet) for Atom, I still use Sublime and its “tag” package if I ever have to do this. I believe BBEdit also offers a “strip all tags” command.


#5

This would be interesting package for atom. I am going to do it when i free. Anyone wanna contribute?