Skip to content

Commit

Permalink
Secondlifetranslations: Footnotes to end of chapter
Browse files Browse the repository at this point in the history
See: #1035
  • Loading branch information
dteviot committed Aug 26, 2023
1 parent 9db8489 commit 589c104
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 14 deletions.
16 changes: 16 additions & 0 deletions plugin/js/Parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,22 @@ class Parser {
}
return chapters;
}

moveFootnotes(dom, content, footnotes) {
if (0 < footnotes.length) {
let list = dom.createElement("ol");
for(let f of footnotes) {
let item = dom.createElement("li");
f.removeAttribute("style");
item.appendChild(f);
list.appendChild(item);
}
let header = dom.createElement("h2");
header.appendChild(dom.createTextNode("Footnotes"));
content.appendChild(header);
content.appendChild(list);
}
}
}

Parser.WEB_TO_EPUB_CLASS_NAME = "webToEpubContent";
15 changes: 1 addition & 14 deletions plugin/js/parsers/PeachblossomcodexParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,8 @@ class PeachblossomcodexParser extends Parser{
if (note !== null) {
content.append(note);
}
this.moveFootnotes(webPageDom, content);
}

moveFootnotes(dom, content) {
let footnotes = [...content.querySelectorAll(".wpcmtt")];
if (0 < footnotes.length) {
let list = dom.createElement("ol");
for(let f of footnotes) {
let item = dom.createElement("li");
f.removeAttribute("style");
item.appendChild(f);
list.appendChild(item);
}
content.appendChild(list);
}
this.moveFootnotes(webPageDom, content, footnotes);
}

getInformationEpubItemChildNodes(dom) {
Expand Down
6 changes: 6 additions & 0 deletions plugin/js/parsers/SecondlifetranslationsParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ class SecondlifetranslationsParser extends Parser{
return img === null ? null : img.src;
}

preprocessRawDom(webPageDom) {
let content = this.findContent(webPageDom);
let footnotes = [...content.querySelectorAll("span.modern-footnotes-footnote__note")];
this.moveFootnotes(webPageDom, content, footnotes);
}

getInformationEpubItemChildNodes(dom) {
return [...dom.querySelectorAll("div.novel-entry-content")];
}
Expand Down

0 comments on commit 589c104

Please sign in to comment.