将源代码输出成 epub 等格式的书籍
2020-09-24 22:34
786 查看
将源代码输出成 epub 等格式的书籍
.title { text-align: center; margin-bottom: 0.2em }
.subtitle { text-align: center; font-size: medium; font-weight: bold; margin-top: 0 }
.todo { font-family: monospace; color: rgba(255, 0, 0, 1) }
.done { font-family: monospace; color: rgba(0, 128, 0, 1) }
.priority { font-family: monospace; color: rgba(255, 165, 0, 1) }
.tag { background-color: rgba(238, 238, 238, 1); font-family: monospace; padding: 2px; font-size: 80%; font-weight: normal }
.timestamp { color: rgba(190, 190, 190, 1) }
.timestamp-kwd { color: rgba(95, 158, 160, 1) }
.org-right { margin-left: auto; margin-right: 0; text-align: right }
.org-left { margin-left: 0; margin-right: auto; text-align: left }
.org-center { margin-left: auto; margin-right: auto; text-align: center }
.underline { text-decoration: underline }
#postamble p, #preamble p { font-size: 90%; margin: 0.2em }
p.verse { margin-left: 3% }
pre { border: 1px solid rgba(204, 204, 204, 1); box-shadow: 3px 3px 3px rgba(238, 238, 238, 1); padding: 8pt; font-family: monospace; overflow: auto; margin: 1.2em }
pre.src { position: relative; overflow: auto; padding-top: 1.2em }
pre.src:before { display: none; position: absolute; background-color: rgba(255, 255, 255, 1); top: -10px; right: 10px; padding: 3px; border: 1px solid rgba(0, 0, 0, 1) }
pre.src:hover:before { display: inline }
pre.src-asymptote:before { content: "Asymptote" }
pre.src-awk:before { content: "Awk" }
pre.src-C:before { content: "C" }
pre.src-clojure:before { content: "Clojure" }
pre.src-css:before { content: "CSS" }
pre.src-D:before { content: "D" }
pre.src-ditaa:before { content: "ditaa" }
pre.src-dot:before { content: "Graphviz" }
pre.src-calc:before { content: "Emacs Calc" }
pre.src-emacs-lisp:before { content: "Emacs Lisp" }
pre.src-fortran:before { content: "Fortran" }
pre.src-gnuplot:before { content: "gnuplot" }
pre.src-haskell:before { content: "Haskell" }
pre.src-hledger:before { content: "hledger" }
pre.src-java:before { content: "Java" }
pre.src-js:before { content: "Javascript" }
pre.src-latex:before { content: "LaTeX" }
pre.src-ledger:before { content: "Ledger" }
pre.src-lisp:before { content: "Lisp" }
pre.src-lilypond:before { content: "Lilypond" }
pre.src-lua:before { content: "Lua" }
pre.src-matlab:before { content: "MATLAB" }
pre.src-mscgen:before { content: "Mscgen" }
pre.src-ocaml:before { content: "Objective Caml" }
pre.src-octave:before { content: "Octave" }
pre.src-org:before { content: "Org mode" }
pre.src-oz:before { content: "OZ" }
pre.src-plantuml:before { content: "Plantuml" }
pre.src-processing:before { content: "Processing.js" }
pre.src-python:before { content: "Python" }
pre.src-R:before { content: "R" }
pre.src-ruby:before { content: "Ruby" }
pre.src-sass:before { content: "Sass" }
pre.src-scheme:before { content: "Scheme" }
pre.src-screen:before { content: "Gnu Screen" }
pre.src-sed:before { content: "Sed" }
pre.src-sh:before { content: "shell" }
pre.src-sql:before { content: "SQL" }
pre.src-sqlite:before { content: "SQLite" }
pre.src-forth:before { content: "Forth" }
pre.src-io:before { content: "IO" }
pre.src-J:before { content: "J" }
pre.src-makefile:before { content: "Makefile" }
pre.src-maxima:before { content: "Maxima" }
pre.src-perl:before { content: "Perl" }
pre.src-picolisp:before { content: "Pico Lisp" }
pre.src-scala:before { content: "Scala" }
pre.src-shell:before { content: "Shell Script" }
pre.src-ebnf2ps:before { content: "ebfn2ps" }
pre.src-cpp:before { content: "C++" }
pre.src-abc:before { content: "ABC" }
pre.src-coq:before { content: "Coq" }
pr
ad8
e.src-groovy:before { content: "Groovy" }
pre.src-bash:before { content: "bash" }
pre.src-csh:before { content: "csh" }
pre.src-ash:before { content: "ash" }
pre.src-dash:before { content: "dash" }
pre.src-ksh:before { content: "ksh" }
pre.src-mksh:before { content: "mksh" }
pre.src-posh:before { content: "posh" }
pre.src-ada:before { content: "Ada" }
pre.src-asm:before { content: "Assembler" }
pre.src-caml:before { content: "Caml" }
pre.src-delphi:before { content: "Delphi" }
pre.src-html:before { content: "HTML" }
pre.src-idl:before { content: "IDL" }
pre.src-mercury:before { content: "Mercury" }
pre.src-metapost:before { content: "MetaPost" }
pre.src-modula-2:before { content: "Modula-2" }
pre.src-pascal:before { content: "Pascal" }
pre.src-ps:before { content: "PostScript" }
pre.src-prolog:before { content: "Prolog" }
pre.src-simula:before { content: "Simula" }
pre.src-tcl:before { content: "tcl" }
pre.src-tex:before { content: "TeX" }
pre.src-plain-tex:before { content: "Plain TeX" }
pre.src-verilog:before { content: "Verilog" }
pre.src-vhdl:before { content: "VHDL" }
pre.src-xml:before { content: "XML" }
pre.src-nxml:before { content: "XML" }
pre.src-conf:before { content: "Configuration File" }
table { border-collapse: collapse }
caption.t-above { caption-side: top }
caption.t-bottom { caption-side: bottom }
td, th { vertical-align: top }
th.org-right { text-align: center }
th.org-left { text-align: center }
th.org-center { text-align: center }
td.org-right { text-align: right }
td.org-left { text-align: left }
td.org-center { text-align: center }
dt { font-weight: bold }
.footpara { display: inline }
.footdef { margin-bottom: 1em }
.figure { padding: 1em }
.figure p { text-align: center }
.equation-container { display: table; text-align: center; width: 100% }
.equation { vertical-align: middle }
.equation-label { display: table-cell; text-align: right; vertical-align: middle }
.inlinetask { padding: 10px; border: 2px solid rgba(128, 128, 128, 1); margin: 10px; background: rgba(255, 255, 204, 1) }
#org-div-home-and-up { text-align: right; font-size: 70%; white-space: nowrap }
textarea { overflow-x: auto }
.linenr { font-size: smaller }
.code-highlighted { background-color: rgba(255, 255, 0, 1) }
.org-info-js_info-navigation { border-style: none }
#org-info-js_console-label { font-size: 10px; font-weight: bold; white-space: nowrap }
.org-info-js_search-highlight { background-color: rgba(255, 255, 0, 1); color: rgba(0, 0, 0, 1); font-weight: bold }
.org-svg { width: 90% }
将源代码输出成 epub 等格式的书籍
Table of Contents
1 效果
本工具介绍 agentzh 大神的 code2ebook 项目,可以直接跳过去看英文文档,这里我更简洁的介绍使用方法,并且简单说一下遇到的问题将源代码生成 html、epub、mobi、pdf 格式的电子书,并且是有函数定义跳转的那种,就像在 ide 中
2 前提
- vim
- perl
- ctags
- calibre 一款电子书管理软件
3 使用
上面工具安装好之后
- 将代码 clone 到本地
- 将目录加入到 PATH 环境变量中
- 切换到源码目录
- 执行下面的 src2html.pl 命令
export PATH=/path/to/code2ebook:$PATH cd /path/to/your/project/ src2html.pl --tab-width 4 --color --cross-reference \ --navigator --line-numbers . 'Your Book Title'
当然,可以使用 -j 选项在多核 cpu 上面加速执行
执行完成后会生成一个 html_out/index.html 文件
使用浏览器打开就可以看具体的代码了
继续操作~
使用刚才下载安装好的 calibre 软件转换成 epub 或者其他书籍格式
/Applications/calibre.app/Contents/MacOS/ebook-convert html_out/index.html nginx-1.9.2-chinese.epub \ --output-profile ipad3 \ --no-default-epub-c 14ec over \ --title "nginx-1.9.2-chinese" --publisher 'wudanyang' \ --language en --authors 'wudanyang'
ok, 成功,看书吧
分享一下 大神注释过的 nginx 代码 生成的 epub 文件:
链接: https://pan.baidu.com/s/1jdc0x7SnnxDCB5FrnwrZ0w
提取码: wcpw
复制这段内容后打开百度网盘手机 App,操作更方便哦
===
作者: 吴丹阳 https://www.cnblogs.com/wudanyang
更新时间: 2020-09-24 Thu 22:49
===
天行健,君子以自强不息。
地势坤,君子以厚德载物。
===
相关文章推荐
- Java数据库编程中查询结果的表格式输出(源代码)
- android平台解析epub格式的书籍信息
- android平台解析epub格式的书籍信息
- android平台解析epub格式的书籍信息
- android平台解析epub格式的书籍信息
- 设计类CDate以满足:输出年月日日期格式;输入的日期加1;设置日期(参考清华版李春葆C++书籍)
- shell脚本编程(严格的终端格式控制,美丽的输出字体颜色)
- fmt:formatDate的输出格式
- Linux(V4L2驱动)下获得Opencv摄像头属性(图像输出格式和是否发生往RGB的转换)的方法
- .netcore中LoggerFileProvider修改输出格式
- 【IOS基础知识】格式输出
- JSTL fmt:formatDate 的输出时间日期格式
- fs学习笔记之输出格式
- 1006. 换个格式输出整数 (15)
- 用DateTime.ToString(string format)输出不同格式的日期
- 懒得整理了,c++常用输出格式~
- 需要复习的:FFmpeg源代码简单分析:日志输出系统(av_log()等)
- PAT 1006. 换个格式输出整数【逆序输出】
- c中输出格式(转载)
- C/C++ 学习之 PDF 格式输出