mirror of
https://gitee.com/docsifyjs/docsify.git
synced 2024-11-30 02:58:37 +08:00
88f8a8003c
Proposed changes described in comment from #1251
54 lines
1.2 KiB
Markdown
54 lines
1.2 KiB
Markdown
# Language highlighting
|
|
|
|
Docsify uses [Prism](https://prismjs.com) to highlight code blocks in your pages. Prism supports the following languages by default:
|
|
|
|
* Markup - `markup`, `html`, `xml`, `svg`, `mathml`, `ssml`, `atom`, `rss`
|
|
* CSS - `css`
|
|
* C-like - `clike`
|
|
* JavaScript - `javascript`, `js`
|
|
|
|
Support for [additional languages](https://prismjs.com/#supported-languages) is available by loading the language-specific [grammar files](https://cdn.jsdelivr.net/npm/prismjs@1/components/) via CDN:
|
|
|
|
```html
|
|
<script src="//cdn.jsdelivr.net/npm/prismjs@1/components/prism-bash.min.js"></script>
|
|
<script src="//cdn.jsdelivr.net/npm/prismjs@1/components/prism-php.min.js"></script>
|
|
```
|
|
|
|
To enable syntax highlighting, wrap each code block in triple backticks with the [language](https://prismjs.com/#supported-languages) specified on the first line:
|
|
|
|
````
|
|
```html
|
|
<p>This is a paragraph</p>
|
|
<a href="//docsify.js.org/">Docsify</a>
|
|
```
|
|
|
|
```bash
|
|
echo "hello"
|
|
```
|
|
|
|
```php
|
|
function getAdder(int $x): int
|
|
{
|
|
return 123;
|
|
}
|
|
```
|
|
````
|
|
|
|
The above markdown will be rendered as:
|
|
|
|
```html
|
|
<p>This is a paragraph</p>
|
|
<a href="//docsify.js.org/">Docsify</a>
|
|
```
|
|
|
|
```bash
|
|
echo "hello"
|
|
```
|
|
|
|
```php
|
|
function getAdder(int $x): int
|
|
{
|
|
return 123;
|
|
}
|
|
```
|