Browse files

Add ablitity to keep comments. Fix dependency.

 * Newer clients like Outlook 2007-2013, unfortunately, render emails
   with Word, comments are need to provide background-images.
   (check: http://www.campaignmonitor.com/blog/post/3363/updated-applying-a-background-image-to-html-email/)
   So I've added an extra option `-c` to indicate, when true, that
   comments should not be removed. This option is false by default.
 * Celeri was not declared in the package.json as a dependency, making the
   binary throw errors when it was used. This was fixed.
 * Update README.md with the -c, --comments option.
  • Loading branch information...
1 parent a6325aa commit 66016bd02df5e49435c0474601310fbc8e5f5a0a Couto committed Oct 16, 2012
Showing with 28 additions and 16 deletions.
  1. +9 −3 README.md
  2. +6 −3 bin/emailify
  3. +10 −8 lib/index.js
  4. +3 −2 package.json
View
12 README.md
@@ -5,7 +5,7 @@ This is the node.js version of [premailer](http://premailer.dialect.ca/).
### Features
- Copies `<style />`, and `<link />` data to associated elements.
-- Strips out comments.
+- Strips out comments by default, but you can optionally keep them, this is useful if you intend to use VML to provide background-images.
- HTML compatibility checking for popular email clients. See:
- http://www.campaignmonitor.com/css/
- http://www.campaignmonitor.com/downloads/documents-tools/campaign-monitor-guide-to-css-in-email-sept-2011.pdf
@@ -65,16 +65,22 @@ npm install emailify -g
-i [input_html] -o [output_html]
Options:
- -i, --input [required]
+ -i, --input [required]
-o, --output
- -t, --test [default: false]
+ -t, --test [default: false]
+ -c, --comments [default: false]
```
To emailify a document, use this command:
```bash
emailify -i /my/html/file.html -o /my/html/emailified.html
```
+If you intend to keep comments, do the following:
+
+```bash
+emailify -c true -i /my/html/file.html -o /my/html/emailified.html
+```
You can easily test a document for compatibility by adding the `-t` flag:
View
9 bin/emailify
@@ -5,11 +5,15 @@ usage('-i [input_html] -o [output_html]').
demand('i').
default('o').
default('t', false).
+default('c', false).
alias('i','input').
alias('o','output').
alias('t','test').
+alias('c','comments').
argv;
+
+
var fs = require('fs'),
emailify = require('../'),
outcome = require('outcome'),
@@ -19,7 +23,6 @@ celeri = require('celeri');
*/
function fixFile(file) {
-
return file.replace(/^\.\//,process.cwd() + '/').replace(/^\~/,process.env.HOME);
}
@@ -37,7 +40,7 @@ var on = outcome.error(function(err) {
*/
-emailify.load(fixFile(argv.i), { test: argv.t }, on.success(function(content, warnings) {
+emailify.load(fixFile(argv.i), { test: argv.t , comments: argv.c }, on.success(function(content, warnings) {
if(argv.o) {
@@ -90,4 +93,4 @@ function printWarnings(warnings) {
fixed: true
});
console.log('\n');
-}
+}
View
18 lib/index.js
@@ -14,7 +14,7 @@ function _copyStyles(window) {
element.style.cssText += rule.style.cssText;
element.cssText = element.style.cssText;
- });
+ });
} catch(e) {
}
@@ -100,12 +100,14 @@ function _parse(content, options, callback) {
//strip stuff that cannot be processed
window.$('script, link, style').remove();
- //strip comments - sometimes gets rendered
- window.$('*').contents().each(function(node) {
- if(this.nodeType == 8) {
- window.$(this).remove();
- }
- });
+ if (!options.comments) {
+ //strip comments - sometimes gets rendered
+ window.$('*').contents().each(function(node) {
+ if(this.nodeType == 8) {
+ window.$(this).remove();
+ }
+ });
+ }
this();
@@ -147,4 +149,4 @@ function _load(file, options, callback) {
}
exports.parse = _parse;
-exports.load = _load;
+exports.load = _load;
View
5 package.json
@@ -16,10 +16,11 @@
"plugin": "0.0.x",
"step": "0.0.x",
"colors": "0.6.x",
- "sprintf": "0.1.x"
+ "sprintf": "0.1.x",
+ "celeri": "0.2.x"
},
"devDependencies": {},
"bin": {
"emailify": "./bin/emailify"
}
-}
+}

0 comments on commit 66016bd

Please sign in to comment.