Skip to content

Commit

Permalink
feat(compiler): support for setting target attribute for link, fixed #…
Browse files Browse the repository at this point in the history
  • Loading branch information
QingWei-Li committed Aug 10, 2017
1 parent c3a1496 commit 7f270f9
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
7 changes: 7 additions & 0 deletions docs/de-de/helpers.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,10 @@ You will get `<a href="/demo/">link</a>`html. Do not worry, you can still set ti

<a href="/demo/" title="title">link</a>
```

## Set target attribute for link

```md
[link](/demo ":target=_blank")
[link](/demo2 ":target=_self")
```
7 changes: 7 additions & 0 deletions docs/helpers.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,10 @@ You will get `<a href="/demo/">link</a>`html. Do not worry, you can still set ti
<a href="/demo/" title="title">link</a>
```

## Set target attribute for link

```md
[link](/demo ":target=_blank")
[link](/demo2 ":target=_self")
```

7 changes: 7 additions & 0 deletions docs/zh-cn/helpers.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,10 @@ You will get `<a href="/demo/">link</a>`html. Do not worry, you can still set ti
<a href="/demo/" title="title">link</a>
```


## Set target attribute for link

```md
[link](/demo ":target=_blank")
[link](/demo2 ":target=_self")
```
7 changes: 7 additions & 0 deletions src/core/render/compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,13 @@ export class Compiler {
title = title && title.replace(/:ignore/g, '').trim()
}

let target = title && title.match(/:target=\w+/)
if (target) {
target = target[0]
title = title.replace(target, '')
blank = ' ' + target.slice(1)
}

if (title) {
title = ` title="${title}"`
}
Expand Down

0 comments on commit 7f270f9

Please sign in to comment.