Skip to main content

LsBook

无法忍受 gitbook 龟速的生成速度,决定自己写一个用于书写自己的书籍生成器。

一切参照 gitbook,只为加快网站的生成速度。

只支持 md 语法:CommonMark 规格

项目示例:https://github.com/liushilive/github_software_testing_dictionary

部署

部署 python,安装 lsbook

pip install lsbook

使用

lsbook -b --log debug <book> <output>

编辑 book.json

{
  "author": "作者",
  "title": "书籍标题",
  "language": "zh-cn",
  // ar bn ca cs de el en es fa fi fr he it ja ko nl no pl pt ro ru sv tr uk ui zh-cn zh-hans zh-tw
  "github_url": "主页地址",
  "ignore": [
    ".git",
    ".svn",
    "要排除的文件与文件夹"
  ]
}

数学公式使用

支持 KaTeX 已支持的全部符号。

  • 内联数学公式:

    $$\int_{-\infty}^\infty g(x) dx$$
    
    $$\fcolorbox{red}{aqua}{A}$$
    
    $$\textcolor{#228B22}{F=ma}$$
    
  • 块级数学公式:

    $$
    \def\arraystretch{1.5}
    \begin{array}{c|c:c}
      a & b & c \\ \hline
      d & e & f \\
      \hdashline
      g & h & i
    \end{array}
    $$
    

流程图使用

  • 支持 mermaid 以支持的流程图。

    ```mermaid
    graph TD;
      A-->B;
      A-->C;
      B-->D;
      C-->D;
    ```
    

代码高亮支持

采用 prism 支持所有官方支持语言。

鼠标悬浮可见

用法:把要隐藏文本内容放在 {%s%} 和 {%ends%} 之间。

{%s%}Hello World.{%ends%}

点击隐藏或显示片段

可以使用标签定义一个新的片段:(默认隐藏),不支持嵌套

<!--sec title="点我隐藏答案" show=true ces-->
B
<!--endsec-->

<!--sec title="点我看分析" show=false ces-->
CPU
<!--endsec-->

<!--sec title="点我看分析" ces-->
C
<!--endsec-->

本标签包含以下参数:

  • title:标题
  • show:是否初始隐藏

导入外部代码文件

@import "你的代码文件" {语言}

@import "你的代码文件"

如果没有指明相关语言,将默认根据文件后缀推断语言。

如果文件为 markdown,将直接引入文件中内容。文件中图片会导入到当前项目中。

自定义 js

书籍目录下创建 book.js 文件保存自定义 js 内容。

内容将在页面加载后运行。

Release files for LsBook 2.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for LsBook 2.0.3
File Size Uploaded
LsBook-2.0.3.tar.gz 5.9 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for LsBook 2.0.3
File Interpreter ABI Platform
LsBook-2.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 11.9 MB

Release files / LsBook-2.0.3.tar.gz

Download URL LsBook-2.0.3.tar.gz
Size 5.9 MB
Tags Source
SHA-256 checksum
How to use checksums
05acafcaaadf46c24be43954b01b9a1bdd59839aedb3a7cbcf40dc881fdbb08f
BLAKE2b-256 checksum
How to use checksums
f308097c575d88a417eef7faf66d38c1d2f0bf2df7a16ff7e1b59fe4dbb173b4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.4

Release files / LsBook-2.0.3-py3-none-any.whl

Download URL LsBook-2.0.3-py3-none-any.whl
Size 6.0 MB
Tags Python 3
SHA-256 checksum
How to use checksums
f9600043fd511f6e82abbb2be4a392c95324dd95e6862e0689aee0162eb19ae6
BLAKE2b-256 checksum
How to use checksums
b2a9a9c1be00fac85f79256c293205eff7ea54110c9bb151b3c053de98a5e7bc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.4

Release history Release notifications | RSS feed

This release

2.0.3 This release

2 release files

2.0.2

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.0.15

2 release files

1.0.13

2 release files

1.0.12

2 release files

1.0.11

2 release files

1.0.10

2 release files

1.0.9

2 release files

1.0.8

2 release files

1.0.7

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.2.9

2 release files

0.2.8

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.42

2 release files

0.1.40

2 release files

0.1.37

1 release file

0.1.36

2 release files

0.1.35

2 release files

0.1.33

2 release files

0.1.32

2 release files

0.1.31

2 release files

0.1.30

2 release files

0.1.29

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page