xonecas.io
117
Ht

htmlKompressor / commit 9ad0752

better compression, space condensation

xonecas2011-06-03 9ad0752a2181503f0824fe7ca6dd34bf07b16cfd parent 72d3706

3 files changed

lib/kompressor.js+5−5
@@ -13,24 +13,24 @@ module.exports = function (source, noComments) {
1313 if (!insidePre) {
1414 var start = line.match(/<pre/);
1515 if (start) {
16- line.replace(/^\s+/, ""); // only before the pre tag
16+ line = line.replace(/^\s+/, ""); // only before the pre tag
1717
1818 // does it end in the same line?
1919 var end = line.match(/<\/pre>/);
2020 if (end && end.index > start.index)
21- line.replace(/\s+$/, "");
21+ line = line.replace(/\s+$/, "");
2222 else
2323 insidePre = true;
2424 }
2525 else { // no pre
26- line.trim();
27- line.replace(/\s\s+/, ""); // condense spaces
26+ line = line.replace(/\s+/g, " "); // condense spaces
27+ line = line.trim();
2828 }
2929 }
3030 else { // inside pre tag
3131 var end = line.match(/<\/pre>/);
3232 if (end) {
33- line.replace(/\s+$/, "");
33+ line = line.replace(/\s+$/, "");
3434 insidePre = false;
3535 }
3636 }
package.json+1−1
@@ -1,7 +1,7 @@
11 {
22 "name": "htmlKompressor",
33 "description": "Node.js Module for compressing html files",
4- "version": "0.0.1",
4+ "version": "0.0.3",
55 "main": "lib/kompressor.js",
66 "homepage": "https://github.com/xonecas/htmlKompressor",
77 "repository": {
test/index.html+2−2
@@ -1,4 +1,4 @@
1-<!doctype html><!--[if lt IE 9 ]> <html class="no-js oldie" lang="en"> <![endif]--><!--[if (gte IE 9)|!(IE)]><!--> <html class="no-js" lang="en"> <!--<![endif]--><head><meta charset="utf-8"><title>Dusty Markdown</title><meta name="description" content="simple command line content manager"><meta name="author" content="@xonecas"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link rel="shortcut icon" href="/favicon.ico"><link rel="apple-touch-icon" href="/apple-touch-icon.pn …
1+<!doctype html> <!--[if lt IE 9 ]> <html class="no-js oldie" lang="en"> <![endif]--><!--[if (gte IE 9)|!(IE)]><!--> <html class="no-js" lang="en"> <!--<![endif]--><head><meta charset="utf-8"><title>Dusty Markdown</title><meta name="description" content="simple command line content manager"><meta name="author" content="@xonecas"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link rel="shortcut icon" href="/favicon.ico"><link rel="apple-touch-icon" href="/apple-touch-icon. …
22 <p>This project is the new content manager under <a href="http://xonecas.com">xonecas.com</a>.
33 It's very minimal and light, developer friendly. The idea
44 is that you can write the dynamic content in markdown and
@@ -64,4 +64,4 @@ There is also a very simple unique visitors/request counter.</p>
6464 <li><a href="http://h5bp.com/"><em>HTML5 Boilerplate</em> →</a></li>
6565 <li><a href="http://akdubya.github.com/dustjs/"><em>Dust</em> →</a></li>
6666 <li><a href="http://daringfireball.net/projects/markdown/basics"><em>Markdown</em> →</a></li>
67-</ul></section><script src="//ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.js"></script><script>window.jQuery || document.write("<script src='js/libs/jquery-1.5.1.min.js'>\x3C/script>")</script><!-- scripts concatenated and minified via ant build script--><script src="js/plugins.js"></script><script src="js/script.js"></script><!-- end scripts--><!--[if lt IE 7 ]><script src="js/libs/dd_belatedpng.js"></script><script>DD_belatedPNG.fix("img, .png_bg");</script><![endif]--></body></html>
67+</ul></section><script src="//ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.js"></script><script>window.jQuery || document.write("<script src='js/libs/jquery-1.5.1.min.js'>\x3C/script>")</script><!-- scripts concatenated and minified via ant build script--><script src="js/plugins.js"></script><script src="js/script.js"></script><!-- end scripts--><!--[if lt IE 7 ]><script src="js/libs/dd_belatedpng.js"></script><script>DD_belatedPNG.fix("img, .png_bg");</script><![endif]--></body></html>