Skip to content

Commit a2c3166

Browse files
committed
fix markdown link parser not handling section links
1 parent f5b0049 commit a2c3166

File tree

2 files changed

+74
-1
lines changed

2 files changed

+74
-1
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
## This is a Heading at the Top
2+
3+
```meta-bind-button
4+
label: Scroll to Middle
5+
style: default
6+
actions:
7+
- type: open
8+
link: "[[#This is a Heading in the Middle]]"
9+
newTab: false
10+
11+
```
12+
13+
some
14+
15+
very
16+
17+
long
18+
19+
text
20+
21+
some
22+
23+
very
24+
25+
long
26+
27+
text
28+
29+
## This is a Heading in the Middle
30+
31+
some
32+
33+
very
34+
35+
long
36+
37+
text
38+
39+
some
40+
41+
very
42+
43+
long
44+
45+
text
46+
47+
some
48+
49+
very
50+
51+
long
52+
53+
text
54+
55+
some
56+
57+
very
58+
59+
long
60+
61+
text
62+
63+
## This is a Heading at the Bottom
64+
65+
66+
Some Secion
67+
^section-1

packages/core/src/parsers/MarkdownLinkParser.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@ import { isUrl, openURL } from 'packages/core/src/utils/Utils';
88

99
const P_MDLinkInner: Parser<[string, string | undefined, string | undefined]> = P.sequence(
1010
P_FilePath, // the file path
11-
P.string('#').then(P.manyNotOf('[]#|^:')).optional(), // the optional heading
11+
P.or(
12+
P.string('#^')
13+
.then(P.manyNotOf('[]#|^:'))
14+
.map(x => '^' + x), // the optional block
15+
P.string('#').then(P.manyNotOf('[]#|^:')), // the optional heading
16+
P.succeed(undefined),
17+
),
1218
P.string('|').then(P.manyNotOf('[]')).optional(), // the optional alias
1319
);
1420

0 commit comments

Comments
 (0)