markdown-up 1.8.0 → 1.8.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.
Files changed (3) hide show
  1. package/README.md +19 -4
  2. package/lib/script.js +17 -1
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -59,9 +59,9 @@ allowing you to build lightweight, client-rendered web applications with no HTML
59
59
  single dependency (MarkdownUp). The "markdown-script" fenced code blocks are interpreted as the
60
60
  [CalcScript programming language](https://craigahobbs.github.io/calc-script/language/).
61
61
  In addition to generating Markdown, you can fetch text and JSON resources, create SVG drawings,
62
- parse CSV, render data tables, draw line charts, and more. For more information, see
63
- [the MarkdownUp Library](https://craigahobbs.github.io/markdown-up/library/) and
64
- [the CalcScript Library](https://craigahobbs.github.io/calc-script/library/).
62
+ parse CSV, render data tables, draw line charts, and more. For more information, see the
63
+ [MarkdownUp Library](https://craigahobbs.github.io/markdown-up/library/) and the
64
+ [CalcScript Library](https://craigahobbs.github.io/calc-script/library/).
65
65
 
66
66
  For example:
67
67
 
@@ -107,9 +107,24 @@ jumpif (ixHello < helloCount) helloLoop
107
107
  Click here to [see the example in action](https://craigahobbs.github.io/markdown-up/#url=DynamicMarkdownExample.md).
108
108
 
109
109
 
110
+ ### Debug Mode
111
+
112
+ Debug mode enables logging output using the
113
+ [debugLog function](https://craigahobbs.github.io/calc-script/library/#var.vName='debugLog').
114
+ For example:
115
+
116
+ ~~~ calcscript
117
+ debugLog('Hello debug')
118
+ ~~~
119
+
120
+ Add the "#debug=1" hash parameter to the application URL to turn on debug mode.
121
+ Debug mode also enables the CalcScript linter, which performs static code analysis on your code and
122
+ reports warnings for any issues found.
123
+
124
+
110
125
  ### Links
111
126
 
112
- - [Dynamic Markdown Examples](https://craigahobbs.github.io/#url=MarkdownUpApplications.md)
127
+ - [MarkdownUp Application Examples](https://craigahobbs.github.io/#url=MarkdownUpApplications.md)
113
128
  - [The CalcScript Language](https://craigahobbs.github.io/calc-script/language/)
114
129
  - [The CalcScript Library](https://craigahobbs.github.io/calc-script/library/)
115
130
  - [The MarkdownUp Library](https://craigahobbs.github.io/markdown-up/library/)
package/lib/script.js CHANGED
@@ -2,6 +2,7 @@
2
2
  // https://github.com/craigahobbs/markdown-up/blob/main/LICENSE
3
3
 
4
4
  import {executeScriptAsync} from 'calc-script/lib/runtimeAsync.js';
5
+ import {lintScript} from 'calc-script/lib/model.js';
5
6
  import {markdownElements} from 'markdown-model/lib/elements.js';
6
7
  import {parseMarkdown} from 'markdown-model/lib/parser.js';
7
8
  import {parseScript} from 'calc-script/lib/parser.js';
@@ -51,7 +52,22 @@ export async function markdownScriptCodeBlock(codeBlock, options) {
51
52
  // Execute the calculation script
52
53
  let errorMessage = null;
53
54
  try {
54
- await executeScriptAsync(parseScript(codeBlock.lines, codeBlock.startLineNumber + 1), options);
55
+ // Parse the script
56
+ const script = parseScript(codeBlock.lines, codeBlock.startLineNumber + 1);
57
+
58
+ // Run the calc-script linter?
59
+ if ('logFn' in options) {
60
+ const warnings = lintScript(script);
61
+ if (warnings.length > 0) {
62
+ options.logFn(`Warnings for the script at line number ${codeBlock.startLineNumber + 1}:`);
63
+ for (const warning of warnings) {
64
+ options.logFn(` ${warning}`);
65
+ }
66
+ }
67
+ }
68
+
69
+ // Execute the script
70
+ await executeScriptAsync(script, options);
55
71
  } catch ({message}) {
56
72
  errorMessage = message;
57
73
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "markdown-up",
4
- "version": "1.8.0",
4
+ "version": "1.8.1",
5
5
  "description": "MarkdownUp is a Markdown viewer",
6
6
  "keywords": [
7
7
  "markdown",