Docsify 代码高亮
跳到导航
跳到搜索
docsify内置的代码高亮工具是 Prism。Prism 默认支持的语言如下:
- Markup -
markup
,html
,xml
,svg
,mathml
,ssml
,atom
,rss
- CSS -
css
- C-like -
clike
- JavaScript -
javascript
,js
<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>
要使用语法高亮,需要在代码块第一行添加对应的语言声明,示例如下:
```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; } ```
上面代码的渲染结果:
<p>This is a paragraph</p>
<a href="//docsify.js.org/">Docsify</a>
echo "hello"
function getAdder(int $x): int
{
return 123;
}