Gitbook 插件安装 - 代码复制,行号

2019-05-30 21:57:20 浏览数 (1)

Code plugin for GitBook

Code blocks are cool but can be cooler. This plugin adds lines numbers for multi-line blocks and a copy button to easily copy the content of your block.

Cool, can I see it working?

The next image shows a single line code block:

When displaying code with multiple lines, line numbers will be added:

How can I use this plugin?

You only have to edit your book.json and modify it adding something like this:

代码语言:javascript复制
"plugins" : [ "code" ],

This will set up everything for you. If you want to get rid of the copy buttons use add this section too:

代码语言:javascript复制
"pluginsConfig": {
  "code": {
    "copyButtons": false
  }
}

安装插件

启动GitBook预览效果

0 人点赞