mkbook 0.1.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/mkbook +117 -0
- data/lib/config.yml +20 -0
- data/lib/make_book.rb +267 -0
- data/lib/template_article.tex +22 -0
- data/lib/template_blog.tex +26 -0
- data/lib/template_book.tex +36 -0
- data/lib/template_fancy.tex +33 -0
- data/lib/template_novel.tex +36 -0
- data/lib/template_plain.tex +31 -0
- data/template/.mkbook.yml +10 -0
- data/template/en/appx01-abbreviation.md +3 -0
- data/template/en/chap01-introduce.md +3 -0
- data/template/en/preface.md +7 -0
- data/template/images/README.md +3 -0
- data/template/resources/README.md +3 -0
- data/template/zh/appx01-abbreviation.md +3 -0
- data/template/zh/chap01-introduce.md +3 -0
- data/template/zh/preface.md +7 -0
- metadata +28 -65
- data/.gitignore +0 -11
- data/.rspec +0 -2
- data/.travis.yml +0 -4
- data/CODE_OF_CONDUCT.md +0 -13
- data/Gemfile +0 -4
- data/LICENSE.txt +0 -21
- data/README.md +0 -41
- data/Rakefile +0 -6
- data/bin/console +0 -14
- data/bin/setup +0 -7
- data/lib/mkbook/version.rb +0 -3
- data/lib/mkbook.rb +0 -5
- data/mkbook.gemspec +0 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d464ccfc2afc5aa1c72a74b59909ce2d7e9fae09
|
4
|
+
data.tar.gz: d3b84a9df4b9c82240f0efe27a258f1b76ec2605
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec1bf3dbbc331b68a41fde3705343c97c5ebd11399e285aef8e1312f2dfcff1ebc91719be8c14eecdf42b9b87f27c432977131cf7afcb0dcf13b53f77d4d5b74
|
7
|
+
data.tar.gz: 09ee583d76ba889e33228407c4fee6e63179434996e76edf9d4b58e213492911458217a623f9bf35b841d8e70d80c30eeacfed8db05e709b2a0677b7a87d1b1d
|
data/bin/mkbook
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
|
4
|
+
require 'optparse'
|
5
|
+
require 'fileutils'
|
6
|
+
require 'erb'
|
7
|
+
require 'yaml'
|
8
|
+
require 'make_book'
|
9
|
+
|
10
|
+
include FileUtils
|
11
|
+
|
12
|
+
# here -- work directory
|
13
|
+
here = Dir.getwd
|
14
|
+
# root -- program directory
|
15
|
+
root = File.dirname(__FILE__)
|
16
|
+
|
17
|
+
# 设置默认选项
|
18
|
+
options = {
|
19
|
+
"lang" => "zh",
|
20
|
+
"build" => "pdf",
|
21
|
+
"template" => "book",
|
22
|
+
"option" => "a5paper,openany",
|
23
|
+
"dir.output" => "out",
|
24
|
+
"dir.latex" => ".tex",
|
25
|
+
"file.preface" => "preface.md",
|
26
|
+
"file.chapters" => "chap*.md",
|
27
|
+
"file.appendix" => "appx*.md"
|
28
|
+
}
|
29
|
+
|
30
|
+
# 加载配置文件
|
31
|
+
config_file = File.join('.mkbook.yml')
|
32
|
+
if File.exists? config_file
|
33
|
+
config_options = YAML.load_file(config_file)
|
34
|
+
options.merge!(config_options) if config_options
|
35
|
+
end
|
36
|
+
|
37
|
+
# 定义选项解析器
|
38
|
+
OptionParser.new do |opts|
|
39
|
+
executable_name = File.basename($PROGRAM_NAME)
|
40
|
+
opts.banner = "Make ebooks from markdown plain text
|
41
|
+
Usage: #{executable_name} [options]\n"
|
42
|
+
|
43
|
+
# 定义输出格式
|
44
|
+
opts.on("-b","--build FORMAT","build format: pdf,html,epub. seperated by ','") do |format|
|
45
|
+
formatOptions = format.split(",")
|
46
|
+
formatOptions.each do |fmt|
|
47
|
+
unless ["pdf","html","epub"].include?(fmt)
|
48
|
+
raise ArgumentError,"FORMAT must be one of 'pdf,html,epub' format"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
options["build"] = formatOptions
|
52
|
+
end
|
53
|
+
|
54
|
+
# 定义 debug 模式, 输出更多信息, 用于调试
|
55
|
+
opts.on("-d","--[no-]debug","debug mode") do |setting|
|
56
|
+
options["debug"] = setting
|
57
|
+
end
|
58
|
+
|
59
|
+
# 定义 定稿 模式, 编译三遍, 建立索引、参考文献
|
60
|
+
opts.on("-f","--[no-]final","final mode") do |setting|
|
61
|
+
options["final"] = setting
|
62
|
+
end
|
63
|
+
|
64
|
+
# 选择语言类型
|
65
|
+
opts.on("-l","--lang LANG","language selection") do |lang|
|
66
|
+
options["lang"] = lang
|
67
|
+
end
|
68
|
+
|
69
|
+
# 选择模板
|
70
|
+
opts.on("-t","--template template.tex","latex template file") do |template|
|
71
|
+
unless File.exists? template
|
72
|
+
raise ArgumentError,"template file \"#{template}\" doesn't exist"
|
73
|
+
end
|
74
|
+
options["template"] = template
|
75
|
+
end
|
76
|
+
|
77
|
+
# 设置书的名字
|
78
|
+
opts.on("-n","--name book name","book name") do |name|
|
79
|
+
unless name =~ /^[a-zA-Z0-9-]+$/
|
80
|
+
raise ArgumentError,"name should be [a-zA-Z0-9-]"
|
81
|
+
end
|
82
|
+
options["name"] = name
|
83
|
+
end
|
84
|
+
|
85
|
+
# 定义生成器
|
86
|
+
opts.on("-g","--generate project","project name") do |name|
|
87
|
+
unless name =~ /^[a-zA-Z0-9-]+$/
|
88
|
+
raise ArgumentError,"name should be [a-zA-Z0-9-]"
|
89
|
+
end
|
90
|
+
options["command"] = "generate"
|
91
|
+
options["name"] = name
|
92
|
+
end
|
93
|
+
end.parse!
|
94
|
+
|
95
|
+
options["name"] = File.basename(here) unless options["name"]
|
96
|
+
|
97
|
+
puts options.inspect if options["debug"]
|
98
|
+
|
99
|
+
if options["command"] == "generate"
|
100
|
+
generate_project(options)
|
101
|
+
exit
|
102
|
+
end
|
103
|
+
|
104
|
+
unless File.exists? config_file
|
105
|
+
log_error("This is not an ebook project, or missing .mkbook.yml.
|
106
|
+
Use the following command to generate project first,
|
107
|
+
mkbook --generate <foo>
|
108
|
+
Or create an empty file .mkbook.yml manually.\n")
|
109
|
+
exit
|
110
|
+
end
|
111
|
+
|
112
|
+
if options["build"].include?("pdf")
|
113
|
+
generate_pdf(options)
|
114
|
+
end
|
115
|
+
|
116
|
+
# 将选项写入文件
|
117
|
+
File.write('.mkbook.yml',options.to_yaml)
|
data/lib/config.yml
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
default:
|
2
|
+
thanks: "Thank you!"
|
3
|
+
zh:
|
4
|
+
title: 书的标题
|
5
|
+
author: 作者
|
6
|
+
date: \today
|
7
|
+
version: 0.0.1
|
8
|
+
contents: 目录
|
9
|
+
figure: 图
|
10
|
+
table: 表
|
11
|
+
appendix: 附录
|
12
|
+
en:
|
13
|
+
title: Book Name
|
14
|
+
author: Author
|
15
|
+
date: \today
|
16
|
+
version: 0.0.1
|
17
|
+
contents: Contents
|
18
|
+
figure: Fig.
|
19
|
+
table: Tab.
|
20
|
+
appendix: Appendix
|
data/lib/make_book.rb
ADDED
@@ -0,0 +1,267 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
|
4
|
+
require 'pathname'
|
5
|
+
|
6
|
+
def generate_project(options)
|
7
|
+
root = File.dirname(__FILE__)
|
8
|
+
source = "#{root}/../template"
|
9
|
+
target = options["name"]
|
10
|
+
lang = options["lang"]
|
11
|
+
log_info("Generate project #{target.upcase}\n")
|
12
|
+
create_from_template("#{source}", "#{target}", :recursive => false)
|
13
|
+
create_from_template("#{source}/.mkbook.yml", "#{target}/.mkbook.yml")
|
14
|
+
create_from_template("#{source}/images", "#{target}/images")
|
15
|
+
create_from_template("#{source}/resources", "#{target}/resources")
|
16
|
+
create_from_template("#{source}/#{lang}", "#{target}/#{lang}")
|
17
|
+
log_info("Generate #{target.upcase} complete!\n")
|
18
|
+
end
|
19
|
+
|
20
|
+
def create_from_template(source, target, options={:recursive => true})
|
21
|
+
if File.directory? source
|
22
|
+
if !Dir.exist? target
|
23
|
+
Dir.mkdir(target)
|
24
|
+
puts "\t\033[32mcreate\033[0m #{target}"
|
25
|
+
else
|
26
|
+
puts "\t\033[31mexists\033[0m #{target}"
|
27
|
+
end
|
28
|
+
if options[:recursive]
|
29
|
+
Dir.foreach(source) do |file|
|
30
|
+
if file != "." and file != ".."
|
31
|
+
sub_source = File.join(source, file)
|
32
|
+
sub_target = File.join(target, file)
|
33
|
+
create_from_template(sub_source, sub_target)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
else
|
38
|
+
if !File.exists? target
|
39
|
+
cp(source, target)
|
40
|
+
puts "\t\033[32mcreate\033[0m #{target}"
|
41
|
+
else
|
42
|
+
puts "\t\033[31mexists\033[0m #{target}"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def traverse_dir(path)
|
48
|
+
if File.directory? path
|
49
|
+
Dir.foreach(path) do |file|
|
50
|
+
if file != "." and file != ".."
|
51
|
+
traverse_dir(File.join(path, file))
|
52
|
+
end
|
53
|
+
end
|
54
|
+
else
|
55
|
+
puts path
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def generate_pdf(options)
|
60
|
+
log_info("Generate PDF ...\n")
|
61
|
+
|
62
|
+
root = File.dirname(__FILE__)
|
63
|
+
lang = options["lang"]
|
64
|
+
|
65
|
+
config_file = "#{root}/config.yml"
|
66
|
+
if File.exists? config_file
|
67
|
+
opts = YAML.load_file(config_file)
|
68
|
+
config_options = opts["default"]
|
69
|
+
config_options.merge!(opts[lang]) if opts[lang]
|
70
|
+
end
|
71
|
+
|
72
|
+
config_file = "#{lang}/config.yml"
|
73
|
+
if File.exists? config_file
|
74
|
+
opts = YAML.load_file(config_file)
|
75
|
+
config_options.merge!(opts) if opts
|
76
|
+
end
|
77
|
+
|
78
|
+
template = ERB.new(File.read("#{root}/template_#{options["template"]}.tex"))
|
79
|
+
|
80
|
+
missing = ['pandoc', 'xelatex'].reject{|command| command_exists?(command)}
|
81
|
+
unless missing.empty?
|
82
|
+
log_error "Missing dependencies: #{missing.join(', ')}."
|
83
|
+
puts "\n\tInstall these and try again."
|
84
|
+
exit
|
85
|
+
end
|
86
|
+
|
87
|
+
Dir.mkdir(options["dir.latex"]) if !Dir.exist? options["dir.latex"]
|
88
|
+
Dir.mkdir(options["dir.output"]) if !Dir.exist? options["dir.output"]
|
89
|
+
|
90
|
+
preface = markdown2latex("file.preface" ,options)
|
91
|
+
chapters = markdown2latex("file.chapters",options)
|
92
|
+
appendix = markdown2latex("file.appendix",options)
|
93
|
+
|
94
|
+
File.open("#{options["dir.latex"]}/main.tex", 'w') do |file|
|
95
|
+
file.write(template.result(binding))
|
96
|
+
end
|
97
|
+
|
98
|
+
abort = false
|
99
|
+
log_info("Running xelatex main.tex:\n")
|
100
|
+
num = options["final"] ? 3 : 1
|
101
|
+
num.times do |i|
|
102
|
+
print "\tPass #{i+1} ... "
|
103
|
+
line = ""
|
104
|
+
IO.popen("xelatex -output-directory=\"#{options["dir.latex"]}\" \"#{options["dir.latex"]}/main.tex\" 2>&1") do |pipe|
|
105
|
+
unless options["debug"]
|
106
|
+
while line = pipe.gets and not abort
|
107
|
+
if (RUBY_VERSION >= "1.9" and line.valid_encoding? and line =~ /^!\s/) or (RUBY_VERSION < "1.9" and line =~ /^!\s/)
|
108
|
+
puts "failed with:\n\t\t\t#{line.strip}"
|
109
|
+
puts "\tConsider running this again with --debug."
|
110
|
+
abort = true
|
111
|
+
end
|
112
|
+
end
|
113
|
+
else
|
114
|
+
STDERR.print while pipe.gets rescue abort = true
|
115
|
+
end
|
116
|
+
end
|
117
|
+
break if abort
|
118
|
+
puts "done"
|
119
|
+
next unless i == 0 and options["final"]
|
120
|
+
IO.popen("cd #{options["dir.latex"]}; bibtex main 2>&1") do |pipe|
|
121
|
+
if options["debug"]
|
122
|
+
STDERR.print while pipe.gets rescue abort = true
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
unless abort
|
128
|
+
log_info("Moving output to #{options["dir.output"]}/#{options["name"]}.#{options["lang"]}.pdf ... ")
|
129
|
+
cp("#{options["dir.latex"]}/main.pdf", "#{options["dir.output"]}/#{options["name"]}.#{options["lang"]}.pdf")
|
130
|
+
puts "done"
|
131
|
+
else
|
132
|
+
log_error("Convert error, exit!\n")
|
133
|
+
exit 1
|
134
|
+
end
|
135
|
+
|
136
|
+
File.write(config_file,config_options.to_yaml)
|
137
|
+
|
138
|
+
log_info("Generate PDF Complete!\n")
|
139
|
+
end
|
140
|
+
|
141
|
+
|
142
|
+
def markdown2latex(regex, options)
|
143
|
+
files = "#{options["lang"]}/#{options[regex]}"
|
144
|
+
log_info("Parsing markdown ... #{files}:\n")
|
145
|
+
markdown = Dir["#{files}"].sort.map do |file|
|
146
|
+
list = file.split('.')
|
147
|
+
file_name = list[0]
|
148
|
+
file_ext = list[1]
|
149
|
+
if file_ext == 'rmd'
|
150
|
+
puts "\t\033[32mconvert\033[0m #{file}"
|
151
|
+
system("rmd2md #{file}; mv *.md zh")
|
152
|
+
file = "#{file_name}.md"
|
153
|
+
end
|
154
|
+
puts "\t\033[32minclude\033[0m #{file}"
|
155
|
+
if options["jeykll"]
|
156
|
+
check_jekyll(File.read(file))
|
157
|
+
else
|
158
|
+
File.read(file)
|
159
|
+
end
|
160
|
+
end.join("\n\n")
|
161
|
+
log_info("Convert markdown into latex ... ")
|
162
|
+
latex = IO.popen('pandoc --no-wrap --chapters -f markdown -t latex', 'w+') do |pipe|
|
163
|
+
pipe.write(pre_pandoc(markdown))
|
164
|
+
pipe.close_write
|
165
|
+
post_pandoc(pipe.read)
|
166
|
+
end
|
167
|
+
puts "done"
|
168
|
+
latex
|
169
|
+
end
|
170
|
+
|
171
|
+
def command_exists?(command)
|
172
|
+
if File.executable?(command) then
|
173
|
+
return command
|
174
|
+
end
|
175
|
+
ENV['PATH'].split(File::PATH_SEPARATOR).map do |path|
|
176
|
+
cmd = "#{path}/#{command}"
|
177
|
+
File.executable?(cmd) || File.executable?("#{cmd}.exe") || File.executable?("#{cmd}.cmd")
|
178
|
+
end.inject{|a, b| a || b}
|
179
|
+
end
|
180
|
+
|
181
|
+
def replace(string, &block)
|
182
|
+
string.instance_eval do
|
183
|
+
alias :s :gsub!
|
184
|
+
instance_eval(&block)
|
185
|
+
end
|
186
|
+
string
|
187
|
+
end
|
188
|
+
|
189
|
+
def pre_pandoc(string)
|
190
|
+
prefix = "resources/"
|
191
|
+
replace(string) do
|
192
|
+
s /Insert\s(18333fig\d+)\.png\s*\n.*?\d{1,2}-\d{1,2}\. (.*)/, ''
|
193
|
+
s /images\/(.*)\?raw=true/, '\1'
|
194
|
+
s /\[@(.*?)\]/, '\citep{\1}'
|
195
|
+
s /% latex table generated in R.*?2013\r?\n/m, ''
|
196
|
+
s /\.\.\/images\//, ''
|
197
|
+
s /{@code\s*(.*?)}/m, '`\1`'
|
198
|
+
s /{@link\s*([^ ]*?)\s*([^ ]*?)}/m, '[\1](\2)'
|
199
|
+
# s /^\r?\n([ ]{4}>)/m, '\n```{r}\n\1'
|
200
|
+
# s /([ ]{4}>.*?)\r?\n([ ]{4}[^>])/m, '\1\n```\2'
|
201
|
+
s /```{\.(\S*?) label="(.*?)", eval=TRUE}(.*?)```/m do |match|
|
202
|
+
source_file = prefix + $2 + extension($1)
|
203
|
+
result_file = prefix + $2 + ".res"
|
204
|
+
code = File.new(source_file, "w")
|
205
|
+
code.puts include_before($1)
|
206
|
+
code.puts $3
|
207
|
+
code.close
|
208
|
+
`chmod a+x #{source_file}`
|
209
|
+
`./#{source_file} > #{result_file} 2>&1`
|
210
|
+
"```{.#{$1}}#{$3}```\n\n输出结果\n\n```\n#{IO.read(result_file)}```"
|
211
|
+
end
|
212
|
+
s /^---\r?\n(.*?)^---\r?\n/m do |match|
|
213
|
+
doc_options=YAML::load($1)
|
214
|
+
'#' + doc_options['title'] if doc_options['title']
|
215
|
+
# about_title = doc_options['source'] ? "本文选自 #{doc_options['source']}." : ""
|
216
|
+
# about_title += doc_options['date'] ? "修改日期: #{doc_options['date']}." : ""
|
217
|
+
# about_title = '\thanks{' + about_title + '}' unless about_title == ""
|
218
|
+
# meta_info = ''
|
219
|
+
# meta_info += ('\title{' + doc_options['title'] + about_title + '}') if doc_options['title']
|
220
|
+
# meta_info += ('\author{' + doc_options['author'] + '}') if doc_options['author']
|
221
|
+
# meta_info += '\date{}\maketitle'
|
222
|
+
end
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
226
|
+
def include_before(lang)
|
227
|
+
case lang
|
228
|
+
when "ruby" ; "#!/usr/bin/env ruby"
|
229
|
+
when "bash" ; "#!/bin/bash"
|
230
|
+
when "python"; "#!/usr/bin/python"
|
231
|
+
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
def extension(lang)
|
236
|
+
case lang
|
237
|
+
when "ruby" ; ".rb"
|
238
|
+
when "bash" ; ".sh"
|
239
|
+
when "python"; ".py"
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
243
|
+
def post_pandoc(string)
|
244
|
+
replace(string) do
|
245
|
+
s /{verbatim}/, '{Verbatim}'
|
246
|
+
# s /^.*{Shaded}.*\r?\n/, ''
|
247
|
+
# s /^.*begin{Highlighting}.*\r?\n/, '\\obeylines\\obeyspace'
|
248
|
+
# s /^.*end{Highlighting}.*\r?\n/, ''
|
249
|
+
end
|
250
|
+
end
|
251
|
+
|
252
|
+
|
253
|
+
def log(type,msg)
|
254
|
+
print "[#{type}] #{Time.now} #{msg}"
|
255
|
+
end
|
256
|
+
|
257
|
+
def log_info(msg)
|
258
|
+
log("INFO",msg)
|
259
|
+
end
|
260
|
+
|
261
|
+
def log_error(msg)
|
262
|
+
log("ERROR",msg)
|
263
|
+
end
|
264
|
+
|
265
|
+
def log_debug(msg)
|
266
|
+
log("DEBUG",msg)
|
267
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
\documentclass[adobefonts,fancyhdr,fntef,footer,<%= options["option"] %>]{htexart}
|
2
|
+
|
3
|
+
\title{<%= config_options["title"] %>}
|
4
|
+
\author{<%= config_options["author"] %>}
|
5
|
+
\date{<%= config_options["date"] %>}
|
6
|
+
|
7
|
+
\def\contentsname{<%= config_options["contents"] %>}
|
8
|
+
\def\figurename{<%= config_options["figure"] %>}
|
9
|
+
\def\tablename{<%= config_options["table"] %>}
|
10
|
+
\def\appendixname{<%= config_options["appendix"] %>}
|
11
|
+
|
12
|
+
\begin{document}
|
13
|
+
\maketitle
|
14
|
+
<%= preface %>
|
15
|
+
|
16
|
+
\tableofcontents
|
17
|
+
|
18
|
+
<%= chapters %>
|
19
|
+
|
20
|
+
%\addcontentsline{toc}{section}{\refname}
|
21
|
+
%\bibliography{/usr/local/texlive/2013/texmf-dist/tex/latex/htex/htexbib}
|
22
|
+
\end{document}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
\documentclass[adobefonts,fancyhdr,fntef,footer,<%= options["option"] %>]{htexart}
|
2
|
+
|
3
|
+
\title{<%= config_options["title"] %>}
|
4
|
+
\author{<%= config_options["author"] %>}
|
5
|
+
\date{<%= config_options["date"] %>}
|
6
|
+
|
7
|
+
\def\contentsname{<%= config_options["contents"] %>}
|
8
|
+
\def\figurename{<%= config_options["figure"] %>}
|
9
|
+
\def\tablename{<%= config_options["table"] %>}
|
10
|
+
\def\appendixname{<%= config_options["appendix"] %>}
|
11
|
+
|
12
|
+
\begin{document}
|
13
|
+
|
14
|
+
<%= chapters %>
|
15
|
+
|
16
|
+
\addcontentsline{toc}{section}{\refname}
|
17
|
+
\bibliography{/usr/local/texlive/2013/texmf-dist/tex/latex/htex/htexbib}
|
18
|
+
|
19
|
+
|
20
|
+
\vskip2cm
|
21
|
+
|
22
|
+
\begin{quote}
|
23
|
+
\textbf{开源书屋}致力于建立一整套编写电子书的解决方案, 并提供大量开源免费、高质量的电子书.
|
24
|
+
请关注我们的\href{http://weibo.com/oboooks}{官方微博}, 及时获取最新资源!
|
25
|
+
\end{quote}
|
26
|
+
\end{document}
|
@@ -0,0 +1,36 @@
|
|
1
|
+
\documentclass[adobefonts,fancyhdr,fntef,header,<%= options["option"] %>]{htexbook}
|
2
|
+
|
3
|
+
\title{<%= config_options["title"] %>}
|
4
|
+
\author{<%= config_options["author"] %>}
|
5
|
+
\date{<%= config_options["date"] %>}
|
6
|
+
|
7
|
+
\def\contentsname{<%= config_options["contents"] %>}
|
8
|
+
\def\figurename{<%= config_options["figure"] %>}
|
9
|
+
\def\tablename{<%= config_options["table"] %>}
|
10
|
+
\def\appendixname{<%= config_options["appendix"] %>}
|
11
|
+
% \setcounter{secnumdepth}{1}
|
12
|
+
% \setcounter{tocdepth}{0}
|
13
|
+
\begin{document}
|
14
|
+
\maketitle
|
15
|
+
|
16
|
+
\frontmatter
|
17
|
+
<%= preface %>
|
18
|
+
|
19
|
+
\tableofcontents
|
20
|
+
% \listoffigures
|
21
|
+
% \listoftables
|
22
|
+
|
23
|
+
\mainmatter
|
24
|
+
<%= chapters %>
|
25
|
+
|
26
|
+
\begin{appendix}
|
27
|
+
<%= appendix %>
|
28
|
+
\end{appendix}
|
29
|
+
|
30
|
+
\backmatter
|
31
|
+
\addcontentsline{toc}{chapter}{\refname}
|
32
|
+
\bibliography{/usr/local/texlive/2013/texmf-dist/tex/latex/htex/htexbib}
|
33
|
+
\newpage
|
34
|
+
\addcontentsline{toc}{chapter}{\indexname}
|
35
|
+
\printindex
|
36
|
+
\end{document}
|
@@ -0,0 +1,33 @@
|
|
1
|
+
\documentclass[a5paper,final,narrow,fancyhdr,adobefonts,<%= "english," if options["lang"]=="en" %><%= options["template"] %>,equal,openany,code]{htexbook}
|
2
|
+
|
3
|
+
\title{<%= config_options["title"] %>}
|
4
|
+
\author{<%= config_options["author"] %>}
|
5
|
+
\date{<%= config_options["date"] %>}
|
6
|
+
\no{1}
|
7
|
+
|
8
|
+
\def\contentsname{<%= config_options["contents"] %>}
|
9
|
+
\def\figurename{<%= config_options["figure"] %>}
|
10
|
+
\def\tablename{<%= config_options["table"] %>}
|
11
|
+
\def\appendixname{<%= config_options["appendix"] %>}
|
12
|
+
\begin{document}
|
13
|
+
\include{head}
|
14
|
+
\maketitle
|
15
|
+
|
16
|
+
\AddToShipoutPicture{\oldincludegraphics[width=\paperwidth,height=\paperheight]{background}}
|
17
|
+
\pagenumbering{roman}
|
18
|
+
<%= preface %>
|
19
|
+
|
20
|
+
\tableofcontents
|
21
|
+
% \listoffigures
|
22
|
+
% \listoftables
|
23
|
+
|
24
|
+
\newpage
|
25
|
+
\pagenumbering{arabic}
|
26
|
+
<%= chapters %>
|
27
|
+
|
28
|
+
\begin{appendix}
|
29
|
+
<%= appendix %>
|
30
|
+
\end{appendix}
|
31
|
+
|
32
|
+
% \include{foot}
|
33
|
+
\end{document}
|
@@ -0,0 +1,36 @@
|
|
1
|
+
\documentclass[adobefonts,fancyhdr,fntef,header,<%= options["option"] %>]{htexbook}
|
2
|
+
|
3
|
+
\title{<%= config_options["title"] %>}
|
4
|
+
\author{<%= config_options["author"] %>}
|
5
|
+
\date{<%= config_options["date"] %>}
|
6
|
+
|
7
|
+
\def\contentsname{<%= config_options["contents"] %>}
|
8
|
+
\def\figurename{<%= config_options["figure"] %>}
|
9
|
+
\def\tablename{<%= config_options["table"] %>}
|
10
|
+
\def\appendixname{<%= config_options["appendix"] %>}
|
11
|
+
\setcounter{secnumdepth}{-2}
|
12
|
+
\setcounter{tocdepth}{0}
|
13
|
+
\begin{document}
|
14
|
+
\maketitle
|
15
|
+
|
16
|
+
\frontmatter
|
17
|
+
<%= preface %>
|
18
|
+
|
19
|
+
\tableofcontents
|
20
|
+
% \listoffigures
|
21
|
+
% \listoftables
|
22
|
+
|
23
|
+
\mainmatter
|
24
|
+
<%= chapters %>
|
25
|
+
|
26
|
+
\begin{appendix}
|
27
|
+
<%= appendix %>
|
28
|
+
\end{appendix}
|
29
|
+
|
30
|
+
\backmatter
|
31
|
+
\addcontentsline{toc}{chapter}{\refname}
|
32
|
+
\bibliography{/usr/local/texlive/2013/texmf-dist/tex/latex/htex/htexbib}
|
33
|
+
\newpage
|
34
|
+
\addcontentsline{toc}{chapter}{\indexname}
|
35
|
+
\printindex
|
36
|
+
\end{document}
|
@@ -0,0 +1,31 @@
|
|
1
|
+
\documentclass[a5paper,final,narrow,fancyhdr,adobefonts,graph,<%= "english," if options["lang"]=="en" %><%= options["template"] %>,equal,openany,code]{htexbook}
|
2
|
+
|
3
|
+
\title{<%= config_options["title"] %>}
|
4
|
+
\author{<%= config_options["author"] %>}
|
5
|
+
\date{<%= config_options["date"] %>}
|
6
|
+
|
7
|
+
\def\contentsname{<%= config_options["contents"] %>}
|
8
|
+
\def\figurename{<%= config_options["figure"] %>}
|
9
|
+
\def\tablename{<%= config_options["table"] %>}
|
10
|
+
\def\appendixname{<%= config_options["appendix"] %>}
|
11
|
+
\begin{document}
|
12
|
+
\include{head}
|
13
|
+
\maketitle
|
14
|
+
|
15
|
+
\pagenumbering{roman}
|
16
|
+
<%= preface %>
|
17
|
+
|
18
|
+
\tableofcontents
|
19
|
+
% \listoffigures
|
20
|
+
% \listoftables
|
21
|
+
|
22
|
+
\newpage
|
23
|
+
\pagenumbering{arabic}
|
24
|
+
<%= chapters %>
|
25
|
+
|
26
|
+
\begin{appendix}
|
27
|
+
<%= appendix %>
|
28
|
+
\end{appendix}
|
29
|
+
|
30
|
+
% \include{foot}
|
31
|
+
\end{document}
|
metadata
CHANGED
@@ -1,80 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mkbook
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Henry He
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
12
|
-
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: bundler
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ~>
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '1.10'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ~>
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '1.10'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: rake
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ~>
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '10.0'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ~>
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '10.0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: rspec
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - '>='
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - '>='
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
11
|
+
date: 2013-08-26 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
55
13
|
description: the ebook generate tools from markdown plain text
|
56
14
|
email:
|
57
15
|
- henryhyn@163.com
|
58
|
-
executables:
|
16
|
+
executables:
|
17
|
+
- mkbook
|
59
18
|
extensions: []
|
60
19
|
extra_rdoc_files: []
|
61
20
|
files:
|
62
|
-
-
|
63
|
-
- .
|
64
|
-
- .
|
65
|
-
-
|
66
|
-
-
|
67
|
-
-
|
68
|
-
-
|
69
|
-
-
|
70
|
-
-
|
71
|
-
-
|
72
|
-
-
|
73
|
-
-
|
74
|
-
-
|
75
|
-
|
76
|
-
|
77
|
-
-
|
21
|
+
- bin/mkbook
|
22
|
+
- lib/config.yml
|
23
|
+
- lib/make_book.rb
|
24
|
+
- lib/template_article.tex
|
25
|
+
- lib/template_blog.tex
|
26
|
+
- lib/template_book.tex
|
27
|
+
- lib/template_fancy.tex
|
28
|
+
- lib/template_novel.tex
|
29
|
+
- lib/template_plain.tex
|
30
|
+
- template/.mkbook.yml
|
31
|
+
- template/en/appx01-abbreviation.md
|
32
|
+
- template/en/chap01-introduce.md
|
33
|
+
- template/en/preface.md
|
34
|
+
- template/images/README.md
|
35
|
+
- template/resources/README.md
|
36
|
+
- template/zh/appx01-abbreviation.md
|
37
|
+
- template/zh/chap01-introduce.md
|
38
|
+
- template/zh/preface.md
|
39
|
+
homepage:
|
40
|
+
licenses: []
|
78
41
|
metadata: {}
|
79
42
|
post_install_message:
|
80
43
|
rdoc_options: []
|
@@ -92,8 +55,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
92
55
|
version: '0'
|
93
56
|
requirements: []
|
94
57
|
rubyforge_project:
|
95
|
-
rubygems_version: 2.0.
|
58
|
+
rubygems_version: 2.0.3
|
96
59
|
signing_key:
|
97
60
|
specification_version: 4
|
98
|
-
summary:
|
61
|
+
summary: mkbook is a ebook maker.
|
99
62
|
test_files: []
|
data/.gitignore
DELETED
data/.rspec
DELETED
data/.travis.yml
DELETED
data/CODE_OF_CONDUCT.md
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
# Contributor Code of Conduct
|
2
|
-
|
3
|
-
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
-
|
5
|
-
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
|
6
|
-
|
7
|
-
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
-
|
9
|
-
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
-
|
11
|
-
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
|
-
|
13
|
-
This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/Gemfile
DELETED
data/LICENSE.txt
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
The MIT License (MIT)
|
2
|
-
|
3
|
-
Copyright (c) 2015 Henry He
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
7
|
-
in the Software without restriction, including without limitation the rights
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
10
|
-
furnished to do so, subject to the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
13
|
-
all copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
-
THE SOFTWARE.
|
data/README.md
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
# Mkbook
|
2
|
-
|
3
|
-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/mkbook`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
6
|
-
|
7
|
-
## Installation
|
8
|
-
|
9
|
-
Add this line to your application's Gemfile:
|
10
|
-
|
11
|
-
```ruby
|
12
|
-
gem 'mkbook'
|
13
|
-
```
|
14
|
-
|
15
|
-
And then execute:
|
16
|
-
|
17
|
-
$ bundle
|
18
|
-
|
19
|
-
Or install it yourself as:
|
20
|
-
|
21
|
-
$ gem install mkbook
|
22
|
-
|
23
|
-
## Usage
|
24
|
-
|
25
|
-
TODO: Write usage instructions here
|
26
|
-
|
27
|
-
## Development
|
28
|
-
|
29
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
-
|
31
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
-
|
33
|
-
## Contributing
|
34
|
-
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/mkbook. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
|
36
|
-
|
37
|
-
|
38
|
-
## License
|
39
|
-
|
40
|
-
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
41
|
-
|
data/Rakefile
DELETED
data/bin/console
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "bundler/setup"
|
4
|
-
require "mkbook"
|
5
|
-
|
6
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
-
# with your gem easier. You can also use a different console, if you like.
|
8
|
-
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
# require "pry"
|
11
|
-
# Pry.start
|
12
|
-
|
13
|
-
require "irb"
|
14
|
-
IRB.start
|
data/bin/setup
DELETED
data/lib/mkbook/version.rb
DELETED
data/lib/mkbook.rb
DELETED
data/mkbook.gemspec
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'mkbook/version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = 'mkbook'
|
8
|
-
spec.version = Mkbook::VERSION
|
9
|
-
spec.authors = ['Henry He']
|
10
|
-
spec.email = ['henryhyn@163.com']
|
11
|
-
|
12
|
-
spec.summary = %q{tools to generate ebooks from markdown}
|
13
|
-
spec.description = %q{the ebook generate tools from markdown plain text}
|
14
|
-
spec.homepage = 'https://github.com/henryhyn/mkbook'
|
15
|
-
spec.license = 'MIT'
|
16
|
-
|
17
|
-
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
-
spec.bindir = 'exe'
|
19
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
-
spec.require_paths = ['lib']
|
21
|
-
|
22
|
-
spec.add_development_dependency 'bundler', '~> 1.10'
|
23
|
-
spec.add_development_dependency 'rake', '~> 10.0'
|
24
|
-
spec.add_development_dependency 'rspec'
|
25
|
-
end
|