From: Jeanie Chung Date: Wed, 28 Jan 2015 23:49:32 +0000 (-0800) Subject: Fixed extra wrapper classes being inserted. Cheerio counts each tag (open/close)... X-Git-Tag: v2.0.0-rc.1~149 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fcf6efb5756ec6e7ecd12e8b526f2553c443600b;p=thirdparty%2Ffoundation%2Ffoundation-emails.git Fixed extra wrapper classes being inserted. Cheerio counts each tag (open/close) as an object instead of individual ones, so after doing some fancy math and exceptions, we are now only counting individual column elements instead of their tag pairs. --- diff --git a/html/index.html b/html/index.html index ba8986a6..8f366a42 100644 --- a/html/index.html +++ b/html/index.html @@ -14,7 +14,7 @@
- asdfasdf + sdfasf

I'm a p tag in a col

diff --git a/html/sidebar-test.html b/html/sidebar-test.html deleted file mode 100644 index c4b8eb20..00000000 --- a/html/sidebar-test.html +++ /dev/null @@ -1,100 +0,0 @@ - - - - - - - - - - - - - - - -
-
- - - - - -

SIDEBAR

- -
- -
-
- - - -

Hello,
Han Fastolfe

-

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et.

-

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et. Lorem ipsum dolor sit amet.

- -

Phasellus dictum sapien a neque luctus cursus. Pellentesque sem dolor, fringilla et pharetra vitae. Click it! »

-
-
- -

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et.

-

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et. Lorem ipsum dolor sit amet.

- -
-
- - - -
Header Thing
-

Subhead

- Link
- Link
- Link
- Link
- Link
-
-
- - -
Connect With Us
- - - - - - -
- - - - - - - -
- - - - - -
- Google + -
-
-
Contact Info:
-

Phone: 408.341.0600

-

Email: hseldon@trantor.com

-
-
-
-
-
-
- - \ No newline at end of file diff --git a/output/index.html b/output/index.html index 04810b8a..1ef700ea 100644 --- a/output/index.html +++ b/output/index.html @@ -15,10 +15,10 @@
-
I'm a p tag in a col
I"M A BUTTON
panel
I'm even
ANOTHER BOTON
- asdlfkjadsf
-
I'm even
Lsdlkfjsdf
asdlfkjadsf
I'm even
Lsdlkfjsdf
asdlfkjadsf
-
I'm a header!
+
I'm a p tag in a col
I"M A BUTTON
panel
I'm even
ANOTHER BOTON
+ asdlfkjadsf
+
I'm even
Lsdlkfjsdf
asdlfkjadsf
I'm even
Lsdlkfjsdf
asdlfkjadsf
+
I'm a header!
diff --git a/output/index.js b/output/index.js index 9dc1f465..e3e8fc2b 100644 --- a/output/index.js +++ b/output/index.js @@ -65,8 +65,12 @@ module.exports = function (body) { return colHTML; }; - // create tables with wrapper class for each column + + // weird math thing to do with cheerio including closing tags and stuff + // so it throws off the number of objects being counted as elements + var colCount = Math.round((obj.length - 1 / 2)); + $(obj).each(function(k,v) { var wrapperHTML = ''; var colSize = ''; @@ -78,10 +82,13 @@ module.exports = function (body) { } // if wrapper is last or the only one, put last class - if (k === obj.length - 1) { - wrapperHTML += ''; - } else { - wrapperHTML += ''; + + if (!obj[k].data) { + if (k === colCount) { + wrapperHTML += ''; + } else { + wrapperHTML += ''; + } } // check for sizes @@ -119,7 +126,7 @@ module.exports = function (body) { }); - file.contents = new Buffer($.html()); + file.contents = new Buffer($.html({normalizeWhitespace: true})); this.emit('data', file); }; diff --git a/output/sidebar-test.html b/output/sidebar-test.html deleted file mode 100644 index d98e723b..00000000 --- a/output/sidebar-test.html +++ /dev/null @@ -1,73 +0,0 @@ - - - - - - - - - - - - - - - -
-
-
-
SIDEBAR
-
-
-
Hello,
Han Fastolfe
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et.
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et. Lorem ipsum dolor sit amet.
-

Phasellus dictum sapien a neque luctus cursus. Pellentesque sem dolor, fringilla et pharetra vitae. Click it! »

-
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et.
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et. Lorem ipsum dolor sit amet.
- Click Me! -
-
-
Header Thing
-

Subhead

- Link
- Link
- Link
- Link
- Link
-
-
Connect With Us
- - - - - - -
- - - - - - - -
- - - - - -
- Google + -
-
-
Contact Info:
-

Phone: 408.341.0600

-

Email: hseldon@trantor.com

-
-
-
-
- - \ No newline at end of file