@@ -5,13 +5,13 @@ import { runParser } from 'packages/core/src/parsers/ParsingError';
5
5
import { isUrl } from 'packages/core/src/utils/Utils' ;
6
6
import { P_FilePath } from 'packages/core/src/parsers/nomParsers/GeneralNomParsers' ;
7
7
8
- const mdWikiLinkInnerParser : Parser < [ string , string | undefined , string | undefined ] > = P . sequence (
8
+ const P_MDLinkInner : Parser < [ string , string | undefined , string | undefined ] > = P . sequence (
9
9
P_FilePath , // the file path
10
10
P . string ( '#' ) . then ( P . manyNotOf ( '[]#|^:' ) ) . optional ( ) , // the optional heading
11
11
P . string ( '|' ) . then ( P . manyNotOf ( '[]' ) ) . optional ( ) , // the optional alias
12
12
) ;
13
13
14
- const mdLinkParser : Parser < MarkdownLink > = P . or (
14
+ const P_MDLink : Parser < MarkdownLink > = P . or (
15
15
// wiki links
16
16
P . sequenceMap (
17
17
( a , b ) : MarkdownLink => {
@@ -24,7 +24,7 @@ const mdLinkParser: Parser<MarkdownLink> = P.or(
24
24
} ;
25
25
} ,
26
26
P . string ( '!' ) . optional ( ) ,
27
- mdWikiLinkInnerParser . wrapString ( '[[' , ']]' ) ,
27
+ P_MDLinkInner . wrapString ( '[[' , ']]' ) ,
28
28
) ,
29
29
// standard markdown links
30
30
P . sequenceMap (
@@ -45,10 +45,7 @@ const mdLinkParser: Parser<MarkdownLink> = P.or(
45
45
) ,
46
46
) ;
47
47
48
- const mdLinkListParser : Parser < MarkdownLink [ ] > = P . separateBy (
49
- mdLinkParser ,
50
- P . string ( ',' ) . trim ( P_UTILS . optionalWhitespace ( ) ) ,
51
- ) ;
48
+ const P_MDLinkList : Parser < MarkdownLink [ ] > = P . separateBy ( P_MDLink , P . string ( ',' ) . trim ( P_UTILS . optionalWhitespace ( ) ) ) ;
52
49
53
50
export interface MarkdownLink {
54
51
isEmbed : boolean ;
@@ -60,15 +57,15 @@ export interface MarkdownLink {
60
57
61
58
export class MDLinkParser {
62
59
static parseLink ( link : string ) : MarkdownLink {
63
- return runParser ( mdLinkParser . thenEof ( ) , link ) ;
60
+ return runParser ( P_MDLink . thenEof ( ) , link ) ;
64
61
}
65
62
66
63
static parseLinkList ( link : string ) : MarkdownLink [ ] {
67
- return runParser ( mdLinkListParser . thenEof ( ) , link ) ;
64
+ return runParser ( P_MDLinkList . thenEof ( ) , link ) ;
68
65
}
69
66
70
67
static isLink ( str : string ) : boolean {
71
- return mdLinkParser . thenEof ( ) . tryParse ( str ) . success ;
68
+ return P_MDLink . thenEof ( ) . tryParse ( str ) . success ;
72
69
}
73
70
74
71
static urlToLink ( url : URL ) : MarkdownLink {
0 commit comments