Comments (2)
手动做了一个目录。使用方式如下:
- 先准备 python 环境,安装一个叫
pdf.tocgen
的包 - 下载下面这个
toc.txt
,和从官网下载的the-fenix-project.pdf
放在一起
Windows 下可以直接用,Mac/Linux 可能需要调整文件编码
- 运行以下命令
pdftocio the-fenix-project.pdf < toc.txt
再次打开 PDF,就应该已经有完整目录了,所有层级应该都是正常的,如下图
from awesome-fenix.
如果遇到未来 PDF 版本更新,或者想要从头生成带目录的 PDF,可以按照如下步骤操作
- 安装 Python 环境和
pdf.tocgen
依赖
pip install -U pdf.tocgen
- 准备一个临时的工作目录
- 把整个项目 git clone 到本地
- 打开
.vuepress\plugins\export\index.js
,在 line 93 (exportPages
定义结束,browser
定义开始前) 插入以下内容,以生成层级数据文件
注意需要将{path_to_folder}
换成 1 中工作目录的路径
fs.writeFileSync("{path_to_folder}" + "/sidebar.json", JSON.stringify(sidebar));
fs.writeFileSync("{path_to_folder}" + "/exportPages.json", JSON.stringify(exportPages));
- 把生成完成的 PDF (位于
.vuepress/dist/pdf
下,文件名为the-fenix-project.pdf
)复制到 1 中的临时工作目录。此时 1 中目录应包含sidebar.json
,exportPages.json
,the-fenix-project.pdf
三个文件 - 从 这里 获取
generate_pdf_with_toc.py
脚本,放置于 1 中工作目录 - 在终端中切换到 1 中工作目录,运行 5 中的脚本
python generate_pdf_with_toc.py
- 若一切正常,会新生成两个文件,其中
the-fenix-project-with-toc.pdf
为带目录的 PDF 文件,toc.txt
为目录描述文件。只要有了目录描述文件,就可以直接在有原始 PDF 的情况下添加目录,而不需要再完成以上的步骤了,链接
如果不想自己生成 PDF,只是想要自己生成目录的话,只需要做如下改动
- 上文步骤 3 中,添加的代码最后加一行
return
,提前结束函数跳过 PDF 生成,但依然生成必要的层级数据文件 - 上文步骤 4 中,直接使用官网下载到的 PDF 文件
但这样可能会有一些小问题:如果官网比 PDF 新(新在这里指文章增加),用官网的文件结构生成的 PDF 目录会包含实际 PDF 文件中没有的项,在脚本中会自动跳过,但是依然会提示。
WARNING: missing some chapters, the PDF provided might not be the most up-to-date version.
警告:部分存在于网站中的章节不存在于 PDF 中。这可能是因为 PDF 构建后网站中增加了新章节。重新构建 PDF 可以解决这一问题。
missing chapter: ArchSummit2021主题演讲:从软件的历史看架构的未来
生成原理:
- 用
vuepress
中的sidebar
获得层级结构,exportPages
获得页面标题和 URL - 用
pdf.tocgen
中的extract_toc
从 PDF 文件中提取出文章标题和对应的页码 - 匹配 1 中的树形目录和 2 中的文章页码,生成带层级的目录
- 将带层级的目录信息写入 PDF 文件中
from awesome-fenix.
pdf 文档已经一年没更新了……
from awesome-fenix.
Related Issues (20)
- 「Comment」https://icyfenix.cn/introduction/about-book.html HOT 23
- tt
- 「Comment」https://icyfenix.cn/tricks/2021/fenix-cli/ HOT 1
- The exported pdf has no table of contents HOT 1
- clientSecret 暴露 安全问题 HOT 2
- 【travis-ci token暴露】 HOT 1
- 书中第166页,这个0.25% 是怎么计算的呢,我的理解是2.5%,希望有大佬解释一下 HOT 1
- 「Comment」https://icyfenix.cn/tricks/2021/arch/ HOT 4
- 「Comment」 http://icyfenix.cn/exploration/projects/microservice_arch_springcloud.html#下载镜像报unhealthy的错误
- 如何捕获并处理 security 相关异常 HOT 1
- 能否在分布式共识算法中增加对raft的介绍
- a word is missing in https://github.com/fenixsoft/awesome-fenix/blob/master/exploration/projects/servicemesh_arch_istio.md
- http://icyfenix.cn/ 评论区已无法使用github登陆讨论
- Paxos 算法工作实例存在的问题
- /exploration/guide/quick-start.html 包含无法访问的外部链接
- 自生成的 pdf 大小和下载的 pdf 有点不一样?
- paxos 和 raft 是不是也和 XA、2PC 一样,属于实现线性一致性的算法之一呢?
- 可靠事件队列缺乏隔离性,为什么会导致超售?
- icyfenix.cn 404
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from awesome-fenix.