Skip to content

Commit

Permalink
feat: ignore to compiled link, fixed #203
Browse files Browse the repository at this point in the history
  • Loading branch information
QingWei-Li committed Jul 9, 2017
1 parent 4492c3e commit 22343ba
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 3 deletions.
24 changes: 24 additions & 0 deletions docs/de-de/helpers.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,27 @@ Generelle Tipps wie:
wird wie folgt gerendert:

?> *TODO* unit test

## Ignore to compile link

Some time we will put some other relative path to the link, you have to need to tell docsify you don't need to compile this link. For example

```md
[link](/demo/)
```


It will be compiled to `<a href="/#/demo/">link</a>` and will be loaded `/demo/README.md`. Maybe you want to jump to `/demo/index.html`.

Now you can do that

```md
[link](/demo/ ":ignore")
```
You will get `<a href="/demo/">link</a>`html. Do not worry, you can still set title for link.

```md
[link](/demo/ ":ignore title")

<a href="/demo/" title="title">link</a>
```
25 changes: 25 additions & 0 deletions docs/helpers.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,28 @@ General tips like:
are rendered as:

?> *TODO* unit test

## Ignore to compile link

Some time we will put some other relative path to the link, you have to need to tell docsify you don't need to compile this link. For example

```md
[link](/demo/)
```


It will be compiled to `<a href="/#/demo/">link</a>` and will be loaded `/demo/README.md`. Maybe you want to jump to `/demo/index.html`.

Now you can do that

```md
[link](/demo/ ":ignore")
```
You will get `<a href="/demo/">link</a>`html. Do not worry, you can still set title for link.

```md
[link](/demo/ ":ignore title")

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

25 changes: 25 additions & 0 deletions docs/zh-cn/helpers.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,28 @@ docsify 扩展了一些 Markdown 语法,可以让文档更易读。

?> *TODO* 完善示例


## Ignore to compile link

Some time we will put some other relative path to the link, you have to need to tell docsify you don't need to compile this link. For example

```md
[link](/demo/)
```


It will be compiled to `<a href="/#/demo/">link</a>` and will be loaded `/demo/README.md`. Maybe you want to jump to `/demo/index.html`.

Now you can do that

```md
[link](/demo/ ":ignore")
```
You will get `<a href="/demo/">link</a>`html. Do not worry, you can still set title for link.

```md
[link](/demo/ ":ignore title")

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

4 changes: 3 additions & 1 deletion src/core/render/compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,12 @@ export class Compiler {
}
renderer.link = function (href, title, text) {
let blank = ''
if (!/:|(\/{2})/.test(href)) {

if (!/:|(\/{2})/.test(href) && !/(\s?:ignore)(\s\S+)?$/.test(title)) {
href = router.toURL(href, null, router.getCurrentPath())
} else {
blank = ` target="${linkTarget}"`
title = title && title.replace(/:ignore/g, '').trim()
}
if (title) {
title = ` title="${title}"`
Expand Down
7 changes: 5 additions & 2 deletions src/core/router/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,19 @@ export function parseQuery (query) {
query.split('&').forEach(function (param) {
const parts = param.replace(/\+/g, ' ').split('=')

res[parts[0]] = decode(parts[1])
res[parts[0]] = parts[1] && decode(parts[1])
})

return res
}

export function stringifyQuery (obj) {
const qs = []

for (const key in obj) {
qs.push(`${encode(key)}=${encode(obj[key])}`.toLowerCase())
qs.push(obj[key]
? `${encode(key)}=${encode(obj[key])}`.toLowerCase()
: encode(key))
}

return qs.length ? `?${qs.join('&')}` : ''
Expand Down

0 comments on commit 22343ba

Please sign in to comment.