feat(compiler): support for setting target attribute for link, fixed #230

This commit is contained in:
qingwei.li 2017-08-10 08:45:49 +08:00
commit 7f270f93c6
4 changed files with 28 additions and 0 deletions

View file

@ -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")
```

View file

@ -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")
```

View file

@ -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")
```

View file

@ -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}"`
}