@@ -7,6 +7,8 @@ import { emojify } from './emojify'
7
7
import { isAbsolutePath , getPath } from '../router/util'
8
8
import { isFn , merge , cached } from '../util/core'
9
9
10
+ const cachedLinks = { }
11
+
10
12
export class Compiler {
11
13
constructor ( config , router ) {
12
14
this . config = config
@@ -42,6 +44,19 @@ export class Compiler {
42
44
} )
43
45
}
44
46
47
+ matchNotCompileLink ( link ) {
48
+ const links = this . config . noCompileLinks
49
+
50
+ for ( var i = 0 ; i < links . length ; i ++ ) {
51
+ const n = links [ i ]
52
+ const re = cachedLinks [ n ] || ( cachedLinks [ n ] = new RegExp ( `^${ n } $` ) )
53
+
54
+ if ( re . test ( link ) ) {
55
+ return link
56
+ }
57
+ }
58
+ }
59
+
45
60
_initRenderer ( ) {
46
61
const renderer = new marked . Renderer ( )
47
62
const { linkTarget, router, contentBase } = this
@@ -80,11 +95,16 @@ export class Compiler {
80
95
}
81
96
renderer . link = function ( href , title , text ) {
82
97
let blank = ''
83
- if ( ! / : | ( \/ { 2 } ) / . test ( href ) ) {
98
+
99
+ if ( ! / : | ( \/ { 2 } ) / . test ( href )
100
+ && ! _self . matchNotCompileLink ( href )
101
+ && ! / ( \s ? : i g n o r e ) ( \s \S + ) ? $ / . test ( title ) ) {
84
102
href = router . toURL ( href , null , router . getCurrentPath ( ) )
85
103
} else {
86
104
blank = ` target="${ linkTarget } "`
105
+ title = title && title . replace ( / : i g n o r e / g, '' ) . trim ( )
87
106
}
107
+
88
108
if ( title ) {
89
109
title = ` title="${ title } "`
90
110
}
0 commit comments