markdown-up 3.3.3 → 3.3.4
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/README.md +1 -3
- package/lib/app.js +14 -27
- package/lib/script.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -52,9 +52,7 @@ application stub file, index.html. For example:
|
|
|
52
52
|
...
|
|
53
53
|
~~~
|
|
54
54
|
|
|
55
|
-
To view a different Markdown resource, set the application's
|
|
56
|
-
["url" hash parameter](https://craigahobbs.github.io/markdown-up/#cmd.help=1)
|
|
57
|
-
(i.e., "http://127.0.0.1:8000#url=other.md").
|
|
55
|
+
To view a different Markdown resource, set the application's "url" hash parameter (i.e., "http://127.0.0.1:8000#url=other.md").
|
|
58
56
|
|
|
59
57
|
|
|
60
58
|
## Dynamic Markdown Applications
|
package/lib/app.js
CHANGED
|
@@ -12,19 +12,12 @@ import {markdownScriptFunctions} from './scriptLibrary.js';
|
|
|
12
12
|
import {parseExpression} from 'bare-script/lib/parser.js';
|
|
13
13
|
import {parseSchemaMarkdown} from 'schema-markdown/lib/parser.js';
|
|
14
14
|
import {renderElements} from 'element-model/lib/elementModel.js';
|
|
15
|
-
import {schemaMarkdownDoc} from 'schema-markdown-doc/lib/schemaMarkdownDoc.js';
|
|
16
15
|
import {validateType} from 'schema-markdown/lib/schema.js';
|
|
17
16
|
|
|
18
17
|
|
|
19
18
|
// The application's hash parameter type model
|
|
20
19
|
const markdownUpTypes = parseSchemaMarkdown(`\
|
|
21
|
-
#
|
|
22
|
-
# [MarkdownUp](https://github.com/craigahobbs/markdown-up#readme) is a Markdown viewer.
|
|
23
|
-
#
|
|
24
|
-
# ## Hash Parameters
|
|
25
|
-
#
|
|
26
|
-
# MarkdownUp recognizes the following hash parameters:
|
|
27
|
-
#
|
|
20
|
+
# The MarkdownUp hash parameters
|
|
28
21
|
struct MarkdownUp
|
|
29
22
|
|
|
30
23
|
# The resource URL
|
|
@@ -63,9 +56,6 @@ struct MarkdownUpSession
|
|
|
63
56
|
# A MarkdownUp application view
|
|
64
57
|
enum MarkdownUpView
|
|
65
58
|
|
|
66
|
-
# Display the hash parameters documentation
|
|
67
|
-
help
|
|
68
|
-
|
|
69
59
|
# Show the resource's Markdown text
|
|
70
60
|
markdown
|
|
71
61
|
`);
|
|
@@ -81,6 +71,7 @@ enum MarkdownUpView
|
|
|
81
71
|
* @property {?boolean} [darkMode = false] - If true, use dark mode by default
|
|
82
72
|
* @property {?number} [fontSize = 12] - The font size, in points
|
|
83
73
|
* @property {?Object} [globals = null] - Global script runtime variables
|
|
74
|
+
* @property {?string} [helpURL] - The help URL
|
|
84
75
|
* @property {?number} [lineHeight = 1.2] - The line height, in em
|
|
85
76
|
* @property {?string} [markdownText = null] - The default Markdown text
|
|
86
77
|
* @property {?boolean} [menu = true] - If true, show the menu
|
|
@@ -109,6 +100,7 @@ export class MarkdownUp {
|
|
|
109
100
|
(this.window.matchMedia && this.window.matchMedia('(prefers-color-scheme: dark)').matches);
|
|
110
101
|
this.fontSize = (options !== null ? options.fontSize : null) ?? 12;
|
|
111
102
|
this.globals = (options !== null ? options.globals : null) ?? null;
|
|
103
|
+
this.helpURL = (options !== null ? options.helpURL : null) ?? 'https://craigahobbs.github.io/markdown-up';
|
|
112
104
|
this.lineHeight = (options !== null ? options.lineHeight : null) ?? 1.2;
|
|
113
105
|
this.markdownText = (options !== null ? options.markdownText : null) ?? null;
|
|
114
106
|
this.menu = (options !== null ? options.menu : null) ?? true;
|
|
@@ -271,21 +263,6 @@ export class MarkdownUp {
|
|
|
271
263
|
const url = this.getResourceURL();
|
|
272
264
|
const scriptOptions = this.createScriptOptions();
|
|
273
265
|
|
|
274
|
-
// Help?
|
|
275
|
-
if (this.params.view === 'help') {
|
|
276
|
-
const schemaMarkdownDocOptions = {
|
|
277
|
-
'params': encodeQueryString(this.params),
|
|
278
|
-
'markdownOptions': scriptOptions.markdownOptions
|
|
279
|
-
};
|
|
280
|
-
return {
|
|
281
|
-
'title': 'MarkdownUp',
|
|
282
|
-
'elements': [
|
|
283
|
-
this.burgerElements(),
|
|
284
|
-
schemaMarkdownDoc(markdownUpTypes, 'MarkdownUp', schemaMarkdownDocOptions)
|
|
285
|
-
]
|
|
286
|
-
};
|
|
287
|
-
}
|
|
288
|
-
|
|
289
266
|
// Get the Markdown text
|
|
290
267
|
let markdownText;
|
|
291
268
|
let timeBegin;
|
|
@@ -564,7 +541,7 @@ export class MarkdownUp {
|
|
|
564
541
|
'path': 'M12,5 A4,7,0,1,0,12,19 A4,7,0,1,0,12,5 M9,9 L15,9 M9,9 L4,6 M9,12 L3,12 M9,15 L4,18 ' +
|
|
565
542
|
'M15,9 L20,6 M15,12 L21,12 M15,15 L20,18'
|
|
566
543
|
}),
|
|
567
|
-
this.
|
|
544
|
+
this.menuLink(this.helpURL, {
|
|
568
545
|
'path': 'M7,9 L7,4 L17,4 L17,12 L12,12 L12,16 M12,19 L12,22'
|
|
569
546
|
})
|
|
570
547
|
]
|
|
@@ -577,6 +554,16 @@ export class MarkdownUp {
|
|
|
577
554
|
}
|
|
578
555
|
|
|
579
556
|
|
|
557
|
+
menuLink(url, icon) {
|
|
558
|
+
return this.menuButton(
|
|
559
|
+
() => {
|
|
560
|
+
this.window.location.href = url;
|
|
561
|
+
},
|
|
562
|
+
icon
|
|
563
|
+
);
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
|
|
580
567
|
menuValueToggle(valueName, icon) {
|
|
581
568
|
icon.checked = valueName in this.paramsSession;
|
|
582
569
|
return this.menuButton(
|
package/lib/script.js
CHANGED
|
@@ -14,7 +14,7 @@ import {parseScript} from 'bare-script/lib/parser.js';
|
|
|
14
14
|
*
|
|
15
15
|
* @typedef {Object} MarkdownScriptOptions
|
|
16
16
|
* @property {number} fontSize - The font size, in points
|
|
17
|
-
* @property {Object} params - The
|
|
17
|
+
* @property {Object} params - The hash parameters object
|
|
18
18
|
* @property {Object} runtime - The [markdown-script runtime state]{@link module:lib/script.MarkdownScriptRuntime}
|
|
19
19
|
* @property {Object} [variables] - The map of variable name to variable value
|
|
20
20
|
* @property {Object} window - The web browser window object
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "markdown-up",
|
|
4
|
-
"version": "3.3.
|
|
4
|
+
"version": "3.3.4",
|
|
5
5
|
"description": "MarkdownUp is a Markdown viewer",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"markdown",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"c8": "~10.1",
|
|
33
|
-
"eslint": "~9.
|
|
33
|
+
"eslint": "~9.17",
|
|
34
34
|
"jsdoc": "~4.0",
|
|
35
35
|
"jsdom": "~25.0"
|
|
36
36
|
}
|