Revise the chapter URL comments

This commit is contained in:
Domenic Denicola 2020-10-26 21:29:21 -04:00
commit bcca56866c

View file

@ -119,9 +119,6 @@ function getBodyXML(chapter, book, contentEl) {
h1El.textContent = chapter.title;
bodyEl.appendChild(h1El);
const comment = contentEl.ownerDocument.createComment(chapter.url);
bodyEl.appendChild(comment);
while (contentEl.firstChild) {
bodyEl.appendChild(contentEl.firstChild);
}
@ -458,8 +455,11 @@ function getBodyXML(chapter, book, contentEl) {
}
});
// Serializer inserts extra xmlns for us since it doesn't know we're going to put this into a <html>
xml = xml.replace(/<body xmlns="http:\/\/www.w3.org\/1999\/xhtml">/, "<body>");
// Serializer inserts extra xmlns for us since it doesn't know we're going to put this into a <html>.
// Use this opportunity to insert a comment pointing to the original URL, for reference.
xml = xml.replace(
/<body xmlns="http:\/\/www.w3.org\/1999\/xhtml">/,
`<body>\n<!-- ${chapter.url} -->\n`);
return xml;
}