Skip to content

Commit 7f270f9

Browse files
committed
feat(compiler): support for setting target attribute for link, fixed #230
1 parent c3a1496 commit 7f270f9

File tree

4 files changed

+28
-0
lines changed

4 files changed

+28
-0
lines changed

Diff for: docs/de-de/helpers.md

+7
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,10 @@ You will get `<a href="/demo/">link</a>`html. Do not worry, you can still set ti
4949

5050
<a href="/demo/" title="title">link</a>
5151
```
52+
53+
## Set target attribute for link
54+
55+
```md
56+
[link](/demo ":target=_blank")
57+
[link](/demo2 ":target=_self")
58+
```

Diff for: docs/helpers.md

+7
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,10 @@ You will get `<a href="/demo/">link</a>`html. Do not worry, you can still set ti
5050
<a href="/demo/" title="title">link</a>
5151
```
5252

53+
## Set target attribute for link
54+
55+
```md
56+
[link](/demo ":target=_blank")
57+
[link](/demo2 ":target=_self")
58+
```
59+

Diff for: docs/zh-cn/helpers.md

+7
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,10 @@ You will get `<a href="/demo/">link</a>`html. Do not worry, you can still set ti
4949
<a href="/demo/" title="title">link</a>
5050
```
5151

52+
53+
## Set target attribute for link
54+
55+
```md
56+
[link](/demo ":target=_blank")
57+
[link](/demo2 ":target=_self")
58+
```

Diff for: src/core/render/compiler.js

+7
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,13 @@ export class Compiler {
105105
title = title && title.replace(/:ignore/g, '').trim()
106106
}
107107

108+
let target = title && title.match(/:target=\w+/)
109+
if (target) {
110+
target = target[0]
111+
title = title.replace(target, '')
112+
blank = ' ' + target.slice(1)
113+
}
114+
108115
if (title) {
109116
title = ` title="${title}"`
110117
}

0 commit comments

Comments
 (0)