markdown-up 1.8.5 → 1.8.6

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.
Files changed (2) hide show
  1. package/lib/app.js +5 -0
  2. package/package.json +1 -1
package/lib/app.js CHANGED
@@ -77,6 +77,7 @@ enum MarkdownUpView
77
77
  * @typedef {Object} MarkdownUpOptions
78
78
  * @property {boolean} [darkMode = false] - If true, use dark mode by default
79
79
  * @property {number} [fontSize = 12] - The font size, in points
80
+ * @property {?Object} [globals = null] - Global script runtime variables
80
81
  * @property {number} [lineHeight = 1.2] - The line height, in em
81
82
  * @property {?string} [markdownText = null] - The default Markdown text
82
83
  * @property {boolean} [menu = true] - If true, show the menu
@@ -101,6 +102,7 @@ export class MarkdownUp {
101
102
  this.paramsSession = null;
102
103
  this.darkMode = (options !== null ? options.darkMode : null) ?? false;
103
104
  this.fontSize = (options !== null ? options.fontSize : null) ?? 12;
105
+ this.globals = (options !== null ? options.globals : null) ?? null;
104
106
  this.lineHeight = (options !== null ? options.lineHeight : null) ?? 1.2;
105
107
  this.markdownText = (options !== null ? options.markdownText : null) ?? null;
106
108
  this.menu = (options !== null ? options.menu : null) ?? true;
@@ -393,6 +395,9 @@ export class MarkdownUp {
393
395
  // Create the markdown-script runtime
394
396
  const runtime = new MarkdownScriptRuntime(scriptOptions);
395
397
  scriptOptions.globals = {...markdownScriptFunctions};
398
+ if (this.globals !== null) {
399
+ Object.assign(scriptOptions.globals, this.globals);
400
+ }
396
401
  scriptOptions.runtime = runtime;
397
402
  scriptOptions.runtimeUpdateFn = () => {
398
403
  // Did script set the document title?
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "markdown-up",
4
- "version": "1.8.5",
4
+ "version": "1.8.6",
5
5
  "description": "MarkdownUp is a Markdown viewer",
6
6
  "keywords": [
7
7
  "markdown",