From ba1e7b956f020fb528798b0159fcaacc70432cb8 Mon Sep 17 00:00:00 2001 From: Domenic Denicola Date: Sat, 9 May 2015 01:28:43 +0200 Subject: [PATCH] More cleanup in conversion --- lib/convert.js | 12 ++++++++---- lib/worm-scraper.js | 6 +++--- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/convert.js b/lib/convert.js index 4c31a8d..b021e13 100644 --- a/lib/convert.js +++ b/lib/convert.js @@ -80,14 +80,16 @@ function getBodyXml(headingEl, contentEl) { contentEl.removeChild(contentEl.lastElementChild); } - // Remove redundant dir="ltr" and align="LEFT" and style="text-align: left;" + // Remove redundant attributes Array.prototype.forEach.call(contentEl.children, function (child) { if (child.getAttribute("dir") === "ltr") { child.removeAttribute("dir"); } - if ((child.getAttribute("align") || "").toLowerCase() === "left") { - child.removeAttribute("align"); - } + + // Only ever appears with align="LEFT" (useless) or align="CENTER" overridden by style="text-align: left;" (also + // useless) + child.removeAttribute("align"); + if (child.getAttribute("style") === "text-align:left;") { child.removeAttribute("style"); } @@ -101,6 +103,8 @@ function getBodyXml(headingEl, contentEl) { } }); + // TODO: remove redundant s inside

s + // Synthesize a tag to serialize const bodyEl = contentEl.ownerDocument.createElement("body"); const h1El = contentEl.ownerDocument.createElement("h1"); diff --git a/lib/worm-scraper.js b/lib/worm-scraper.js index 75367cf..ebed3b3 100644 --- a/lib/worm-scraper.js +++ b/lib/worm-scraper.js @@ -21,13 +21,13 @@ Promise.resolve() // return download(START_CHAPTER_URL, cachePath); }) .then(function () { -// return rimraf(chaptersPath); + return rimraf(chaptersPath); }) .then(function () { -// return mkdirp(chaptersPath); + return mkdirp(chaptersPath); }) .then(function () { -// return convert(cachePath, chaptersPath); + return convert(cachePath, chaptersPath); }) .then(function () { return extras(contentPath, chaptersPath);