markdown-up 1.8.6 → 1.8.7
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 +9 -7
- package/lib/app.js +16 -2
- package/lib/script.js +5 -1
- package/lib/scriptLibrary.js +4 -3
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -66,17 +66,19 @@ parse CSV, render data tables, draw line charts, and more. For more information,
|
|
|
66
66
|
For example:
|
|
67
67
|
|
|
68
68
|
```
|
|
69
|
-
#
|
|
69
|
+
# Dynamic Markdown Example
|
|
70
70
|
|
|
71
71
|
~~~ markdown-script
|
|
72
72
|
# Variable arguments
|
|
73
|
-
helloCount = if(vCount != null, vCount,
|
|
73
|
+
helloCount = if(vCount != null, vCount, 3)
|
|
74
74
|
|
|
75
75
|
# Constants
|
|
76
|
-
width =
|
|
77
|
-
height =
|
|
76
|
+
width = 200
|
|
77
|
+
height = 60
|
|
78
78
|
borderSize = 5
|
|
79
|
-
borderColor = '
|
|
79
|
+
borderColor = 'red'
|
|
80
|
+
fillColor = 'blue'
|
|
81
|
+
textColor = 'white'
|
|
80
82
|
|
|
81
83
|
# Render the more/less menu
|
|
82
84
|
markdownPrint( \
|
|
@@ -94,9 +96,9 @@ helloLoop:
|
|
|
94
96
|
|
|
95
97
|
# Render the hello drawing
|
|
96
98
|
setDrawingSize(width, height)
|
|
97
|
-
drawStyle(borderColor, borderSize)
|
|
99
|
+
drawStyle(borderColor, borderSize, fillColor)
|
|
98
100
|
drawRect(0.5 * borderSize, 0.5 * borderSize, width - borderSize, height - borderSize)
|
|
99
|
-
drawTextStyle(0.67 * height,
|
|
101
|
+
drawTextStyle(0.67 * height, textColor, true)
|
|
100
102
|
drawText(helloTitle, 0.5 * width, 0.55 * height)
|
|
101
103
|
|
|
102
104
|
ixHello = ixHello + 1
|
package/lib/app.js
CHANGED
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
|
|
6
6
|
import {MarkdownScriptRuntime, markdownScriptCodeBlock} from './script.js';
|
|
7
7
|
import {decodeQueryString, encodeQueryString} from 'schema-markdown/lib/encode.js';
|
|
8
|
-
import {getBaseURL, isRelativeURL, markdownElementsAsync} from 'markdown-model/lib/elements.js';
|
|
9
8
|
import {getMarkdownTitle, parseMarkdown} from 'markdown-model/lib/parser.js';
|
|
10
9
|
import {evaluateExpression} from 'calc-script/lib/runtime.js';
|
|
10
|
+
import {markdownElementsAsync} from 'markdown-model/lib/elements.js';
|
|
11
11
|
import {markdownScriptFunctions} from './scriptLibrary.js';
|
|
12
12
|
import {parseExpression} from 'calc-script/lib/parser.js';
|
|
13
13
|
import {parseSchemaMarkdown} from 'schema-markdown/lib/parser.js';
|
|
@@ -19,7 +19,7 @@ import {validateType} from 'schema-markdown/lib/schema.js';
|
|
|
19
19
|
// The application's hash parameter type model
|
|
20
20
|
const markdownUpTypes = parseSchemaMarkdown(`\
|
|
21
21
|
#
|
|
22
|
-
# [MarkdownUp](https://
|
|
22
|
+
# [MarkdownUp](https://github.com/craigahobbs/markdown-up#readme) is a Markdown viewer.
|
|
23
23
|
#
|
|
24
24
|
# ## Hash Parameters
|
|
25
25
|
#
|
|
@@ -610,3 +610,17 @@ function getHashID(url) {
|
|
|
610
610
|
}
|
|
611
611
|
|
|
612
612
|
const rHashId = /[#&]([^=]+)$/;
|
|
613
|
+
|
|
614
|
+
|
|
615
|
+
// Test if a URL is relative
|
|
616
|
+
function isRelativeURL(url) {
|
|
617
|
+
return !rNotRelativeURL.test(url);
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
const rNotRelativeURL = /^(?:[a-z]+:|\/|\?|#)/;
|
|
621
|
+
|
|
622
|
+
|
|
623
|
+
// Get a URL's base URL
|
|
624
|
+
function getBaseURL(url) {
|
|
625
|
+
return url.slice(0, url.lastIndexOf('/') + 1);
|
|
626
|
+
}
|
package/lib/script.js
CHANGED
|
@@ -259,7 +259,11 @@ export class MarkdownScriptRuntime {
|
|
|
259
259
|
finishMarkdown() {
|
|
260
260
|
if (this.markdown !== null) {
|
|
261
261
|
const markdownOptions = {'headerIds': true, 'urlFn': this.options.urlFn};
|
|
262
|
-
|
|
262
|
+
try {
|
|
263
|
+
this.addElements(markdownElements(parseMarkdown(this.markdown), markdownOptions));
|
|
264
|
+
} catch {
|
|
265
|
+
// Do nothing
|
|
266
|
+
}
|
|
263
267
|
this.markdown = null;
|
|
264
268
|
}
|
|
265
269
|
}
|
package/lib/scriptLibrary.js
CHANGED
|
@@ -5,10 +5,10 @@ import {
|
|
|
5
5
|
addCalculatedField, aggregateData, filterData, joinData, parseCSV, sortData, topData, validateAggregation, validateData
|
|
6
6
|
} from './data.js';
|
|
7
7
|
import {dataTableElements, validateDataTable} from './dataTable.js';
|
|
8
|
-
import {escapeMarkdownText,
|
|
9
|
-
import {getMarkdownTitle, parseMarkdown} from 'markdown-model/lib/parser.js';
|
|
8
|
+
import {escapeMarkdownText, getMarkdownTitle, parseMarkdown} from 'markdown-model/lib/parser.js';
|
|
10
9
|
import {lineChartElements, validateLineChart} from './lineChart.js';
|
|
11
10
|
import {encodeQueryString} from 'schema-markdown/lib/encode.js';
|
|
11
|
+
import {markdownHeaderId} from 'markdown-model/lib/elements.js';
|
|
12
12
|
import {schemaMarkdownDoc} from 'schema-markdown-doc/lib/schemaMarkdownDoc.js';
|
|
13
13
|
import {validateElements} from 'element-model/lib/elementModel.js';
|
|
14
14
|
|
|
@@ -647,7 +647,8 @@ export const markdownScriptFunctions = {
|
|
|
647
647
|
|
|
648
648
|
// $function: schemaElements
|
|
649
649
|
// $group: Schema
|
|
650
|
-
// $doc:
|
|
650
|
+
// $doc: Get a schema type's documentation [element model](https://github.com/craigahobbs/element-model#readme).
|
|
651
|
+
// $doc: Render the element model with the [elementModelRender](#var.vName='elementModelRender') function.
|
|
651
652
|
// $arg types: The [type model](https://craigahobbs.github.io/schema-markdown-doc/doc/#var.vName='Types')
|
|
652
653
|
// $arg typeName: The type name
|
|
653
654
|
// $arg actionURLs: Optional (default is null). The
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "markdown-up",
|
|
4
|
-
"version": "1.8.
|
|
4
|
+
"version": "1.8.7",
|
|
5
5
|
"description": "MarkdownUp is a Markdown viewer",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"markdown",
|
|
@@ -24,15 +24,15 @@
|
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"calc-script": "~1.3",
|
|
26
26
|
"element-model": "~1.1",
|
|
27
|
-
"markdown-model": "~1.
|
|
27
|
+
"markdown-model": "~1.7",
|
|
28
28
|
"schema-markdown": "~1.2",
|
|
29
29
|
"schema-markdown-doc": "~1.5"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"ava": "~
|
|
32
|
+
"ava": "~5.0",
|
|
33
33
|
"c8": "~7.12",
|
|
34
|
-
"eslint": "~8.
|
|
35
|
-
"jsdoc": "~
|
|
34
|
+
"eslint": "~8.27",
|
|
35
|
+
"jsdoc": "~4.0",
|
|
36
36
|
"jsdom": "~20.0"
|
|
37
37
|
}
|
|
38
38
|
}
|