More cleanup in conversion
This commit is contained in:
parent
a26f622fbb
commit
ba1e7b956f
2 changed files with 11 additions and 7 deletions
|
|
@ -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 <span id>s inside <p>s
|
||||
|
||||
// Synthesize a <body> tag to serialize
|
||||
const bodyEl = contentEl.ownerDocument.createElement("body");
|
||||
const h1El = contentEl.ownerDocument.createElement("h1");
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue