Modified to work with node and potentially npm.
authorHugo Wetterberg <hugo@wetterberg.nu>
Fri, 5 Aug 2011 13:48:20 +0000 (15:48 +0200)
committerHugo Wetterberg <hugo@wetterberg.nu>
Fri, 5 Aug 2011 13:48:20 +0000 (15:48 +0200)
package.json [new file with mode: 0644]
src/htmllint.js
src/htmlminifier.js
src/htmlparser.js

diff --git a/package.json b/package.json
new file mode 100644 (file)
index 0000000..2da4449
--- /dev/null
@@ -0,0 +1,35 @@
+{
+  "name": "html-minifier",
+  "version": "0.43",
+  "description": "HTMLMinifier is a Javascript-based HTML minifier with lint-like capabilities.",
+  "keywords": ["html", "minifier", "lint"],
+  "maintainers": [{
+    "name": "Juriy Zaytsev",
+    "email": "kangax@gmail.com",
+    "web": "http://perfectionkills.com"
+  }],
+  "contributors": [{
+    "name": "Gilmore Davidson",
+    "web": "https://github.com/gilmoreorless"
+  },
+  {
+    "name": "Hugo Wetterberg",
+    "email": "hugo@wetterberg.nu"
+  }],
+  "licenses": [{
+    "type": "MIT",
+    "url": "https://github.com/hugowetterberg/html-minifier/blob/gh-pages/src/license.txt"
+  }],
+  "repositories": [{
+    "type": "git",
+    "url": "git://github.com/hugowetterberg/html-minifier.git"
+  }],
+  "engines": {
+    "node": ">=0.4.8"
+  },
+  "directories": {
+    "src": "./src"
+  },
+  "main": "./src/htmlminifier.js"
+}
+
index c97dfb7..f61d579 100644 (file)
   
   global.HTMLLint = Lint;
   
-})(this);
\ No newline at end of file
+})(typeof exports === 'undefined' ? window : exports);
\ No newline at end of file
index b6d63b6..ab0cb08 100644 (file)
@@ -9,7 +9,7 @@
  
 (function(global){
   
-  var log;
+  var log, HTMLParser;
   if (global.console && global.console.log) {
     log = function(message) {
       // "preserving" `this`
     log = function(){ };
   }
   
+  if (global.HTMLParser) {
+    HTMLParser = global.HTMLParser;
+  }
+  else if (typeof require === 'function') {
+    HTMLParser = require('./htmlparser').HTMLParser;
+  }
+
   function trimWhitespace(str) {
     return str.replace(/^\s+/, '').replace(/\s+$/, '');
   }
   // export
   global.minify = minify;
   
-})(this);
\ No newline at end of file
+})(typeof exports === 'undefined' ? window : exports);
\ No newline at end of file
index e6fbcf4..50ccbcb 100644 (file)
@@ -24,7 +24,7 @@
  *
  */
 
-(function(){
+(function(global){
 
   // Regular Expressions for parsing tags and attributes
   var startTag = /^<(\w+)((?:\s*[\w:-]+(?:\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|[^>\s]+))?)*)\s*(\/?)>/,
@@ -53,7 +53,7 @@
   
   var reCache = { }, stackedTag, re;
 
-  var HTMLParser = this.HTMLParser = function( html, handler ) {
+  var HTMLParser = global.HTMLParser = function( html, handler ) {
     var index, chars, match, stack = [], last = html;
     stack.last = function(){
       return this[ this.length - 1 ];
     }
   };
   
-  this.HTMLtoXML = function( html ) {
+  global.HTMLtoXML = function( html ) {
     var results = "";
     
     HTMLParser(html, {
     return results;
   };
   
-  this.HTMLtoDOM = function( html, doc ) {
+  global.HTMLtoDOM = function( html, doc ) {
     // There can be only one of these elements
     var one = makeMap("html,head,body,title");
     
     }
     return obj;
   }
-})();
\ No newline at end of file
+})(typeof exports === 'undefined' ? window : exports);
\ No newline at end of file