single-file-core 1.5.13 → 1.5.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/index.js +1 -1
- package/core/util.js +2 -2
- package/modules/template-formatter.js +11 -9
- package/package.json +1 -1
package/core/index.js
CHANGED
|
@@ -1535,7 +1535,7 @@ class Processor {
|
|
|
1535
1535
|
publisher: publisherElement && publisherElement.content ? publisherElement.content.trim() : "",
|
|
1536
1536
|
heading: headingElement && headingElement.textContent ? headingElement.textContent.trim() : ""
|
|
1537
1537
|
};
|
|
1538
|
-
this.options.infobarContent = await util.evalTemplate(this.options.infobarTemplate, this.options, null, this.doc, true);
|
|
1538
|
+
this.options.infobarContent = await util.evalTemplate(this.options.infobarTemplate, this.options, null, this.doc, { dontReplaceSlash: true });
|
|
1539
1539
|
}
|
|
1540
1540
|
}
|
|
1541
1541
|
|
package/core/util.js
CHANGED
|
@@ -166,8 +166,8 @@ function getInstance(utilOptions) {
|
|
|
166
166
|
getMimeType(options) {
|
|
167
167
|
return !options.compressContent || options.selfExtractingArchive ? "text/html" : "application/zip";
|
|
168
168
|
},
|
|
169
|
-
async evalTemplate(template, options, content, doc,
|
|
170
|
-
return modules.templateFormatter.evalTemplate(template, options, content, doc,
|
|
169
|
+
async evalTemplate(template, options, content, doc, context) {
|
|
170
|
+
return modules.templateFormatter.evalTemplate(template, options, content, doc, context);
|
|
171
171
|
},
|
|
172
172
|
minifyHTML(doc, options) {
|
|
173
173
|
return modules.htmlMinifier.process(doc, options);
|
|
@@ -16899,7 +16899,9 @@ async function formatFilename(content, doc, options) {
|
|
|
16899
16899
|
return filename.trim();
|
|
16900
16900
|
}
|
|
16901
16901
|
|
|
16902
|
-
async function evalTemplate(template = "", options, content, doc,
|
|
16902
|
+
async function evalTemplate(template = "", options, content, doc, context = {}) {
|
|
16903
|
+
const { dontReplaceSlash } = context;
|
|
16904
|
+
context.currentDate = new Date();
|
|
16903
16905
|
const url = new URL(options.saveUrl);
|
|
16904
16906
|
const urlHref = decode(url.href);
|
|
16905
16907
|
const params = Array.from(new URLSearchParams(url.search));
|
|
@@ -17018,11 +17020,11 @@ async function evalTemplate(template = "", options, content, doc, dontReplaceSla
|
|
|
17018
17020
|
"decode-uri": value => { try { return decodeURI(value); } catch (error) { return value; } },
|
|
17019
17021
|
"encode-uri-component": value => { try { return encodeURIComponent(value); } catch (error) { return value; } },
|
|
17020
17022
|
"decode-uri-component": value => { try { return decodeURIComponent(value); } catch (error) { return value; } },
|
|
17021
|
-
"date-locale": locales =>
|
|
17022
|
-
"time-locale": locales =>
|
|
17023
|
-
"datetime-locale": locales =>
|
|
17023
|
+
"date-locale": locales => context.currentDate.toLocaleDateString(locales),
|
|
17024
|
+
"time-locale": locales => context.currentDate.toLocaleTimeString(locales),
|
|
17025
|
+
"datetime-locale": locales => context.currentDate.toLocaleString(locales),
|
|
17024
17026
|
"datetime-custom": (locale, year, month, day, weekday, hour, minute, second, hour12, timeZone, fractionalSecondDigits, timeZoneName, dayPeriod, era, localeMatcher) => {
|
|
17025
|
-
const date =
|
|
17027
|
+
const date = context.currentDate;
|
|
17026
17028
|
const options = {};
|
|
17027
17029
|
setOption(options, "year", year);
|
|
17028
17030
|
setOption(options, "month", month);
|
|
@@ -17050,10 +17052,10 @@ async function evalTemplate(template = "", options, content, doc, dontReplaceSla
|
|
|
17050
17052
|
}
|
|
17051
17053
|
}
|
|
17052
17054
|
};
|
|
17053
|
-
functions["date-locale"].dontReplaceSlash =
|
|
17054
|
-
functions["time-locale"].dontReplaceSlash =
|
|
17055
|
-
functions["datetime-locale"].dontReplaceSlash =
|
|
17056
|
-
functions["datetime-custom"].dontReplaceSlash =
|
|
17055
|
+
functions["date-locale"].dontReplaceSlash = true;
|
|
17056
|
+
functions["time-locale"].dontReplaceSlash = true;
|
|
17057
|
+
functions["datetime-locale"].dontReplaceSlash = true;
|
|
17058
|
+
functions["datetime-custom"].dontReplaceSlash = true;
|
|
17057
17059
|
if (doc) {
|
|
17058
17060
|
functions["page-element-text"] = (selector) => {
|
|
17059
17061
|
const element = doc.querySelector(selector);
|