markdown-up 3.11.1 → 3.12.1
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/lib/dataTable.js +2 -2
- package/lib/lineChart.js +2 -2
- package/lib/script.js +5 -5
- package/lib/scriptLibrary.js +40 -81
- package/package.json +5 -6
package/lib/dataTable.js
CHANGED
|
@@ -79,7 +79,7 @@ enum DataTableDatetimeFormat
|
|
|
79
79
|
* Validate a data table model
|
|
80
80
|
*
|
|
81
81
|
* @param {Object} dataTable - The
|
|
82
|
-
* [data table model]{@link https://craigahobbs.github.io/
|
|
82
|
+
* [data table model]{@link https://craigahobbs.github.io/bare-script/library/model.html#var.vName='DataTable'}
|
|
83
83
|
* @returns {Object}
|
|
84
84
|
* @throws [ValidationError]{@link https://craigahobbs.github.io/schema-markdown-js/module-lib_schema.ValidationError.html}
|
|
85
85
|
*/
|
|
@@ -104,7 +104,7 @@ export function validateDataTable(dataTable) {
|
|
|
104
104
|
*
|
|
105
105
|
* @param {Object[]} data - The data array
|
|
106
106
|
* @param {?Object} [dataTable = null] - The
|
|
107
|
-
* [data table model]{@link https://craigahobbs.github.io/
|
|
107
|
+
* [data table model]{@link https://craigahobbs.github.io/bare-script/library/model.html#var.vName='DataTable'}
|
|
108
108
|
* @param {?Object} [options = null] - The [data table options]{@link module:lib/dataTable~DataTableOptions}
|
|
109
109
|
* @returns {Object} The data table [element model]{@link https://github.com/craigahobbs/element-model#readme}
|
|
110
110
|
*/
|
package/lib/lineChart.js
CHANGED
|
@@ -101,7 +101,7 @@ enum LineChartDatetimeFormat
|
|
|
101
101
|
* Validate a line chart model
|
|
102
102
|
*
|
|
103
103
|
* @param {Object} lineChart - The
|
|
104
|
-
* [line chart model]{@link https://craigahobbs.github.io/
|
|
104
|
+
* [line chart model]{@link https://craigahobbs.github.io/bare-script/library/model.html#var.vName='LineChart'}
|
|
105
105
|
* @returns {Object}
|
|
106
106
|
* @throws [ValidationError]{@link https://craigahobbs.github.io/schema-markdown-js/module-lib_schema.ValidationError.html}
|
|
107
107
|
*/
|
|
@@ -174,7 +174,7 @@ const chartLineWidth = 3;
|
|
|
174
174
|
*
|
|
175
175
|
* @param {Object[]} data - The data array
|
|
176
176
|
* @param {Object} lineChart - The
|
|
177
|
-
* [line chart model]{@link https://craigahobbs.github.io/
|
|
177
|
+
* [line chart model]{@link https://craigahobbs.github.io/bare-script/library/model.html#var.vName='LineChart'}
|
|
178
178
|
* @param {?Object} [options = null] - The [line chart options]{@link module:lib/lineChart~LineChartOptions}
|
|
179
179
|
* @returns {Object} The line chart [element model]{@link https://github.com/craigahobbs/element-model#readme}
|
|
180
180
|
*/
|
package/lib/script.js
CHANGED
|
@@ -62,22 +62,22 @@ export async function markdownScriptCodeBlock(codeBlock, options) {
|
|
|
62
62
|
// Parse the script
|
|
63
63
|
const script = parseScript(codeBlock.lines, codeBlock.startLineNumber + 1);
|
|
64
64
|
|
|
65
|
+
// Execute the script
|
|
66
|
+
await executeScriptAsync(script, options);
|
|
67
|
+
|
|
65
68
|
// Run the bare-script linter?
|
|
66
69
|
if ('logFn' in options && options.debug) {
|
|
67
|
-
const warnings = lintScript(script);
|
|
70
|
+
const warnings = lintScript(script, options.globals);
|
|
68
71
|
const warningPrefix = `MarkdownUp: Script static analysis...`;
|
|
69
72
|
if (warnings.length === 0) {
|
|
70
73
|
options.logFn(`${warningPrefix} OK`);
|
|
71
74
|
} else {
|
|
72
75
|
options.logFn(`${warningPrefix} ${warnings.length} warning${warnings.length > 1 ? 's' : ''}:`);
|
|
73
76
|
for (const warning of warnings) {
|
|
74
|
-
options.logFn(`MarkdownUp:
|
|
77
|
+
options.logFn(`MarkdownUp: ${warning}`);
|
|
75
78
|
}
|
|
76
79
|
}
|
|
77
80
|
}
|
|
78
|
-
|
|
79
|
-
// Execute the script
|
|
80
|
-
await executeScriptAsync(script, options);
|
|
81
81
|
} catch ({message}) {
|
|
82
82
|
errorMessage = message;
|
|
83
83
|
}
|
package/lib/scriptLibrary.js
CHANGED
|
@@ -4,11 +4,8 @@
|
|
|
4
4
|
import {dataTableElements, validateDataTable} from './dataTable.js';
|
|
5
5
|
import {escapeMarkdownText, getMarkdownTitle, parseMarkdown} from 'markdown-model/lib/parser.js';
|
|
6
6
|
import {lineChartElements, validateLineChart} from './lineChart.js';
|
|
7
|
+
import {markdownElements, markdownHeaderId as markdownModelHeaderId} from 'markdown-model/lib/elements.js';
|
|
7
8
|
import {valueArgsModel, valueArgsValidate} from 'bare-script/lib/value.js';
|
|
8
|
-
import {encodeQueryString} from 'schema-markdown/lib/encode.js';
|
|
9
|
-
import {markdownHeaderId as markdownModelHeaderId} from 'markdown-model/lib/elements.js';
|
|
10
|
-
import {parseSchemaMarkdown} from 'schema-markdown/lib/parser.js';
|
|
11
|
-
import {schemaMarkdownDoc} from 'schema-markdown-doc/lib/schemaMarkdownDoc.js';
|
|
12
9
|
import {validateElements} from 'element-model/lib/elementModel.js';
|
|
13
10
|
|
|
14
11
|
|
|
@@ -141,8 +138,17 @@ const documentSetFocusArgs = valueArgsModel([
|
|
|
141
138
|
// $doc:
|
|
142
139
|
// $doc: myAppMain()
|
|
143
140
|
// $doc: ```
|
|
144
|
-
// $arg callback: The keydown event callback function
|
|
145
|
-
// $arg callback:
|
|
141
|
+
// $arg callback: The keydown event callback function, which takes a single `event` object that has
|
|
142
|
+
// $arg callback: the following attributes:
|
|
143
|
+
// $arg callback: - `key` - The key value (e.g., "a", "Enter", "ArrowUp")
|
|
144
|
+
// $arg callback: - `code` - The physical key code (e.g., "KeyA", "Enter")
|
|
145
|
+
// $arg callback: - `keyCode` - The legacy numeric code (e.g., 65 for 'a')
|
|
146
|
+
// $arg callback: - `ctrlKey` - If true, the control key is pressed
|
|
147
|
+
// $arg callback: - `altKey` - If true, the alt key is pressed
|
|
148
|
+
// $arg callback: - `shiftKey` - If true, the shift key is pressed
|
|
149
|
+
// $arg callback: - `metaKey` - If true, the cmd key is pressed
|
|
150
|
+
// $arg callback: - `repeat` - If true, the key is held down
|
|
151
|
+
// $arg callback: - `location` - 0=standard, 1=left, 2=right
|
|
146
152
|
function documentSetKeyDown(args, options) {
|
|
147
153
|
const [callback] = valueArgsValidate(documentSetKeyDownArgs, args);
|
|
148
154
|
const {runtime} = options;
|
|
@@ -180,42 +186,6 @@ const documentSetKeyDownArgs = valueArgsModel([
|
|
|
180
186
|
]);
|
|
181
187
|
|
|
182
188
|
|
|
183
|
-
export const documentKeyEventTypes = parseSchemaMarkdown(`\
|
|
184
|
-
group "Events"
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
# A document key event object
|
|
188
|
-
struct DocumentKeyEvent
|
|
189
|
-
|
|
190
|
-
# The key value (e.g., "a", "Enter", "ArrowUp")
|
|
191
|
-
string key
|
|
192
|
-
|
|
193
|
-
# The physical key code (e.g., "KeyA", "Enter")
|
|
194
|
-
string code
|
|
195
|
-
|
|
196
|
-
# The legacy numeric code (e.g., 65 for 'a')
|
|
197
|
-
string keyCode
|
|
198
|
-
|
|
199
|
-
# If true, the control key is pressed
|
|
200
|
-
bool ctrlKey
|
|
201
|
-
|
|
202
|
-
# If true, the alt key is pressed
|
|
203
|
-
bool altKey
|
|
204
|
-
|
|
205
|
-
# If true, the shift key is pressed
|
|
206
|
-
bool shiftKey
|
|
207
|
-
|
|
208
|
-
# If true, the cmd key is pressed
|
|
209
|
-
bool metaKey
|
|
210
|
-
|
|
211
|
-
# If true, the key is held down
|
|
212
|
-
bool repeat
|
|
213
|
-
|
|
214
|
-
# 0=standard, 1=left, 2=right
|
|
215
|
-
int location
|
|
216
|
-
`);
|
|
217
|
-
|
|
218
|
-
|
|
219
189
|
// $function: documentSetReset
|
|
220
190
|
// $group: Document
|
|
221
191
|
// $doc: Set the document reset element
|
|
@@ -883,6 +853,33 @@ const localStorageSetArgs = valueArgsModel([
|
|
|
883
853
|
//
|
|
884
854
|
|
|
885
855
|
|
|
856
|
+
// $function: markdownElements
|
|
857
|
+
// $group: Markdown
|
|
858
|
+
// $doc: Generate an element model from a Markdown model
|
|
859
|
+
// $arg markdownModel: The [Markdown model](https://craigahobbs.github.io/markdown-model/model/#var.vName='Markdown')
|
|
860
|
+
// $arg generic: Optional (default is false). If true, render markdown elements in a generic context.
|
|
861
|
+
// $return: The rendered Markdown [element model](https://github.com/craigahobbs/element-model#readme)
|
|
862
|
+
function markdownElementsFn(args, options) {
|
|
863
|
+
const [markdownModel, generic] = valueArgsValidate(markdownElementsArgs, args);
|
|
864
|
+
|
|
865
|
+
// Create the markdown-model options
|
|
866
|
+
const markdownOptions = {...options.markdownOptions};
|
|
867
|
+
delete markdownOptions.codeBlocks;
|
|
868
|
+
if (generic) {
|
|
869
|
+
delete markdownOptions.copyFn;
|
|
870
|
+
delete markdownOptions.urlFn;
|
|
871
|
+
delete markdownOptions.usedHeaderIds;
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
return markdownElements(markdownModel, markdownOptions);
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
const markdownElementsArgs = valueArgsModel([
|
|
878
|
+
{'name': 'markdownModel', 'type': 'object'},
|
|
879
|
+
{'name': 'generic', 'type': 'boolean', 'default': false}
|
|
880
|
+
]);
|
|
881
|
+
|
|
882
|
+
|
|
886
883
|
// $function: markdownEscape
|
|
887
884
|
// $group: Markdown
|
|
888
885
|
// $doc: Escape text for inclusion in Markdown text
|
|
@@ -949,44 +946,6 @@ const markdownTitleArgs = valueArgsModel([
|
|
|
949
946
|
]);
|
|
950
947
|
|
|
951
948
|
|
|
952
|
-
//
|
|
953
|
-
// Schema functions
|
|
954
|
-
//
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
// $function: schemaElements
|
|
958
|
-
// $group: Schema
|
|
959
|
-
// $doc: Get a schema type's documentation [element model](https://github.com/craigahobbs/element-model#readme).
|
|
960
|
-
// $doc: Render the element model with the [elementModelRender](#var.vName='elementModelRender') function.
|
|
961
|
-
// $arg types: The [type model](https://craigahobbs.github.io/schema-markdown-doc/doc/#var.vName='Types')
|
|
962
|
-
// $arg typeName: The type name
|
|
963
|
-
// $arg actionURLs: Optional (default is null). The
|
|
964
|
-
// $arg actionURLs: [action URL overrides](https://craigahobbs.github.io/schema-markdown-doc/doc/#var.vName='ActionURL').
|
|
965
|
-
// $arg actionCustom: Optional (default is false). If true, the action has a custom response.
|
|
966
|
-
// $return: The schema type's documentation [element model](https://github.com/craigahobbs/element-model#readme)
|
|
967
|
-
function schemaElements(args, options) {
|
|
968
|
-
const [types, typeName, actionURLs = null, actionCustom] = valueArgsValidate(schemaElementsArgs, args);
|
|
969
|
-
const schemaOptions = {
|
|
970
|
-
'params': encodeQueryString(options.params),
|
|
971
|
-
'markdownOptions': options.markdownOptions
|
|
972
|
-
};
|
|
973
|
-
if (actionURLs !== null) {
|
|
974
|
-
schemaOptions.actionURLs = actionURLs;
|
|
975
|
-
}
|
|
976
|
-
if (actionCustom) {
|
|
977
|
-
schemaOptions.actionCustom = true;
|
|
978
|
-
}
|
|
979
|
-
return schemaMarkdownDoc(types, typeName, schemaOptions);
|
|
980
|
-
}
|
|
981
|
-
|
|
982
|
-
const schemaElementsArgs = valueArgsModel([
|
|
983
|
-
{'name': 'types', 'type': 'object'},
|
|
984
|
-
{'name': 'typeName', 'type': 'string'},
|
|
985
|
-
{'name': 'actionURLs', 'type': 'array', 'nullable': true},
|
|
986
|
-
{'name': 'actionCustom', 'type': 'boolean', 'default': false}
|
|
987
|
-
]);
|
|
988
|
-
|
|
989
|
-
|
|
990
949
|
//
|
|
991
950
|
// Session storage functions
|
|
992
951
|
//
|
|
@@ -1223,12 +1182,12 @@ export const markdownScriptFunctions = {
|
|
|
1223
1182
|
localStorageGet,
|
|
1224
1183
|
localStorageRemove,
|
|
1225
1184
|
localStorageSet,
|
|
1185
|
+
'markdownElements': markdownElementsFn,
|
|
1226
1186
|
markdownEscape,
|
|
1227
1187
|
markdownHeaderId,
|
|
1228
1188
|
markdownParse,
|
|
1229
1189
|
markdownPrint,
|
|
1230
1190
|
markdownTitle,
|
|
1231
|
-
schemaElements,
|
|
1232
1191
|
sessionStorageClear,
|
|
1233
1192
|
sessionStorageGet,
|
|
1234
1193
|
sessionStorageRemove,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "markdown-up",
|
|
4
|
-
"version": "3.
|
|
4
|
+
"version": "3.12.1",
|
|
5
5
|
"description": "MarkdownUp is a Markdown viewer",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"markdown",
|
|
@@ -22,16 +22,15 @@
|
|
|
22
22
|
"test": "node --test test/"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"bare-script": "~3.
|
|
25
|
+
"bare-script": "~3.8",
|
|
26
26
|
"element-model": "~1.2",
|
|
27
27
|
"markdown-model": "~2.2",
|
|
28
|
-
"schema-markdown": "~1.2"
|
|
29
|
-
"schema-markdown-doc": "~2.1"
|
|
28
|
+
"schema-markdown": "~1.2"
|
|
30
29
|
},
|
|
31
30
|
"devDependencies": {
|
|
32
31
|
"c8": "~10.1",
|
|
33
|
-
"eslint": "~9.
|
|
32
|
+
"eslint": "~9.39",
|
|
34
33
|
"jsdoc": "~4.0",
|
|
35
|
-
"jsdom": "~27.
|
|
34
|
+
"jsdom": "~27.1"
|
|
36
35
|
}
|
|
37
36
|
}
|