markdown-up 3.0.1 → 3.1.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 CHANGED
@@ -69,7 +69,7 @@ parse CSV, render data tables, draw line charts, and more. For more information,
69
69
 
70
70
  For example:
71
71
 
72
- ```
72
+ ``` markdown
73
73
  # Dynamic Markdown Example
74
74
 
75
75
  ~~~ markdown-script
@@ -117,7 +117,7 @@ following example that uses the
117
117
  [unittest.mds](https://craigahobbs.github.io/markdown-up/library/include.html#var.vGroup='unittest.mds')
118
118
  system library:
119
119
 
120
- ~~~
120
+ ~~~ barescript
121
121
  include <unittest.mds>
122
122
 
123
123
  function testSanity():
package/lib/app.js CHANGED
@@ -182,23 +182,21 @@ export class MarkdownUp {
182
182
  // Render the element model
183
183
  renderElements(this.window.document.body, result.elements);
184
184
 
185
- // Focus?
186
- if ('focus' in result) {
187
- this.setDocumentFocus(result.focus);
188
- }
189
-
190
185
  // Navigate?
191
186
  // Note: This is done after render since it may have no effect (in which case we need to render)
192
187
  if ('location' in result && result.location !== null) {
193
188
  this.window.location.href = result.location;
194
- return;
195
- }
196
189
 
197
190
  // If there is a header ID, re-navigate to scroll to the header ID since it was just rendered.
198
191
  // The re-render is short-circuited by the unchanged hash param check above.
199
- if (!isError && getHeaderId(this.window.location.hash) !== null) {
192
+ } else if (!isError && getHeaderId(this.window.location.hash) !== null) {
200
193
  this.window.location.href = this.window.location.hash;
201
194
  }
195
+
196
+ // Focus?
197
+ if ('focus' in result) {
198
+ this.setDocumentFocus(result.focus);
199
+ }
202
200
  }
203
201
 
204
202
 
@@ -280,7 +278,7 @@ export class MarkdownUp {
280
278
  const urlOverride = 'url' in this.params && this.params.url !== '';
281
279
  const url = urlOverride ? this.params.url : this.url;
282
280
  const scriptOptions = this.createScriptOptions(url);
283
- let markdownText = null;
281
+ let markdownText;
284
282
  let timeBegin;
285
283
  if (this.markdownText !== null && !urlOverride) {
286
284
  ({markdownText} = this);
@@ -452,17 +450,17 @@ export class MarkdownUp {
452
450
  }
453
451
  }
454
452
 
455
- // Focus?
456
- if (runtime.documentFocus !== null) {
457
- this.setDocumentFocus(runtime.documentFocus);
458
- }
459
-
460
453
  // Navigate?
461
454
  // Note: This is done after render since it may have no effect (in which case we want to render).
462
455
  if (runtime.windowLocation !== null) {
463
456
  this.window.location.href = runtime.windowLocation;
464
457
  }
465
458
 
459
+ // Focus?
460
+ if (runtime.documentFocus !== null) {
461
+ this.setDocumentFocus(runtime.documentFocus);
462
+ }
463
+
466
464
  // Reset the runtime
467
465
  runtime.reset();
468
466
  };
@@ -937,6 +937,28 @@ const sessionStorageSetArgs = valueArgsModel([
937
937
  ]);
938
938
 
939
939
 
940
+ //
941
+ // URL functions
942
+ //
943
+
944
+
945
+ // $function: urlObjectCreate
946
+ // $group: URL
947
+ // $doc: Create an object URL (i.e. a file download URL)
948
+ // $arg data: The object data string
949
+ // $arg contentType: Optional (default is "text/plain"). The object content type.
950
+ // $return: The object URL string
951
+ function urlObjectCreate(args, options) {
952
+ const [data, contentType] = valueArgsValidate(urlObjectCreateArgs, args);
953
+ return options.window.URL.createObjectURL(new Blob([data], {'type': contentType}));
954
+ }
955
+
956
+ const urlObjectCreateArgs = valueArgsModel([
957
+ {'name': 'data', 'type': 'string'},
958
+ {'name': 'contentType', 'type': 'string', 'default': 'text/plain'}
959
+ ]);
960
+
961
+
940
962
  //
941
963
  // Window functions
942
964
  //
@@ -1075,6 +1097,7 @@ export const markdownScriptFunctions = {
1075
1097
  sessionStorageGet,
1076
1098
  sessionStorageRemove,
1077
1099
  sessionStorageSet,
1100
+ urlObjectCreate,
1078
1101
  windowHeight,
1079
1102
  windowSetLocation,
1080
1103
  windowSetResize,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "markdown-up",
4
- "version": "3.0.1",
4
+ "version": "3.1.0",
5
5
  "description": "MarkdownUp is a Markdown viewer",
6
6
  "keywords": [
7
7
  "markdown",
@@ -24,14 +24,14 @@
24
24
  "dependencies": {
25
25
  "bare-script": "~3.0",
26
26
  "element-model": "~1.1",
27
- "markdown-model": "~1.8",
27
+ "markdown-model": "~2.0",
28
28
  "schema-markdown": "~1.2",
29
- "schema-markdown-doc": "~1.6"
29
+ "schema-markdown-doc": "~1.7"
30
30
  },
31
31
  "devDependencies": {
32
- "c8": "~9.1",
33
- "eslint": "~8.57",
32
+ "c8": "~10.1",
33
+ "eslint": "~9.9",
34
34
  "jsdoc": "~4.0",
35
- "jsdom": "~24.0"
35
+ "jsdom": "~25.0"
36
36
  }
37
37
  }