-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
191 additions
and
73 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,100 @@ | ||
# Markdown Extensions | ||
|
||
[[toc]] | ||
|
||
## Links | ||
|
||
- Inbound links ending in `.md` or `.html` are converted to `<router-link>` for SPA navigation. | ||
|
||
- [Home](/) | ||
- [Setup](./setup.md#quickstart) | ||
|
||
- Outbound links automatically gets `target="_blank"`: [vuejs.org](https://vuejs.org) | ||
|
||
## Header Anchors | ||
|
||
Headers automatically get anchor links applied. | ||
|
||
## Table of Contents | ||
|
||
**Input** | ||
|
||
``` markdown | ||
[[toc]] | ||
``` | ||
|
||
**Output** | ||
|
||
[[toc]] | ||
|
||
## Custom Containers | ||
|
||
## Configuration | ||
**Input** | ||
|
||
``` markdown | ||
::: tip | ||
This is a tip | ||
::: | ||
|
||
::: warning | ||
This is a warning | ||
::: | ||
|
||
::: danger | ||
This is a dangerous thing | ||
::: | ||
``` | ||
|
||
**Output** | ||
|
||
::: tip | ||
This is a tip | ||
::: | ||
|
||
::: warning | ||
This is a warning | ||
::: | ||
|
||
::: danger | ||
This is a dangerous thing | ||
::: | ||
|
||
## Line Highlighting in Code Blocks | ||
|
||
**Input** | ||
|
||
```` markdown | ||
``` js{4} | ||
export default { | ||
data () { | ||
return { | ||
msg: 'Highlighted!' | ||
} | ||
} | ||
} | ||
``` | ||
```` | ||
|
||
**Output** | ||
|
||
``` js{4} | ||
export default { | ||
data () { | ||
return { | ||
msg: 'Highlighted!' | ||
} | ||
} | ||
} | ||
``` | ||
|
||
## Emoji | ||
|
||
**Input** | ||
|
||
``` markdown | ||
:tada: :100: | ||
``` | ||
|
||
**Output** | ||
|
||
## Syntax Highlighting | ||
:tada: :100: | ||
|
||
Highlight lines | ||
## Custom Configuration |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,31 @@ | ||
const chalk = require('chalk') | ||
const prism = require('prismjs') | ||
const loadLanguages = require('prismjs/components/index') | ||
|
||
// required to make embedded highlighting work... | ||
loadLanguages(['markup', 'css', 'javascript']) | ||
|
||
function wrap (code, lang) { | ||
return `<pre v-pre class="language-${lang}"><code>${code}</code></pre>` | ||
} | ||
|
||
module.exports = (str, lang) => { | ||
if (!lang) { | ||
return wrap(str, 'text') | ||
} | ||
if (lang === 'vue' || lang === 'html') { | ||
lang = 'markup' | ||
} | ||
if (!prism.languages[lang]) { | ||
try { | ||
loadLanguages([lang]) | ||
} catch (e) { | ||
throw new Error(`[vuepress] Syntax highlight for language "${lang}" is not supported.`) | ||
console.log(chalk.yellow(`[vuepress] Syntax highlight for language "${lang}" is not supported.`)) | ||
} | ||
} | ||
if (prism.languages[lang]) { | ||
const res = prism.highlight(str, prism.languages[lang], lang) | ||
return `<pre v-pre class="language-${lang}"><code>${res}</code></pre>` | ||
const code = prism.highlight(str, prism.languages[lang], lang) | ||
return wrap(code, lang) | ||
} | ||
return '' | ||
return wrap(str, 'text') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters