add support of prism plugins

4.0
A.C.Sukazyo Eyre 2023-03-28 17:54:06 +08:00
parent 1e56cbb634
commit 4d442fee37
Signed by: Eyre_S
GPG Key ID: C17CE40291207874
3 changed files with 35 additions and 6 deletions

View File

@ -11,6 +11,10 @@
<book_name>ph-Bookshelf Wiki</book_name>
<configurations>
<prism.plugins>autolinker</prism.plugins>
</configurations>
<contents>
<Page id="ph-bookshelf">the ph-Bookshelf</Page>
@ -20,8 +24,8 @@
<Chapter root="tools/">
<caption>页面选项</caption>
<Page id="code-highlight">代码高亮</Page>
<Page id="code-highlight">RegEx 高亮着色</Page>
<Page id="code-highlight"><![CDATA[<small>Prism </small>代码高亮]]></Page>
<Page id="regex-highlight">RegEx 高亮着色</Page>
</Chapter>
<Chapter>
<caption>站点配置选项</caption>

View File

@ -1,5 +1,5 @@
---
title: 代码高亮
title: 代码高亮
---
# <small>基于 Prism 的</small> 代码块高亮支持
@ -20,6 +20,18 @@ Prism 不会自动为所有代码块着色,所以不指定 `language-xxx` 即
// todo
## 添加 Prism 插件
ph-Bookshelf 还添加了可以方便的引入 Prism 的官方扩展插件的支持,你可以借此扩展代码高亮/代码块的使用方式。
只需要使用配置字段 `prism.plugins` 声明你需要的插件,每个语言名称之间通过 `;` 来分隔, ph-Bookshelf 即会自动加载这些插件。
ph-Bookshelf 可以合并不同位置的配置字段:所以在 *book.xml* 设置了 `line-numbers; autolinker`,在页面内设置了 `command-line` 后,最后在这个页面内,将会导入 `line-numbers` `autolinker` `command-line` 三个。
> 通过 `prism.plugins` 导入的插件最终将会向页面导入 `https://cdn.jsdelivr.net/npm/prismjs@v1.x/plugins/{$plugin}/prism-{$plugin}.min.js`{.lang-url} 和 `https://cdn.jsdelivr.net/npm/prismjs@v1.x/plugins/{$plugin}/prism-{$plugin}.min.css`{.lang-url} 两个文件。这在导入 Prism 官方插件的一般情况下都可以使用。
>
> 目前还没有支持从自定义 url 导入。
---
## 你知道吗

View File

@ -1,3 +1,8 @@
---
configurations:
prism.plugins: 'command-line'
---
# Web Server
[Apache]: https://httpd.apache.org/
@ -14,9 +19,17 @@ ph-Bookshelf 原始版本是在 [Apache Web Server][Apache] 环境下开发的
确认 [mod_rewrite] 已经打开。这一般可以通过以下简单的命令确认:
```shell-session
# a2enmod rewrite
```
<pre
class="command-line"
data-user="root"
data-output="2-4, 6"
><code class="lang-bash"
>a2enmod rewrite
Enabling module rewrite.
To activate the new configuration, you need to run:
service apache2 restart
a2enmod rewrite
Module rewrite already enabled</code></pre>
> 如果你使用的是旧版 Apache<small>一般存在于会被叫做 httpd 的 apache</small>module 配置或许会在服务器里,这时候,大概你的 Apache 的配置文件(通常为 `/etc/apache2/httpd.conf`{.lang-url} 或者 `/etc/httpd/httpd.conf`{.lang-url}),找到以下行并取消注释它:
>