Permalink
Browse files

add --noemptypipe option to remove lines with just pipe character. fi…

…xes #93
  • Loading branch information...
1 parent c379dc8 commit 693186f1bb1667a89f7612721744745b8acf5d4e @donpark committed May 15, 2015
Showing with 10 additions and 2 deletions.
  1. +1 −0 README.md
  2. +1 −0 cli.js
  3. +2 −0 lib/html2jade.coffee
  4. +5 −1 lib/html2jade.js
  5. +1 −1 package.json
View
@@ -56,6 +56,7 @@ To generate [Scalate](http://scalate.fusesource.org/) compatible output:
* `--numeric` - use numeric character entities
* `-s, --scalate` - generate [Scalate](http://scalate.fusesource.org/) variant of jade syntax
* `--noattrcomma` - omit attribute separating commas
+* `--noemptypipe` - omit lines with only pipe ('|') printable character
## Programmatic Usage (>= 0.0.7)
View
@@ -57,6 +57,7 @@ program
.option('--bodyless', 'do not output enveloping html and body tags')
.option('--numeric', 'use numeric character entities')
.option('--noattrcomma', 'omit attribute separating commas')
+ .option('--noemptypipe', 'omit lines with only pipe (\'|\') printable character')
program.parse(process.argv);
@@ -61,6 +61,7 @@ class Writer
@attrQuote = "'"
@nonAttrQuote = '"'
@attrQuoteEscaped = "\\#{@attrQuote}"
+ @noEmptyPipe = options.noemptypipe ? false
tagHead: (node) ->
result = if node.tagName isnt 'DIV' then node.tagName.toLowerCase() else ''
if node.id and isValidJadeId(node.id)
@@ -146,6 +147,7 @@ class Writer
wrap = options.wrap ? true
encodeEntityRef = options.encodeEntityRef ? false
escapeBackslash = options.escapeBackslash ? false
+ return if pipe and @noEmptyPipe and line.trim().length is 0
prefix = if pipe then '| ' else ''
line = line.trimLeft() unless node?.previousSibling?.nodeType is 1
line = line.trimRight() unless node?.nextSibling?.nodeType is 1
View
@@ -78,7 +78,7 @@
Writer = (function() {
function Writer(options) {
- var _ref, _ref1;
+ var _ref, _ref1, _ref2;
if (options == null) {
options = {};
}
@@ -93,6 +93,7 @@
this.nonAttrQuote = '"';
}
this.attrQuoteEscaped = "\\" + this.attrQuote;
+ this.noEmptyPipe = (_ref2 = options.noemptypipe) != null ? _ref2 : false;
}
Writer.prototype.tagHead = function(node) {
@@ -225,6 +226,9 @@
wrap = (_ref2 = options.wrap) != null ? _ref2 : true;
encodeEntityRef = (_ref3 = options.encodeEntityRef) != null ? _ref3 : false;
escapeBackslash = (_ref4 = options.escapeBackslash) != null ? _ref4 : false;
+ if (pipe && this.noEmptyPipe && line.trim().length === 0) {
+ return;
+ }
prefix = pipe ? '| ' : '';
if ((node != null ? (_ref5 = node.previousSibling) != null ? _ref5.nodeType : void 0 : void 0) !== 1) {
line = line.trimLeft();
View
@@ -1,7 +1,7 @@
{
"name": "html2jade",
"description": "HTML to Jade conversion tool",
- "version": "0.8.3",
+ "version": "0.8.4",
"author": "Don Park <donpark@docuverse.com>",
"repository": "git://github.com/donpark/html2jade.git",
"license": "BSD",

0 comments on commit 693186f

Please sign in to comment.