markdown-up 2.3.4 → 2.3.6
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/lib/app.js +54 -50
- package/lib/scriptLibrary.js +2 -2
- package/package.json +1 -1
package/lib/app.js
CHANGED
|
@@ -194,13 +194,10 @@ export class MarkdownUp {
|
|
|
194
194
|
return;
|
|
195
195
|
}
|
|
196
196
|
|
|
197
|
-
// If there is a
|
|
197
|
+
// If there is a header ID, re-navigate to scroll to the header ID since it was just rendered.
|
|
198
198
|
// The re-render is short-circuited by the unchanged hash param check above.
|
|
199
|
-
if (!isError &&
|
|
199
|
+
if (!isError && getHeaderId(this.window.location.hash) !== null) {
|
|
200
200
|
this.window.location.href = this.window.location.hash;
|
|
201
|
-
} else {
|
|
202
|
-
// Otherwise, scroll to the top of the page
|
|
203
|
-
this.window.scrollTo(0, 0);
|
|
204
201
|
}
|
|
205
202
|
}
|
|
206
203
|
|
|
@@ -483,10 +480,10 @@ export class MarkdownUp {
|
|
|
483
480
|
hashParams.url = `${getBaseURL(resourceURL)}${hashParams.url}`;
|
|
484
481
|
}
|
|
485
482
|
|
|
486
|
-
// Encode hash parameters with a
|
|
483
|
+
// Encode hash parameters with a header ID
|
|
487
484
|
const paramString = encodeQueryString({...this.params, ...hashParams});
|
|
488
|
-
const
|
|
489
|
-
return `#${paramString}${
|
|
485
|
+
const headerId = getHeaderId(url);
|
|
486
|
+
return `#${paramString}${headerId !== null && paramString !== '' ? '&' : ''}${headerId !== null ? headerId : ''}`;
|
|
490
487
|
}
|
|
491
488
|
|
|
492
489
|
// Relative URL?
|
|
@@ -499,45 +496,52 @@ export class MarkdownUp {
|
|
|
499
496
|
|
|
500
497
|
|
|
501
498
|
burgerElements() {
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
'
|
|
508
|
-
'
|
|
509
|
-
'
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
// Popup menu
|
|
514
|
-
!('menu' in this.paramsSession) ? null : {
|
|
515
|
-
'html': 'div',
|
|
516
|
-
'attr': {'class': 'menu'},
|
|
517
|
-
'elem': [
|
|
518
|
-
this.menuViewToggle('markdown', {
|
|
519
|
-
'path': 'M4,2 L20,2 L20,22 L4,22 Z',
|
|
520
|
-
'path2': 'M7,7.5 L17,7.5 M7,12 L17,12 M7,16.5 L17,16.5'
|
|
521
|
-
}),
|
|
522
|
-
this.menuValueToggle('darkMode', {
|
|
523
|
-
'path': 'M16,3 A10,10,0,1,1,3,18 A14,14,0,0,0,17,3'
|
|
524
|
-
}, true),
|
|
525
|
-
this.menuValueCycle('fontSize', this.fontSize, 2, {
|
|
526
|
-
'path': 'M4,22 L10,2 L14,2 L20,22 M6,14 L18,14',
|
|
527
|
-
'strokeWidth': 4
|
|
528
|
-
}),
|
|
529
|
-
this.menuValueCycle('lineHeight', this.lineHeight, 0.2, {
|
|
530
|
-
'path2': 'M2,3 L22,3 M2,9 L22,9 M2,15 L22,15 M2,21 L22,21'
|
|
531
|
-
}),
|
|
532
|
-
this.menuValueToggle('debug', {
|
|
533
|
-
'path': 'M12,5 A4,7,0,1,0,12,19 A4,7,0,1,0,12,5 M9,9 L15,9 M9,9 L4,6 M9,12 L3,12 M9,15 L4,18 ' +
|
|
534
|
-
'M15,9 L20,6 M15,12 L21,12 M15,15 L20,18'
|
|
535
|
-
}),
|
|
536
|
-
this.menuViewToggle('help', {
|
|
537
|
-
'path': 'M7,9 L7,4 L17,4 L17,12 L12,12 L12,16 M12,19 L12,22'
|
|
499
|
+
const paramString = encodeQueryString({...this.params});
|
|
500
|
+
const topHeaderId = `${paramString}${paramString !== '' ? '&' : ''}_top`;
|
|
501
|
+
return [
|
|
502
|
+
!this.menu ? null : [
|
|
503
|
+
{
|
|
504
|
+
'html': 'div',
|
|
505
|
+
'attr': {'class': 'menu-burger'},
|
|
506
|
+
'elem': this.menuValueToggle('menu', {
|
|
507
|
+
'size': 32,
|
|
508
|
+
'noCheck': true,
|
|
509
|
+
'path': 'M3,5 L21,5 M3,12 L21,12 M3,19 L21,19'
|
|
538
510
|
})
|
|
539
|
-
|
|
540
|
-
|
|
511
|
+
},
|
|
512
|
+
|
|
513
|
+
// Popup menu
|
|
514
|
+
!('menu' in this.paramsSession) ? null : {
|
|
515
|
+
'html': 'div',
|
|
516
|
+
'attr': {'class': 'menu'},
|
|
517
|
+
'elem': [
|
|
518
|
+
this.menuViewToggle('markdown', {
|
|
519
|
+
'path': 'M4,2 L20,2 L20,22 L4,22 Z',
|
|
520
|
+
'path2': 'M7,7.5 L17,7.5 M7,12 L17,12 M7,16.5 L17,16.5'
|
|
521
|
+
}),
|
|
522
|
+
this.menuValueToggle('darkMode', {
|
|
523
|
+
'path': 'M16,3 A10,10,0,1,1,3,18 A14,14,0,0,0,17,3'
|
|
524
|
+
}, true),
|
|
525
|
+
this.menuValueCycle('fontSize', this.fontSize, 2, {
|
|
526
|
+
'path': 'M4,22 L10,2 L14,2 L20,22 M6,14 L18,14',
|
|
527
|
+
'strokeWidth': 4
|
|
528
|
+
}),
|
|
529
|
+
this.menuValueCycle('lineHeight', this.lineHeight, 0.2, {
|
|
530
|
+
'path2': 'M2,3 L22,3 M2,9 L22,9 M2,15 L22,15 M2,21 L22,21'
|
|
531
|
+
}),
|
|
532
|
+
this.menuValueToggle('debug', {
|
|
533
|
+
'path': 'M12,5 A4,7,0,1,0,12,19 A4,7,0,1,0,12,5 M9,9 L15,9 M9,9 L4,6 M9,12 L3,12 M9,15 L4,18 ' +
|
|
534
|
+
'M15,9 L20,6 M15,12 L21,12 M15,15 L20,18'
|
|
535
|
+
}),
|
|
536
|
+
this.menuViewToggle('help', {
|
|
537
|
+
'path': 'M7,9 L7,4 L17,4 L17,12 L12,12 L12,16 M12,19 L12,22'
|
|
538
|
+
})
|
|
539
|
+
]
|
|
540
|
+
}
|
|
541
|
+
],
|
|
542
|
+
|
|
543
|
+
// The top header ID
|
|
544
|
+
{'html': 'div', 'attr': {'id': topHeaderId, 'style': 'display=none; position: absolute; top: 0;'}}
|
|
541
545
|
];
|
|
542
546
|
}
|
|
543
547
|
|
|
@@ -639,13 +643,13 @@ export class MarkdownUp {
|
|
|
639
643
|
}
|
|
640
644
|
|
|
641
645
|
|
|
642
|
-
// Get a URL's
|
|
643
|
-
function
|
|
644
|
-
const matchId = url.match(
|
|
646
|
+
// Get a URL's header ID
|
|
647
|
+
function getHeaderId(url) {
|
|
648
|
+
const matchId = url.match(rHeaderId);
|
|
645
649
|
return matchId !== null ? matchId[1] : null;
|
|
646
650
|
}
|
|
647
651
|
|
|
648
|
-
const
|
|
652
|
+
const rHeaderId = /[#&]([^=]+)$/;
|
|
649
653
|
|
|
650
654
|
|
|
651
655
|
// Test if a URL is relative
|
package/lib/scriptLibrary.js
CHANGED
|
@@ -516,14 +516,14 @@ export const markdownScriptFunctions = {
|
|
|
516
516
|
// $function: markdownParse
|
|
517
517
|
// $group: Markdown
|
|
518
518
|
// $doc: Parse Markdown text
|
|
519
|
-
// $arg lines
|
|
519
|
+
// $arg lines...: The Markdown text lines (may contain nested arrays of un-split lines)
|
|
520
520
|
// $return: The [Markdown model](https://craigahobbs.github.io/markdown-model/model/#var.vName='Markdown')
|
|
521
521
|
'markdownParse': (lines) => parseMarkdown(lines.flat()),
|
|
522
522
|
|
|
523
523
|
// $function: markdownPrint
|
|
524
524
|
// $group: Markdown
|
|
525
525
|
// $doc: Render Markdown text
|
|
526
|
-
// $arg lines
|
|
526
|
+
// $arg lines...: The Markdown text lines (may contain nested arrays of un-split lines)
|
|
527
527
|
'markdownPrint': (lines, options) => {
|
|
528
528
|
const {runtime} = options;
|
|
529
529
|
runtime.setMarkdown();
|