rb_latex 0.4.0 → 0.5.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/lib/rb_latex.rb +1 -1
- data/lib/rb_latex/maker.rb +15 -6
- data/lib/rb_latex/meta_info.rb +10 -2
- data/lib/rb_latex/utils.rb +1 -1
- data/lib/rb_latex/version.rb +1 -1
- data/templates/book.tex.erb +6 -0
- data/templates/colophon.tex.erb +7 -1
- data/templates/rblatexdefault.sty +3 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f23586d00b1e945e6b2d7be44e10132f18f5e5887805727d61388e813a426978
|
4
|
+
data.tar.gz: ab0cd3bdbf6578bde98a32c358c54470f93bcf8b035b03e696672c24bd25ad63
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eddef7a892507795391daf04981430594eddd564a99ad8e782c76447c17e8a9071799e52eec454aebc7635bf846f14743ed885924d91e45fbc8a76c6bd78ebe7
|
7
|
+
data.tar.gz: 2f19b3faab3c6c07c5e36dbcd6253b1021746d59eec25f1b52c4c868bf23dbe11b64b9a480f9bf278ddb276fce5edd974a71fd740d9f9158a7d4c0f5b4a89594
|
data/lib/rb_latex.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
require "rb_latex/version"
|
2
2
|
require "rb_latex/error"
|
3
|
+
require "rb_latex/utils"
|
3
4
|
require "rb_latex/maker"
|
4
5
|
require "rb_latex/item_list"
|
5
6
|
require "rb_latex/meta_info"
|
6
7
|
require "rb_latex/logger"
|
7
|
-
require "rb_latex/utils"
|
8
8
|
|
9
9
|
module RbLatex
|
10
10
|
TEMPLATES_DIR = File.join(File.dirname(__FILE__), "../templates")
|
data/lib/rb_latex/maker.rb
CHANGED
@@ -12,7 +12,11 @@ module RbLatex
|
|
12
12
|
attr_accessor :dvipdf_command
|
13
13
|
attr_accessor :debug
|
14
14
|
attr_accessor :book_name
|
15
|
-
attr_accessor :
|
15
|
+
attr_accessor :titlepage
|
16
|
+
attr_accessor :colophon
|
17
|
+
attr_accessor :colophon_before
|
18
|
+
attr_accessor :colophon_after
|
19
|
+
attr_accessor :colophon_template
|
16
20
|
attr_reader :work_dir
|
17
21
|
|
18
22
|
RbLatex::MetaInfo::ATTRS.each do |name|
|
@@ -37,7 +41,11 @@ module RbLatex
|
|
37
41
|
@debug = nil
|
38
42
|
@book_name = "book"
|
39
43
|
@default_option = nil
|
40
|
-
@
|
44
|
+
@colophon_template = "colophon.tex.erb"
|
45
|
+
@colophon = nil
|
46
|
+
@colophon_before = nil
|
47
|
+
@colophon_after = nil
|
48
|
+
@titlepage = nil
|
41
49
|
end
|
42
50
|
|
43
51
|
def add_item(filename, content)
|
@@ -79,8 +87,8 @@ module RbLatex
|
|
79
87
|
File.write(File.join(dir, book_filename(".tex")), book_tex)
|
80
88
|
rblatexdefault_sty = apply_template("rblatexdefault.sty")
|
81
89
|
File.write(File.join(dir, "rblatexdefault.sty"), rblatexdefault_sty)
|
82
|
-
if @
|
83
|
-
colophon_tex = apply_template(
|
90
|
+
if @colophon
|
91
|
+
colophon_tex = apply_template(@colophon_template, template_dir: @colophon_dir)
|
84
92
|
File.write(File.join(dir, "colophon.tex"), colophon_tex)
|
85
93
|
end
|
86
94
|
end
|
@@ -142,8 +150,9 @@ module RbLatex
|
|
142
150
|
end
|
143
151
|
end
|
144
152
|
|
145
|
-
def apply_template(template_file)
|
146
|
-
|
153
|
+
def apply_template(template_file, template_dir: nil)
|
154
|
+
template_dir ||= RbLatex::TEMPLATES_DIR
|
155
|
+
template = File.read(File.join(template_dir, template_file))
|
147
156
|
return ERB.new(template, nil, '-').result(binding)
|
148
157
|
end
|
149
158
|
|
data/lib/rb_latex/meta_info.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
module RbLatex
|
2
2
|
class MetaInfo
|
3
|
+
include RbLatex::Utils
|
3
4
|
|
4
5
|
ATTRS = %i(title creator page_progression_direction language publisher)
|
5
6
|
|
@@ -43,15 +44,22 @@ module RbLatex
|
|
43
44
|
end
|
44
45
|
|
45
46
|
def to_latex
|
47
|
+
"\\title{#{escape_latex(title)}}\n"+
|
48
|
+
"\\author{#{escape_latex(author)}}\n"+
|
49
|
+
"\\date{}\n"+
|
46
50
|
"\\newcommand{\\rblatexTitle}{#{escape_latex(title)}}\n"+
|
47
51
|
"\\newcommand{\\rblatexAuthor}{#{escape_latex(author)}}\n"+
|
48
|
-
"\\newcommand{\\rblatexPubdate}{#{escape_latex(
|
52
|
+
"\\newcommand{\\rblatexPubdate}{#{escape_latex(pubdate_to_s)}}\n"+
|
49
53
|
"\\newcommand{\\rblatexPublisher}{#{escape_latex(publisher)}}\n"+
|
50
54
|
"\\newcommand{\\rblatexPageDirection}{#{escape_latex(page_progression_direction)}}\n"
|
51
55
|
end
|
52
56
|
|
53
57
|
def date_format(time)
|
54
|
-
time
|
58
|
+
if time
|
59
|
+
time.strftime("%Y年%-m月%-d日")
|
60
|
+
else
|
61
|
+
""
|
62
|
+
end
|
55
63
|
end
|
56
64
|
|
57
65
|
def add_creator(name, role)
|
data/lib/rb_latex/utils.rb
CHANGED
data/lib/rb_latex/version.rb
CHANGED
data/templates/book.tex.erb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
\documentclass[<%= @dclass_option %>]{<%= @dclass %>}
|
2
2
|
|
3
|
+
%% meta_info
|
4
|
+
<%= @meta_info.to_latex %>
|
5
|
+
|
3
6
|
%% load RbLatex default stlye
|
4
7
|
\usepackage[<%= @default_option %>]{rblatexdefault}
|
5
8
|
|
@@ -9,6 +12,9 @@
|
|
9
12
|
}
|
10
13
|
|
11
14
|
\begin{document}
|
15
|
+
<% if @titlepage %>
|
16
|
+
\maketitle
|
17
|
+
<% end %>
|
12
18
|
<% @item_list.filenames.each_with_index do |filename, idx| %>
|
13
19
|
\input{<%= filename %>}
|
14
20
|
<% if @item_list.filenames.size > idx + 1 %>
|
data/templates/colophon.tex.erb
CHANGED
@@ -1,8 +1,11 @@
|
|
1
1
|
\newpage
|
2
2
|
\thispagestyle{empty}
|
3
3
|
\vspace*{\fill}
|
4
|
+
{\noindent\Large \rblatexTitle } \\
|
5
|
+
\rule[0pt]{\textwidth}{0.5pt} \\
|
6
|
+
<%= @colophon_before || "\\rblatexColophonBefore" %>
|
4
7
|
\begin{tabular}{ll}
|
5
|
-
<%- @
|
8
|
+
<%- @colophon.each do |key, val| -%>
|
6
9
|
<%- if val.kind_of? Array -%>
|
7
10
|
<%- val.each_with_index do |item, idx| -%>
|
8
11
|
<%- if idx > 0 -%>
|
@@ -16,3 +19,6 @@
|
|
16
19
|
<%- end -%>
|
17
20
|
<%- end -%>
|
18
21
|
\end{tabular}
|
22
|
+
~ \\
|
23
|
+
\rule[0pt]{\textwidth}{0.5pt} \\
|
24
|
+
{\small <%= @colophon_after || "\\rblatexColophonAfter" %>}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rb_latex
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- takahashim
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-06-
|
11
|
+
date: 2018-06-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|