docsify实现代码折叠

前言

docsify是一款神奇的文档生成利器!提供一个index.html进行配置,其他的说明文档完全可以通过md文件去写,使说明文档可以只专注于md的编写。

插件

docsify拥有活跃的社区,也攒下了很多比较好的插件。今天我们要介绍的是一个可以折叠代码的插件。
在说明文档中可能会有较长的代码,以至于说明文档太过长,对于阅读来说不太友好,那么docsify-hide-code插件就比较好的解决了这个问题。

你可以设置折叠高度,当代码块儿超出此长度将会被折叠,点击展开即可查看所有代码。还提供了是否滚动选项,可以滚动查看代码。

使用

在docsify之后,将以下脚本标记添加到你的index.html中。

<script src="https://unpkg.com/docsify-hide-code"></script>

也可以使用以下脚本。

<script src="https://cdn.jsdelivr.net/npm/docsify-hide-code/dist/docsify-hide-code.min.js"></script>

参数

window.$docsify = {
    hideCode: {
        scroll: false, // 启用滚动
        height: 300 // 折叠高度
    }
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
Docsify is a documentation generator that can be used on Linux operating systems. It allows you to easily create beautiful and customizable documentation websites from simple markdown files. To get started with Docsify on Linux, you can follow these steps: 1. Install Node.js: Docsify requires Node.js to be installed on your system. You can download and install Node.js from the official website or use a package manager like apt or yum. 2. Install Docsify: Once you have Node.js installed, open your terminal and run the following command to install Docsify globally: ``` npm install -g docsify-cli ``` 3. Create Documentation: Next, navigate to the directory where you want to create your documentation website. Create a new directory for your documentation and navigate into it. 4. Initialize Docsify: Run the following command to initialize Docsify in the current directory: ``` docsify init ./docs ``` This will create a `docs` folder with some basic configuration files. 5. Start Docsify: To start the local development server and preview your documentation website, run the following command: ``` docsify serve docs ``` This will start the server and provide you with a URL (e.g., http://localhost:3000) where you can access your documentation. 6. Customize and Write Your Documentation: Docsify uses markdown files for content. You can edit the markdown files in the `docs` folder to write your documentation. You can also customize the appearance and behavior of your documentation website by modifying the `index.html` and `README.md` files. That's it! You now have a local Docsify server running on your Linux system, allowing you to create and preview your documentation website.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

会功夫的李白

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值