Add README.md;
authorJuriy Zaytsev <kangax@gmail.com>
Wed, 10 Mar 2010 02:04:15 +0000 (21:04 -0500)
committerJuriy Zaytsev <kangax@gmail.com>
Wed, 10 Mar 2010 02:04:15 +0000 (21:04 -0500)
Add </option> to tags allowed for deletion (thanks Jakub Vrána).

README.md [new file with mode: 0644]
src/htmlminifier.js
tests/index.html

diff --git a/README.md b/README.md
new file mode 100644 (file)
index 0000000..d0b7e98
--- /dev/null
+++ b/README.md
@@ -0,0 +1,3 @@
+[HTMLMinifier](http://kangax.github.com/html-minifier/) is a Javascript-based HTML minifier (duh), with lint-like capabilities.
+
+See [corresponding blog post](http://perfectionkills.com/experimenting-with-html-minifier/) for all the gory details of [how it works](http://perfectionkills.com/experimenting-with-html-minifier/#how_it_works), [description of each option](http://perfectionkills.com/experimenting-with-html-minifier/#options), [testing results](http://perfectionkills.com/experimenting-with-html-minifier/#field_testing) and [conclusions](http://perfectionkills.com/experimenting-with-html-minifier/#cost_and_benefits).
\ No newline at end of file
index bc3db26..dd7a9c9 100644 (file)
   }
   
   function isOptionalTag(tag) {
-    return (/^(?:html|t?body|t?head|tfoot|tr)$/).test(tag);
+    return (/^(?:html|t?body|t?head|tfoot|tr|option)$/).test(tag);
   }
   
   var reEmptyAttribute = new RegExp(
         buffer.push('>');
       },
       end: function( tag ) {
-        
         var isElementEmpty = currentChars === '' && tag === currentTag;
         if ((options.removeEmptyElements && isElementEmpty && canRemoveElement(tag))) {
           // remove last "element" from buffer, return
         }
         else if (options.removeOptionalTags && isOptionalTag(tag)) {
           // noop, leave start tag in buffer
+          return;
         }
         else {
           // push end tag to buffer
index c0f8e37..817283e 100644 (file)
           equals(minify(input), input);
         });
         
+        test('removing optional tags in options', function(){
+          input = '<select><option>foo</option><option>bar</option></select>';
+          output = '<select><option>foo<option>bar</select>';
+          equals(minify(input, { removeOptionalTags: true }), output);
+        });
+        
       })(this);
     </script>
   </body>