markdown-up 1.8.10 → 1.9.0
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 +27 -10
- package/lib/script.js +3 -2
- package/lib/scriptLibrary.js +27 -25
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -65,8 +65,7 @@ single dependency (MarkdownUp). The "markdown-script" fenced code blocks are int
|
|
|
65
65
|
[CalcScript programming language](https://craigahobbs.github.io/calc-script/language/).
|
|
66
66
|
In addition to generating Markdown, you can fetch text and JSON resources, create SVG drawings,
|
|
67
67
|
parse CSV, render data tables, draw line charts, and more. For more information, see the
|
|
68
|
-
[MarkdownUp Library](https://craigahobbs.github.io/markdown-up/library/)
|
|
69
|
-
[CalcScript Library](https://craigahobbs.github.io/calc-script/library/).
|
|
68
|
+
[MarkdownUp Library](https://craigahobbs.github.io/markdown-up/library/).
|
|
70
69
|
|
|
71
70
|
For example:
|
|
72
71
|
|
|
@@ -81,9 +80,6 @@ helloCount = if(vCount != null, vCount, 3)
|
|
|
81
80
|
width = 200
|
|
82
81
|
height = 60
|
|
83
82
|
borderSize = 5
|
|
84
|
-
borderColor = 'red'
|
|
85
|
-
fillColor = 'blue'
|
|
86
|
-
textColor = 'white'
|
|
87
83
|
|
|
88
84
|
# Render the more/less menu
|
|
89
85
|
markdownPrint( \
|
|
@@ -94,26 +90,47 @@ markdownPrint( \
|
|
|
94
90
|
|
|
95
91
|
# Render many hellos
|
|
96
92
|
ixHello = 0
|
|
97
|
-
|
|
93
|
+
while ixHello < helloCount do
|
|
98
94
|
# Render the hello title
|
|
99
95
|
helloTitle = 'Hello #' + (ixHello + 1)
|
|
100
96
|
markdownPrint('', '## ' + helloTitle)
|
|
101
97
|
|
|
102
98
|
# Render the hello drawing
|
|
103
99
|
setDrawingSize(width, height)
|
|
104
|
-
drawStyle(
|
|
100
|
+
drawStyle('red', borderSize, 'blue')
|
|
105
101
|
drawRect(0.5 * borderSize, 0.5 * borderSize, width - borderSize, height - borderSize)
|
|
106
|
-
drawTextStyle(0.67 * height,
|
|
102
|
+
drawTextStyle(0.67 * height, 'white', true)
|
|
107
103
|
drawText(helloTitle, 0.5 * width, 0.55 * height)
|
|
108
104
|
|
|
109
105
|
ixHello = ixHello + 1
|
|
110
|
-
|
|
106
|
+
endwhile
|
|
111
107
|
~~~
|
|
112
108
|
```
|
|
113
109
|
|
|
114
110
|
Click here to [see the example in action](https://craigahobbs.github.io/markdown-up/#url=DynamicMarkdownExample.md).
|
|
115
111
|
|
|
116
112
|
|
|
113
|
+
### The MarkdownUp Include Library
|
|
114
|
+
|
|
115
|
+
MarkdownUp provides some additional functionality that can be included at runtime. Consider the
|
|
116
|
+
following example with the unit test include library:
|
|
117
|
+
|
|
118
|
+
~~~
|
|
119
|
+
include 'https://craigahobbs.github.io/markdown-up/include/unittest.mds'
|
|
120
|
+
|
|
121
|
+
function testSanity()
|
|
122
|
+
unittestEquals(1 + 1, 2)
|
|
123
|
+
endfunction
|
|
124
|
+
unittestRunTest('testSanity')
|
|
125
|
+
|
|
126
|
+
unittestReport()
|
|
127
|
+
~~~
|
|
128
|
+
|
|
129
|
+
See the
|
|
130
|
+
[MarkdownUp Include Library](https://craigahobbs.github.io/markdown-up/library/include.html)
|
|
131
|
+
documentation for more information on the available include libraries.
|
|
132
|
+
|
|
133
|
+
|
|
117
134
|
### Debug Mode
|
|
118
135
|
|
|
119
136
|
Debug mode enables logging output using the
|
|
@@ -134,8 +151,8 @@ To turn on debug mode, click the debug button in the MarkdownUp menu in the uppe
|
|
|
134
151
|
|
|
135
152
|
- [MarkdownUp Application Examples](https://craigahobbs.github.io/#url=MarkdownUpApplications.md)
|
|
136
153
|
- [The CalcScript Language](https://craigahobbs.github.io/calc-script/language/)
|
|
137
|
-
- [The CalcScript Library](https://craigahobbs.github.io/calc-script/library/)
|
|
138
154
|
- [The MarkdownUp Library](https://craigahobbs.github.io/markdown-up/library/)
|
|
155
|
+
- [The MarkdownUp Include Library](https://craigahobbs.github.io/markdown-up/library/include.html)
|
|
139
156
|
|
|
140
157
|
|
|
141
158
|
## The MarkdownUp Package
|
package/lib/script.js
CHANGED
|
@@ -65,10 +65,11 @@ export async function markdownScriptCodeBlock(codeBlock, options) {
|
|
|
65
65
|
// Run the calc-script linter?
|
|
66
66
|
if ('logFn' in options) {
|
|
67
67
|
const warnings = lintScript(script);
|
|
68
|
+
const warningPrefix = `MarkdownUp: Script static analysis...`;
|
|
68
69
|
if (warnings.length === 0) {
|
|
69
|
-
options.logFn(
|
|
70
|
+
options.logFn(`${warningPrefix} OK`);
|
|
70
71
|
} else {
|
|
71
|
-
options.logFn(
|
|
72
|
+
options.logFn(`${warningPrefix} ${warnings.length} warning${warnings.length > 1 ? 's' : ''}:`);
|
|
72
73
|
for (const warning of warnings) {
|
|
73
74
|
options.logFn(`MarkdownUp: ${warning}`);
|
|
74
75
|
}
|
package/lib/scriptLibrary.js
CHANGED
|
@@ -760,8 +760,7 @@ function elementModelWrapCallbacks(elements, options) {
|
|
|
760
760
|
}
|
|
761
761
|
|
|
762
762
|
// Element callback attribute must be map of event => callback
|
|
763
|
-
|
|
764
|
-
if (elementEvents !== null && typeof elementEvents === 'object') {
|
|
763
|
+
if ('callback' in elements) {
|
|
765
764
|
// Get the callback data, if any
|
|
766
765
|
let callbackData = null;
|
|
767
766
|
if ('callbackData' in elements) {
|
|
@@ -770,29 +769,32 @@ function elementModelWrapCallbacks(elements, options) {
|
|
|
770
769
|
}
|
|
771
770
|
|
|
772
771
|
// Wrap the event handler function
|
|
773
|
-
elements.callback
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
element
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
eventArgs
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
// Call the event handler
|
|
785
|
-
options.statementCount = 0;
|
|
786
|
-
try {
|
|
787
|
-
await elementEventCallback(eventArgs, options);
|
|
788
|
-
} catch ({message}) {
|
|
789
|
-
if ('logFn' in options) {
|
|
790
|
-
options.logFn(`MarkdownUp: Error executing elementModelRender callback: ${message}`);
|
|
772
|
+
const elementEvents = elements.callback;
|
|
773
|
+
if (elementEvents !== null) {
|
|
774
|
+
elements.callback = (element) => {
|
|
775
|
+
// On element render, add a listener for each event
|
|
776
|
+
for (const [elementEvent, elementEventCallback] of Object.entries(elementEvents)) {
|
|
777
|
+
element.addEventListener(elementEvent, async (event) => {
|
|
778
|
+
// Determine the event callback args
|
|
779
|
+
const eventArgs = [];
|
|
780
|
+
if (elementEvent === 'keydown' || elementEvent === 'keypress' || elementEvent === 'keyup') {
|
|
781
|
+
eventArgs.push(event.keyCode);
|
|
791
782
|
}
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
783
|
+
eventArgs.push(callbackData);
|
|
784
|
+
|
|
785
|
+
// Call the event handler
|
|
786
|
+
options.statementCount = 0;
|
|
787
|
+
try {
|
|
788
|
+
await elementEventCallback(eventArgs, options);
|
|
789
|
+
} catch ({message}) {
|
|
790
|
+
if ('logFn' in options) {
|
|
791
|
+
options.logFn(`MarkdownUp: Error executing elementModelRender callback: ${message}`);
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
options.runtimeUpdateFn();
|
|
795
|
+
});
|
|
796
|
+
}
|
|
797
|
+
};
|
|
798
|
+
}
|
|
797
799
|
}
|
|
798
800
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "markdown-up",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.9.0",
|
|
5
5
|
"description": "MarkdownUp is a Markdown viewer",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"markdown",
|
|
@@ -22,16 +22,16 @@
|
|
|
22
22
|
"test": "ava -v test/"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"calc-script": "~1.
|
|
25
|
+
"calc-script": "~1.4",
|
|
26
26
|
"element-model": "~1.1",
|
|
27
|
-
"markdown-model": "~1.
|
|
27
|
+
"markdown-model": "~1.8",
|
|
28
28
|
"schema-markdown": "~1.2",
|
|
29
|
-
"schema-markdown-doc": "~1.
|
|
29
|
+
"schema-markdown-doc": "~1.6"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"ava": "~5.
|
|
33
|
-
"c8": "~7.
|
|
34
|
-
"eslint": "~8.
|
|
32
|
+
"ava": "~5.2",
|
|
33
|
+
"c8": "~7.13",
|
|
34
|
+
"eslint": "~8.39",
|
|
35
35
|
"jsdoc": "~4.0",
|
|
36
36
|
"jsdom": "~21.1"
|
|
37
37
|
}
|