日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

gitbook asciidoc 项目生成PDF 教程

發(fā)布時(shí)間:2023/12/20 编程问答 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 gitbook asciidoc 项目生成PDF 教程 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

環(huán)境

操作系統(tǒng): win7
npm: 3.10.10

需求

今天在gitbook看elasticsearch權(quán)威指南時(shí),發(fā)現(xiàn)與官網(wǎng)的有些不一樣,或者說官網(wǎng)上的中文文檔依然有些錯(cuò)別字或者翻譯不對(duì)的地方。而gitbook上的源碼目前視乎還在更新,但是源碼看起來又特難受,于是乎我就折騰怎樣將其生成為PDF文件來看。

折騰一晚上總于又眉目啦

步驟

①安裝好gitbook環(huán)境
②將gitbook項(xiàng)目源碼;也就是GitHub項(xiàng)目clone下來。
③安裝ebook-convert。
④執(zhí)行g(shù)itbook命令生成PDF

安裝gitbook環(huán)境

由于GitBook 是一個(gè)基于 Node.js 的命令行工具,可使用 Github/Git 和 Markdown 來制作精美的電子書。

所以我們要先安裝Node.js。

安裝Node.js

這里我就不介紹啦!

安裝gitbook

在安裝好Node.js之后在命令行中執(zhí)行如下命令:

npm install gitbook-cli -g

驗(yàn)證安裝是否成功:

C:\Users\yutao>npm -v 3.10.10

這里也簡單介紹下gitbook命令:

本地預(yù)覽

C:\Users\lenovo> gitbook serve ./圖書名稱

輸出一個(gè)靜態(tài)網(wǎng)站

C:\Users\lenovo> gitbook build 圖書目錄 輸出目錄

上面命令的路徑是項(xiàng)目路徑的上一層。也就是不要進(jìn)入到項(xiàng)目文件夾中。

查看幫助

C:\Users\lenovo> gitbook help build [book] [output] build a book --format Format to build to (Default is website; Values are website, jso n, ebook) --log Minimum log level to display (Default is info; Values are debug , info, warn, error, disabled)pdf [book] [output] build a book to pdf --log Minimum log level to display (Default is info; Values are debug , info, warn, error, disabled)epub [book] [output] build a book to epub --log Minimum log level to display (Default is info; Values are debug , info, warn, error, disabled)mobi [book] [output] build a book to mobi --log Minimum log level to display (Default is info; Values are debug , info, warn, error, disabled)serve [book] Build then serve a gitbook from a directory --port Port for server to listen on (Default is 4000) --lrport Port for livereload server to listen on (Default is 35729) --watch Enable/disable file watcher (Default is true) --format Format to build to (Default is website; Values are website, jso n, ebook) --log Minimum log level to display (Default is info; Values are debug , info, warn, error, disabled)install [book] install plugins dependenciesinit [directory] create files and folders based on contents of SUMMARY.m d

安裝 ebook-convert

ebook-convert 下載地址

我下載的是Windows版。

安裝一下就可以,記得要啟動(dòng)下,設(shè)置書庫路徑。

clone 項(xiàng)目

我clone的項(xiàng)目是:

git clone git@github.com:elasticsearch-cn/elasticsearch-definitive-guide.git

這里重點(diǎn)來了
首先,這個(gè)項(xiàng)目的文件格式是asciidoc的,網(wǎng)上大部分教程都是Markdown。
這就導(dǎo)致我查閱的資料很少,執(zhí)行命令時(shí)總是報(bào)錯(cuò)。

后來我才知道,這種類型格式的項(xiàng)目需要兩個(gè)文件:
① README.adoc 文件
② SUMMARY.adoc 文件

README.adoc 類似于這本書的介紹。
SUMMARY.adoc 就這本書的目錄結(jié)構(gòu)。

這兩個(gè)文件都需要,書的介紹可以沒有,也就是README.adoc這個(gè)文件你可以什么都不寫空著就行。

但是SUMMARY.adoc是生成PDF時(shí)的關(guān)鍵。

編寫SUMMARY.adoc有兩種方式:

第一種
使用官方格式編寫目錄:

= Summary. link:chapter-1/README.adoc[Chapter 1] .. link:chapter-1/ARTICLE1.adoc[Article 1] .. link:chapter-1/ARTICLE2.adoc[Article 2] ... link:chapter-1/ARTICLE-1-2-1.adoc[Article 1.2.1] . link:chapter-2/README.adoc[Chapter 2] . link:chapter-3/README.adoc[Chapter 3] . link:chapter-4/README.adoc[Chapter 4] .. Unfinished article . Unfinished Chapter

對(duì)于我的項(xiàng)目而言就是:

= Summary. link:00_Getting_started.asciidoc[入門基礎(chǔ)] .. link:010_Intro/05_What_is_it.asciidoc[一切為了搜索] .. link:010_Intro/10_Installing_ES.asciidoc[安裝es] .. link:010_Intro/15_API.asciidoc[15_API.asciidoc] //我沒有寫全,只寫了一部分。。。

在執(zhí)行:

E:\document\elasticsearch-definitive-guide>gitbook pdf ./ ./es.pdf

其中document是我自己創(chuàng)建的一個(gè)文件夾,我的項(xiàng)目結(jié)構(gòu):

執(zhí)行完了后,項(xiàng)目中就多了個(gè)es.pdf 文件。


第二種 方法

利用 asciidocfx軟件中的PDF導(dǎo)出功能;
SUMMARY.adoc 文件要這么編寫:

include::010_Intro/05_What_is_it.asciidoc[]include::010_Intro/10_Installing_ES.asciidoc[]include::010_Intro/15_API.asciidoc[]include::010_Intro/20_Document.asciidoc[]include::010_Intro/25_Tutorial_Indexing.asciidoc[]include::010_Intro/30_Tutorial_Search.asciidoc[]include::010_Intro/35_Tutorial_Aggregations.asciidoc[]include::010_Intro/40_Tutorial_Conclusion.asciidoc[]include::010_Intro/45_Distributed.asciidoc[]include::010_Intro/50_Conclusion.asciidoc[]

再用asciidocfx這個(gè)軟件打開這個(gè)項(xiàng)目并打開定位到SUMMARY.adoc文件后,點(diǎn)擊右上方的PDF按鈕,等一會(huì)就會(huì)生成PDF文件。


參考地址:

https://tonydeng.github.io/gitbook-zh/gitbook-howtouse/output/pdfandebook.html

https://www.gitbook.com/book/yuzeshan/gitbook-studying/details

https://chrisniael.gitbooks.io/gitbook-documentation/content/format/asciidoc.html

https://yuzeshan.gitbooks.io/gitbook-studying/content/output/pdfandebook.html

https://www.gitbook.com/book/melody/asciidoc/details

https://www.gitbook.com/book/gitbookio/docs-toolchain/details

https://github.com/elasticsearch-cn/elasticsearch-definitive-guide

總結(jié)

以上是生活随笔為你收集整理的gitbook asciidoc 项目生成PDF 教程的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。