markdown-up 1.7.0 → 1.7.3
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 +43 -27
- package/lib/app.js +395 -230
- package/lib/barChart.js +5 -6
- package/lib/data.js +27 -31
- package/lib/dataTable.js +5 -6
- package/lib/lineChart.js +5 -6
- package/lib/model.js +5 -11
- package/lib/script.js +601 -178
- package/lib/util.js +19 -23
- package/package.json +7 -7
package/lib/util.js
CHANGED
|
@@ -14,30 +14,26 @@ import {renderElements} from 'element-model/lib/elementModel.js';
|
|
|
14
14
|
* [calc-script's options]{@link https://craigahobbs.github.io/calc-script/module-lib_runtime.html#~ExecuteScriptOptions}).
|
|
15
15
|
*
|
|
16
16
|
* @typedef {Object} MarkdownScriptOptions
|
|
17
|
-
* @property {number}
|
|
18
|
-
* @property {Object}
|
|
19
|
-
* @property {
|
|
20
|
-
* @property {Object} [
|
|
21
|
-
* @property {
|
|
22
|
-
* @property {
|
|
23
|
-
* @property {module:lib/util~URLFn} [urlFn] - The URL modifier function
|
|
24
|
-
* @property {Object} [variables] - The map of variable name to chart variable value
|
|
17
|
+
* @property {number} fontSize - The font size, in points
|
|
18
|
+
* @property {Object} params - The hash parameters object
|
|
19
|
+
* @property {Object} runtime - The [markdown-script runtime state]{@link module:lib/script.MarkdownScriptRuntime}
|
|
20
|
+
* @property {Object} [variables] - The map of variable name to variable value
|
|
21
|
+
* @property {Object} window - The web browser window object
|
|
22
|
+
* @property {function} runtimeUpdateFn - The [runtime update callback function]{@link module:lib/util~MarkdownScriptRuntimeUpdateFn}
|
|
25
23
|
*/
|
|
26
24
|
|
|
27
25
|
/**
|
|
28
|
-
* A
|
|
26
|
+
* A runtime update callback function
|
|
29
27
|
*
|
|
30
|
-
* @callback
|
|
31
|
-
* @param {string} url - The URL
|
|
32
|
-
* @returns {string} The modified URL
|
|
28
|
+
* @callback MarkdownScriptRuntimeUpdateFn
|
|
33
29
|
*/
|
|
34
30
|
|
|
35
31
|
/**
|
|
36
|
-
* A
|
|
32
|
+
* A URL modifier function
|
|
37
33
|
*
|
|
38
|
-
* @callback
|
|
39
|
-
* @param {string} url - The URL
|
|
40
|
-
* @
|
|
34
|
+
* @callback URLFn
|
|
35
|
+
* @param {string} url - The URL
|
|
36
|
+
* @returns {string} The modified URL
|
|
41
37
|
*/
|
|
42
38
|
|
|
43
39
|
|
|
@@ -132,11 +128,11 @@ export function parameterValue(param, minValue, maxValue) {
|
|
|
132
128
|
|
|
133
129
|
|
|
134
130
|
// Generic code block helper function
|
|
135
|
-
export function chartCodeBlock(
|
|
131
|
+
export function chartCodeBlock(codeBlock, options, validationFn, renderFn) {
|
|
136
132
|
// Decode and validate the chart model
|
|
137
|
-
let
|
|
133
|
+
let chart;
|
|
138
134
|
try {
|
|
139
|
-
|
|
135
|
+
chart = validationFn(decodeChartLines(codeBlock.lines));
|
|
140
136
|
} catch ({message}) {
|
|
141
137
|
return {'html': 'p', 'elem': {'html': 'pre', 'elem': {'text': `Error: ${message}`}}};
|
|
142
138
|
}
|
|
@@ -144,15 +140,15 @@ export function chartCodeBlock(language, lines, options, validationFn, renderFn)
|
|
|
144
140
|
// Render the chart asynchronously
|
|
145
141
|
return {
|
|
146
142
|
'html': 'p',
|
|
147
|
-
'elem': !('width' in
|
|
143
|
+
'elem': !('width' in chart) ? null : {
|
|
148
144
|
'svg': 'svg',
|
|
149
145
|
'attr': {
|
|
150
|
-
'width':
|
|
151
|
-
'height':
|
|
146
|
+
'width': chart.width,
|
|
147
|
+
'height': chart.height
|
|
152
148
|
}
|
|
153
149
|
},
|
|
154
150
|
'callback': (parent) => {
|
|
155
|
-
renderFn(
|
|
151
|
+
renderFn(chart, options).
|
|
156
152
|
then((elements) => {
|
|
157
153
|
renderElements(parent, elements);
|
|
158
154
|
}).
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "markdown-up",
|
|
4
|
-
"version": "1.7.
|
|
4
|
+
"version": "1.7.3",
|
|
5
5
|
"description": "JavaScript Markdown viewer application",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"markdown",
|
|
@@ -22,17 +22,17 @@
|
|
|
22
22
|
"test": "ava -v test/"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"calc-script": "~0
|
|
26
|
-
"element-
|
|
25
|
+
"calc-script": "~1.0",
|
|
26
|
+
"element-model": "~1.1",
|
|
27
27
|
"markdown-model": "~1.4",
|
|
28
28
|
"schema-markdown": "~1.1",
|
|
29
|
-
"schema-markdown-doc": "~1.
|
|
29
|
+
"schema-markdown-doc": "~1.4"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"ava": "~4.
|
|
32
|
+
"ava": "~4.3",
|
|
33
33
|
"c8": "~7.11",
|
|
34
|
-
"eslint": "~8.
|
|
34
|
+
"eslint": "~8.19",
|
|
35
35
|
"jsdoc": "~3.6",
|
|
36
|
-
"jsdom": "~
|
|
36
|
+
"jsdom": "~20.0"
|
|
37
37
|
}
|
|
38
38
|
}
|