0

I have searched but could not find anything similar to what I need. I am looking for a tool that is capable of removing leading/trailing spaces in my HTML files which also have embedded JavaScript. Basically in the end, I plan to use this tool within my Nant scripts to perform this task on the fly with every deployment.

Is there already a tool that can do this, or maybe the best scripting language?

Basically, I will like what MS Word does for text using "justify (Ctrl+J)", to be done for my HTML files.

tshepang
  • 12,111
  • 21
  • 91
  • 136
Geddon
  • 1,266
  • 1
  • 11
  • 31
  • 1
    Leading/trailing spaces from *where* in the HTML files? Are you just looking to [minify](http://en.wikipedia.org/wiki/Minification_(programming)) or is there another objective? – David Thomas Nov 02 '12 at 19:25
  • From the space in the beginning of the HTML files. I am not looking to minify or get rid of all whitespaces in the file. – Geddon Nov 02 '12 at 19:40
  • I remember A number of years ago someone at Cicso decided to delete all TABs (\t) from their web site and accidentally deleted every instance of the letter "t". http://nakedsecurity.sophos.com/2008/09/25/cisco-website-where-have-the-ts-gone/ – Diodeus - James MacFarlane Nov 02 '12 at 19:42
  • Tried the add an example in my original post but it wont let me...This tool does something similar to what I want for HTML files.http://www.odditysoftware.com/page-webtools16.htm – Geddon Nov 02 '12 at 19:45
  • Do you have a server-side scripting environment to do this? What tools are available, or are you willing to consider? – David Thomas Nov 02 '12 at 19:53
  • I am using a windows environment, so will consider scripting in powershell or cmd. – Geddon Nov 05 '12 at 13:57

1 Answers1

0

Here is the solution I found for this.

Using the html compressor command line tool, I was able to only remove the leading spaces of the html file where as fully minifying them didnt work.

Soultion:

java -jar htmlcompressor.jar --preserve-comments --preserve-multi-spaces --preserve-line-breaks --output D:\html\foo-leading_spaces.htm D:\html\foo.htm

Using this tool to generate my desired results, I am able to apply this to my build scripts to perform this process on the fly.

Thanks everyone for their input and hope this helps others in the similar situation.

Geddon
  • 1,266
  • 1
  • 11
  • 31