gtibook 插件 代码块(2)

简介: gtibook 插件 代码块(2)

5. prism-themes 插件

当使用gitbook-plugin-prism时,prism-themes 插件提供了额外的主题。

5.1 安装

npm i gitbook-plugin-prism-themes

或者

gitbook install

5.2 配置

{
  "plugins": ["-highlight", "prism", "prism-themes"]
}
"pluginsConfig": {  
  "prism": {
    "css": [
      "prism-themes/themes/prism-duotone-dark.css"
    ]
  }
}

5.3 效果

6. ACE 插件

ACE插件是使 GitBook 支持ace 。

6.1 安装

npm i gitbook-plugin-ace

6.2 配置

默认情况下,line-height 为 1,会使代码显得比较挤,而作者好像没提供修改行高的选项,如果需要修改行高,可以到 node_modules -> github-plugin-ace -> assets -> ace.js 中加入下面两行代码 (30 行左右的位置):

editor.container.style.lineHeight = 1.25;
editor.renderer.updateFontSize();

不过上面的做法有个问题就是,每次使用 gitbook install 安装新的插件之后,代码又会重置为原来的样子。另外可以在 website.css 中加入下面的 css 代码来指定 ace 字体的大小

.aceCode {
  font-size: 14px !important;
}

使用插件:

"plugins": [
    "ace"
]

使用示例:

// This is a hello world program for C.
#include <stdio.h>
int main(){
  printf("Hello World!");
  return 1;
}

6.3 效果

略

7. Terminal 插件

Terminal 插件功能是模拟终端显示,主要用于显示命令以及多行输出,不过写起来有些麻烦。

7.1 安装

npm i gitbook-plugin-terminal

7.2 配置

terminal 支持下面 5 种样式,如果需要更换样式,在 pluginsConfig 里配置即可。


black: Just that good old black terminal everybody loves.

classic: Looking for green color font over a black background? This is for you.

flat: Oh, flat colors. I love flat colors. Everything looks modern with them.

ubuntu: Admit it or not, but Ubuntu have a good looking terminal.

white: Make your terminal to blend in with your GitBook.

book.json配置:

{
    "plugins": [
        "terminal"
    ],
    "pluginsConfig": {
        "terminal": {
            "copyButtons": true,
            "fade": false,
            "style": "flat"
        }
    }
}

现在支持 6 种标签:

command: Command "executed" in the terminal.
delimiter: Sequence of characters between the prompt and the command.
error: Error message.
path: Directory path shown in the prompt.
prompt: Prompt of the user.
warning: Warning message.

标签的使用格式如下所示:

**[<tag_name> 内容]

为了使标签正常工作,需要在代码块的第一行加入 **[termial] 标记,下面是一个完整的示例:

**[terminal]
**[prompt foo@joe]**[path ~]**[delimiter  $ ]**[command ./myscript]
Normal output line. Nothing special here...
But...
You can add some colors. What about a warning message?
**[warning [WARNING] The color depends on the theme. Could look normal too]
What about an error message?
**[error [ERROR] This is not the error you are looking for]

7.3 效果

略

8. codesnippet 插件

codesnippet 插件可以轻松导入代码文件或在 GitBook 的代码块中使用变量。

8.1 安装

npm i gitbook-plugin-codesnippet

8.2 配置

{
    "plugins": ["codesnippet"]
}

8.3 语法

添加代码内容:
This is a code snippet:
{% codesnippet "./myfile.js" %}{% endcodesnippet %}

指定语言类型:

This is a code snippet, display as HTML:
{% codesnippet "./myfile.ejs", language="html" %}{% endcodesnippet %}

带有模板语法的代码块

This is a code snippet, display as HTML:
{% codesnippet %}
curl {{ book.hostname|d("http://localhost") }}/myapi
{% endcodesnippet %}

8.4 效果

(略)

8.5 评价

很方便,但用处不太大,略感繁琐。

综合指数:⭐️⭐️⭐️

相关文章
|
前端开发 Java 数据库
软件体系结构 - 软件构件
软件体系结构 - 软件构件
1000 0
|
人工智能 边缘计算 5G
5G时代,别让能耗成为“隐形杀手”——聊聊5G网络的能耗管理
5G时代,别让能耗成为“隐形杀手”——聊聊5G网络的能耗管理
1076 13
|
12月前
|
开发者 Windows
Acrobat DC 2020 Mac 版PDF阅读器安装教程(简单易懂版)
下载Acrobat_DC_2020_Mac.dmg镜像文件,双击挂载后运行Install.app,按向导完成安装。若系统阻止打开,前往“安全性与隐私”设置点击“仍要打开”即可正常使用。
|
边缘计算 弹性计算 人工智能
魔搭社区大模型一键部署到阿里云边缘云(ENS)
随着大模型技术的快速发展,业界的关注点正逐步从模型训练往模型推理 转变。这一转变不仅反映了大模型在实际业务中的广泛应用需求,也体现了技术优化和工程化落地的趋势。
1803 7
|
安全 Linux 开发者
Debian GNU/Linux
Debian是Linux发行版之一,其起源可以追溯到1993年,由Ian Murdock创立。Debian的名字来源于其创始人Ian Murdock的女友的名字Deb和Linux的创始人Linus Torvalds的名字的组合,即“Deb”+“ian”。Debian的目标是创建一个自由、开放、安全、稳定的操作系统,为用户提供丰富的软件资源和良好的使用体验。 特点
801 8
Debian GNU/Linux
|
人工智能 算法 搜索推荐
CoAT: 基于蒙特卡洛树搜索和关联记忆的大模型推理能力优化框架
研究者提出了一种新的关联思维链(CoAT)方法,通过整合蒙特卡洛树搜索(MCTS)和关联记忆机制,提升大语言模型(LLMs)的推理能力。CoAT框架优化了MCTS算法,增强了结构化推理和动态知识整合,适用于复杂推理、多跳问答和代码生成等任务。实验结果显示,CoAT在精确匹配和F1分数上表现优异,超越了多个基线模型。然而,该方法在计算资源消耗和实时推理速度方面仍有改进空间。
1658 5
CoAT: 基于蒙特卡洛树搜索和关联记忆的大模型推理能力优化框架
|
Java 容器
SpringBoot——聊聊application.properties和application.yml的写法规范及区别
SpringBoot——聊聊application.properties和application.yml的写法规范及区别
1482 0
SpringBoot——聊聊application.properties和application.yml的写法规范及区别
|
前端开发 JavaScript Java
IDEA Maven install Failed to execute goal org.apache.maven.plugins异常处理
IDEA Maven install Failed to execute goal org.apache.maven.plugins异常处理
2367 0
|
人工智能 自然语言处理 算法
DeepSeek大模型在客服系统中的应用场景解析
在数字化浪潮下,客户服务领域正经历深刻变革,AI技术成为提升服务效能与体验的关键。DeepSeek大模型凭借自然语言处理、语音交互及多模态技术,显著优化客服流程,提升用户满意度。它通过智能问答、多轮对话引导、多模态语音客服和情绪监测等功能,革新服务模式,实现高效应答与精准分析,推动人机协作,为企业和客户创造更大价值。
1319 5
|
存储 关系型数据库 MySQL
图解MySQL【日志】——Undo Log
Undo Log(回滚日志)是 MySQL 中用于实现事务原子性和一致性的关键机制。在默认的自动提交模式下,MySQL 隐式开启事务,每条增删改语句都会记录到 Undo Log 中。其主要作用包括:
1110 0

热门文章

最新文章