|
|
@@ -365,6 +365,31 @@ this.SingleFileCore = this.SingleFileCore || (() => {
|
|
|
this.onEventAttributeNames = Util.getOnEventAttributeNames(this.doc);
|
|
|
}
|
|
|
|
|
|
+ async finalize() {
|
|
|
+ const metaCharset = this.doc.head.querySelector("meta[charset]");
|
|
|
+ if (metaCharset) {
|
|
|
+ this.doc.head.insertBefore(metaCharset, this.doc.head.firstChild);
|
|
|
+ }
|
|
|
+ this.doc.querySelectorAll("base").forEach(element => element.remove());
|
|
|
+ if (this.doc.head.querySelectorAll("*").length == 1 && metaCharset && this.doc.body.childNodes.length == 0) {
|
|
|
+ this.doc.head.querySelector("meta[charset]").remove();
|
|
|
+ }
|
|
|
+ const titleElement = this.doc.querySelector("title");
|
|
|
+ const descriptionElement = this.doc.querySelector("meta[name=description]");
|
|
|
+ const authorElement = this.doc.querySelector("meta[name=author]");
|
|
|
+ const creatorElement = this.doc.querySelector("meta[name=creator]");
|
|
|
+ const publisherElement = this.doc.querySelector("meta[name=publisher]");
|
|
|
+ this.options.title = titleElement ? titleElement.textContent.trim() : "";
|
|
|
+ this.options.infobarContent = await ProcessorHelper.evalTemplate(this.options.infobarTemplate, this.options, null, true);
|
|
|
+ this.options.info = {
|
|
|
+ description: descriptionElement && descriptionElement.content ? descriptionElement.content.trim() : "",
|
|
|
+ lang: this.doc.documentElement.lang,
|
|
|
+ author: authorElement && authorElement.content ? authorElement.content.trim() : "",
|
|
|
+ creator: creatorElement && creatorElement.content ? creatorElement.content.trim() : "",
|
|
|
+ publisher: publisherElement && publisherElement.content ? publisherElement.content.trim() : ""
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
async getPageData() {
|
|
|
DocUtil.postProcessDoc(this.doc, this.options);
|
|
|
const url = DocUtil.parseURL(this.baseURI);
|
|
|
@@ -409,31 +434,6 @@ this.SingleFileCore = this.SingleFileCore || (() => {
|
|
|
};
|
|
|
}
|
|
|
|
|
|
- async finalize() {
|
|
|
- const metaCharset = this.doc.head.querySelector("meta[charset]");
|
|
|
- if (metaCharset) {
|
|
|
- this.doc.head.insertBefore(metaCharset, this.doc.head.firstChild);
|
|
|
- }
|
|
|
- this.doc.querySelectorAll("base").forEach(element => element.remove());
|
|
|
- if (this.doc.head.querySelectorAll("*").length == 1 && metaCharset && this.doc.body.childNodes.length == 0) {
|
|
|
- this.doc.head.querySelector("meta[charset]").remove();
|
|
|
- }
|
|
|
- const titleElement = this.doc.querySelector("title");
|
|
|
- const descriptionElement = this.doc.querySelector("meta[name=description]");
|
|
|
- const authorElement = this.doc.querySelector("meta[name=author]");
|
|
|
- const creatorElement = this.doc.querySelector("meta[name=creator]");
|
|
|
- const publisherElement = this.doc.querySelector("meta[name=publisher]");
|
|
|
- this.options.title = titleElement ? titleElement.textContent.trim() : "";
|
|
|
- this.options.infobarContent = await ProcessorHelper.evalTemplate(this.options.infobarTemplate, this.options, null, true);
|
|
|
- this.options.info = {
|
|
|
- description: descriptionElement && descriptionElement.content ? descriptionElement.content.trim() : "",
|
|
|
- lang: this.doc.documentElement.lang,
|
|
|
- author: authorElement && authorElement.content ? authorElement.content.trim() : "",
|
|
|
- creator: creatorElement && creatorElement.content ? creatorElement.content.trim() : "",
|
|
|
- publisher: publisherElement && publisherElement.content ? publisherElement.content.trim() : ""
|
|
|
- };
|
|
|
- }
|
|
|
-
|
|
|
preProcessPage() {
|
|
|
if (this.options.win) {
|
|
|
this.doc.body.querySelectorAll(":not(svg) title, meta, link[href][rel*=\"icon\"]").forEach(element => element instanceof this.options.win.HTMLElement && this.doc.head.appendChild(element));
|