|
|
@ -55,7 +55,7 @@ export default async function(
|
|
|
|
|
|
|
|
|
|
|
|
const Properties = new Map([
|
|
|
|
const Properties = new Map([
|
|
|
|
["html-title", (article, singleLine, document) =>
|
|
|
|
["html-title", (article, singleLine, document) =>
|
|
|
|
`<h1>${escapeHTML(Properties.get("title")(article, singleLine, document), document)}</h1>`
|
|
|
|
`<h1>${escapeHTML(Properties.get("title")(article, singleLine, document))}</h1>`
|
|
|
|
],
|
|
|
|
],
|
|
|
|
["title", (article, singleLine) =>
|
|
|
|
["title", (article, singleLine) =>
|
|
|
|
singleLine ? article.title.replace(/\n+/gm, ' ') : article.title
|
|
|
|
singleLine ? article.title.replace(/\n+/gm, ' ') : article.title
|
|
|
@ -398,11 +398,16 @@ export default async function(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Taken from https://stackoverflow.com/a/22706073/5701177
|
|
|
|
//Taken from https://stackoverflow.com/a/30970751
|
|
|
|
function escapeHTML(string, document) {
|
|
|
|
function escapeHTML(string) {
|
|
|
|
const p = document.createElement("p");
|
|
|
|
const lookup = {
|
|
|
|
p.appendChild(document.createTextNode(string));
|
|
|
|
'&': "&",
|
|
|
|
return p.innerHTML;
|
|
|
|
'"': """,
|
|
|
|
|
|
|
|
'\'': "'",
|
|
|
|
|
|
|
|
'<': "<",
|
|
|
|
|
|
|
|
'>': ">"
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
return string.replace( /[&"'<>]/g, c => lookup[c] );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async function getHTML(document, window) {
|
|
|
|
async function getHTML(document, window) {
|
|
|
@ -489,7 +494,7 @@ export default async function(
|
|
|
|
<link rel="stylesheet" href="${cssHref}" type="text/css">`);
|
|
|
|
<link rel="stylesheet" href="${cssHref}" type="text/css">`);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
writeStream.write(`
|
|
|
|
writeStream.write(`
|
|
|
|
<title>${escapeHTML(Properties.get("title")(article, false, document), document)}</title>
|
|
|
|
<title>${escapeHTML(Properties.get("title")(article, false, document))}</title>
|
|
|
|
</head>
|
|
|
|
</head>
|
|
|
|
`
|
|
|
|
`
|
|
|
|
);
|
|
|
|
);
|
|
|
@ -508,12 +513,12 @@ export default async function(
|
|
|
|
|
|
|
|
|
|
|
|
writeStream.write(`
|
|
|
|
writeStream.write(`
|
|
|
|
<div class="header reader-header reader-show-element">
|
|
|
|
<div class="header reader-header reader-show-element">
|
|
|
|
<h1 class="reader-title">${escapeHTML(Properties.get("title")(article, false, document), document)}</h1>`);
|
|
|
|
<h1 class="reader-title">${escapeHTML(Properties.get("title")(article, false, document))}</h1>`);
|
|
|
|
|
|
|
|
|
|
|
|
const author = Properties.get("byline")(article, false, document);
|
|
|
|
const author = Properties.get("byline")(article, false, document);
|
|
|
|
if (author) {
|
|
|
|
if (author) {
|
|
|
|
writeStream.write(`
|
|
|
|
writeStream.write(`
|
|
|
|
<div class="credits reader-credits">${escapeHTML(author, document)}</div>`);
|
|
|
|
<div class="credits reader-credits">${escapeHTML(author)}</div>`);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
writeStream.write(`
|
|
|
|
writeStream.write(`
|
|
|
@ -543,7 +548,7 @@ export default async function(
|
|
|
|
|
|
|
|
|
|
|
|
const author = Properties.get("byline")(article, false, document);
|
|
|
|
const author = Properties.get("byline")(article, false, document);
|
|
|
|
if (author) {
|
|
|
|
if (author) {
|
|
|
|
writeStream.write(`<p><i>${escapeHTML(author, document)}</i></p>`);
|
|
|
|
writeStream.write(`<p><i>${escapeHTML(author)}</i></p>`);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
writeStream.write("\n<hr>\n");
|
|
|
|
writeStream.write("\n<hr>\n");
|
|
|
|
const html = Properties.get("html-content")(article, false, document);
|
|
|
|
const html = Properties.get("html-content")(article, false, document);
|
|
|
|