markdown-up 2.3.0 → 2.3.2
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 +4 -2
- package/lib/app.js +3 -3
- package/lib/dataTable.js +23 -10
- package/lib/scriptLibrary.js +8 -8
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -113,13 +113,15 @@ Click here to [see the example in action](https://craigahobbs.github.io/markdown
|
|
|
113
113
|
### The MarkdownUp Include Library
|
|
114
114
|
|
|
115
115
|
MarkdownUp provides some additional functionality that can be included at runtime. Consider the
|
|
116
|
-
following example
|
|
116
|
+
following example that uses the
|
|
117
|
+
[unittest.mds](https://craigahobbs.github.io/markdown-up/library/include.html#var.vGroup='unittest.mds')
|
|
118
|
+
system library:
|
|
117
119
|
|
|
118
120
|
~~~
|
|
119
121
|
include <unittest.mds>
|
|
120
122
|
|
|
121
123
|
function testSanity():
|
|
122
|
-
|
|
124
|
+
unittestEqual(1 + 1, 2)
|
|
123
125
|
endfunction
|
|
124
126
|
unittestRunTest('testSanity')
|
|
125
127
|
|
package/lib/app.js
CHANGED
|
@@ -194,9 +194,9 @@ export class MarkdownUp {
|
|
|
194
194
|
return;
|
|
195
195
|
}
|
|
196
196
|
|
|
197
|
-
// If
|
|
198
|
-
// first render, re-render is short-circuited by the unchanged hash param check above.
|
|
199
|
-
if (!isError &&
|
|
197
|
+
// If the window location hash exists in the document, re-navigate there since it was just rendered.
|
|
198
|
+
// After the first render, re-render is short-circuited by the unchanged hash param check above.
|
|
199
|
+
if (!isError && this.window.document.getElementById(this.window.location.hash.slice(1)) !== null) {
|
|
200
200
|
this.window.location.href = this.window.location.hash;
|
|
201
201
|
}
|
|
202
202
|
}
|
package/lib/dataTable.js
CHANGED
|
@@ -41,12 +41,15 @@ struct DataTable
|
|
|
41
41
|
# A data table field formatting model
|
|
42
42
|
struct DataTableFieldFormat
|
|
43
43
|
|
|
44
|
-
# If true, format the field as Markdown
|
|
45
|
-
optional bool markdown
|
|
46
|
-
|
|
47
44
|
# The field alignment
|
|
48
45
|
optional DataTableFieldAlignment align
|
|
49
46
|
|
|
47
|
+
# If true, don't wrap text
|
|
48
|
+
optional bool nowrap
|
|
49
|
+
|
|
50
|
+
# If true, format the field as Markdown
|
|
51
|
+
optional bool markdown
|
|
52
|
+
|
|
50
53
|
|
|
51
54
|
# A field alignment
|
|
52
55
|
enum DataTableFieldAlignment
|
|
@@ -134,7 +137,7 @@ export function dataTableElements(data, dataTable = null, options = null) {
|
|
|
134
137
|
const fieldFormat = (fieldFormats !== null ? (fieldFormats[field] ?? null) : null);
|
|
135
138
|
return {
|
|
136
139
|
'html': 'th',
|
|
137
|
-
'attr': (fieldFormat
|
|
140
|
+
'attr': createFieldAttr(fieldFormat),
|
|
138
141
|
'elem': {'text': field}
|
|
139
142
|
};
|
|
140
143
|
}),
|
|
@@ -142,7 +145,7 @@ export function dataTableElements(data, dataTable = null, options = null) {
|
|
|
142
145
|
const fieldFormat = (fieldFormats !== null ? (fieldFormats[field] ?? null) : null);
|
|
143
146
|
return {
|
|
144
147
|
'html': 'th',
|
|
145
|
-
'attr': (fieldFormat
|
|
148
|
+
'attr': createFieldAttr(fieldFormat),
|
|
146
149
|
'elem': {'text': field}
|
|
147
150
|
};
|
|
148
151
|
})
|
|
@@ -170,9 +173,8 @@ export function dataTableElements(data, dataTable = null, options = null) {
|
|
|
170
173
|
: {'text': formatValue(value, formatPrecision, formatDatetime, formatTrim)};
|
|
171
174
|
return {
|
|
172
175
|
'html': 'td',
|
|
173
|
-
'attr': fieldFormat
|
|
174
|
-
|
|
175
|
-
'elem': skip ? null : fieldElements
|
|
176
|
+
'attr': createFieldAttr(fieldFormat),
|
|
177
|
+
'elem': (skip ? null : fieldElements)
|
|
176
178
|
};
|
|
177
179
|
}),
|
|
178
180
|
tableFields.map((field) => {
|
|
@@ -183,8 +185,7 @@ export function dataTableElements(data, dataTable = null, options = null) {
|
|
|
183
185
|
: {'text': formatValue(value, formatPrecision, formatDatetime, formatTrim)};
|
|
184
186
|
return {
|
|
185
187
|
'html': 'td',
|
|
186
|
-
'attr': fieldFormat
|
|
187
|
-
? {'style': `text-align: ${fieldFormat.align}`} : null,
|
|
188
|
+
'attr': createFieldAttr(fieldFormat),
|
|
188
189
|
'elem': fieldElements
|
|
189
190
|
};
|
|
190
191
|
})
|
|
@@ -194,3 +195,15 @@ export function dataTableElements(data, dataTable = null, options = null) {
|
|
|
194
195
|
]
|
|
195
196
|
};
|
|
196
197
|
}
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
function createFieldAttr(fieldFormat) {
|
|
201
|
+
const fieldStyles = [];
|
|
202
|
+
if (fieldFormat !== null && 'align' in fieldFormat) {
|
|
203
|
+
fieldStyles.push(`text-align: ${fieldFormat.align}`);
|
|
204
|
+
}
|
|
205
|
+
if (fieldFormat !== null && fieldFormat.nowrap) {
|
|
206
|
+
fieldStyles.push('white-space: nowrap');
|
|
207
|
+
}
|
|
208
|
+
return (fieldStyles.length ? {'style': fieldStyles.join('; ')} : null);
|
|
209
|
+
}
|
package/lib/scriptLibrary.js
CHANGED
|
@@ -398,7 +398,7 @@ export const markdownScriptFunctions = {
|
|
|
398
398
|
// $doc: Compute the text's height to fit the width
|
|
399
399
|
// $arg text: The text
|
|
400
400
|
// $arg width: The width of the text. If 0, the default font size (in pixels) is returned.
|
|
401
|
-
// $return: The text's height
|
|
401
|
+
// $return: The text's height, in pixels
|
|
402
402
|
'drawTextHeight': ([text, width], options) => (width > 0 ? width / (fontWidthRatio * text.length) : options.runtime.drawingFontSizePx),
|
|
403
403
|
|
|
404
404
|
// $function: drawTextStyle
|
|
@@ -423,7 +423,7 @@ export const markdownScriptFunctions = {
|
|
|
423
423
|
// $doc: Compute the text's width
|
|
424
424
|
// $arg text: The text
|
|
425
425
|
// $arg fontSizePx: The text font size, in pixels
|
|
426
|
-
// $return: The text's width
|
|
426
|
+
// $return: The text's width, in pixels
|
|
427
427
|
'drawTextWidth': ([text, fontSizePx]) => fontWidthRatio * fontSizePx * text.length,
|
|
428
428
|
|
|
429
429
|
// $function: drawVLine
|
|
@@ -479,6 +479,12 @@ export const markdownScriptFunctions = {
|
|
|
479
479
|
// $return: The local storage value string or null if the key does not exist
|
|
480
480
|
'localStorageGet': ([key], options) => options.window.localStorage.getItem(key),
|
|
481
481
|
|
|
482
|
+
// $function: localStorageRemove
|
|
483
|
+
// $group: Local Storage
|
|
484
|
+
// $doc: Remove a browser local storage key
|
|
485
|
+
// $arg key: The key string
|
|
486
|
+
'localStorageRemove': ([key], options) => options.window.localStorage.removeItem(key),
|
|
487
|
+
|
|
482
488
|
// $function: localStorageSet
|
|
483
489
|
// $group: Local Storage
|
|
484
490
|
// $doc: Set a browser local storage key's value
|
|
@@ -486,12 +492,6 @@ export const markdownScriptFunctions = {
|
|
|
486
492
|
// $arg value: The value string
|
|
487
493
|
'localStorageSet': ([key, value], options) => options.window.localStorage.setItem(key, value),
|
|
488
494
|
|
|
489
|
-
// $function: localStorageRemove
|
|
490
|
-
// $group: Local Storage
|
|
491
|
-
// $doc: Remove a browser local storage key
|
|
492
|
-
// $arg key: The key string
|
|
493
|
-
'localStorageRemove': ([key], options) => options.window.localStorage.removeItem(key),
|
|
494
|
-
|
|
495
495
|
|
|
496
496
|
//
|
|
497
497
|
// Markdown functions
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "markdown-up",
|
|
4
|
-
"version": "2.3.
|
|
4
|
+
"version": "2.3.2",
|
|
5
5
|
"description": "MarkdownUp is a Markdown viewer",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"markdown",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"c8": "~8.0",
|
|
33
|
-
"eslint": "~8.
|
|
33
|
+
"eslint": "~8.50",
|
|
34
34
|
"jsdoc": "~4.0",
|
|
35
35
|
"jsdom": "~22.1"
|
|
36
36
|
}
|