rb_latex 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rb_latex/maker.rb +19 -19
- data/lib/rb_latex/version.rb +1 -1
- data/templates/book.tex.erb +4 -6
- data/templates/rblatexdefault.sty +5 -8
- 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: dad0ca7be7d5e599b0d18cb0f14a5b687375159b581ce703c1f736e06128ac40
|
4
|
+
data.tar.gz: 901e7d2140823b9faa57d1f8085d8cdc063da5680de6e83489458c9cd4c1e805
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d97a6af5181ee7d18311a73630200dbb0dbb245dcca3971b6e4e95dabe9561832b7afd0b492f4955d173261402c30a8c681a7bf9207ed29948a7150cacfa4410
|
7
|
+
data.tar.gz: 7be3517b348028970c83a84bad4b90028db1fea4c70a9a257791c384841cb2895a7cd0feeb6e93845f88e92828c9fbc450a06dc9edf6eb4638ad299f478e3463
|
data/lib/rb_latex/maker.rb
CHANGED
@@ -11,6 +11,8 @@ module RbLatex
|
|
11
11
|
attr_accessor :latex_command
|
12
12
|
attr_accessor :dvipdf_command
|
13
13
|
attr_accessor :debug
|
14
|
+
attr_accessor :book_name
|
15
|
+
attr_reader :work_dir
|
14
16
|
|
15
17
|
RbLatex::MetaInfo::ATTRS.each do |name|
|
16
18
|
def_delegator :@meta_info, name
|
@@ -18,18 +20,11 @@ module RbLatex
|
|
18
20
|
def_delegator :@meta_info, name_eq
|
19
21
|
end
|
20
22
|
|
21
|
-
|
22
|
-
def_delegator :@meta_info, :date=
|
23
|
-
def_delegator :@meta_info, :lastmodified
|
24
|
-
def_delegator :@meta_info, :lastmodified=
|
25
|
-
def_delegator :@meta_info, :add_creator
|
26
|
-
|
27
|
-
attr_reader :work_dir
|
23
|
+
def_delegators :@meta_info, :date, :date=, :lastmodified, :lastmodified=, :add_creator
|
28
24
|
|
29
25
|
def initialize(root_dir)
|
30
26
|
@root_dir = root_dir
|
31
27
|
@root_fullpath = File.absolute_path(root_dir)
|
32
|
-
@config = default_config
|
33
28
|
@work_dir = ".rblatex_work"
|
34
29
|
@item_list = RbLatex::ItemList.new
|
35
30
|
@meta_info = RbLatex::MetaInfo.new
|
@@ -37,16 +32,18 @@ module RbLatex
|
|
37
32
|
@dvipdf_command = "dvipdfmx"
|
38
33
|
@document_class = ["jlreq", "book,b5paper,openany"]
|
39
34
|
@debug = nil
|
40
|
-
|
41
|
-
|
42
|
-
def default_config
|
43
|
-
{}
|
35
|
+
@book_name = "book"
|
36
|
+
@default_option = nil
|
44
37
|
end
|
45
38
|
|
46
39
|
def add_item(filename, content)
|
47
40
|
@item_list.add_item(filename, content)
|
48
41
|
end
|
49
42
|
|
43
|
+
def book_filename(ext = ".pdf")
|
44
|
+
"#{@book_name}#{ext}"
|
45
|
+
end
|
46
|
+
|
50
47
|
def generate_pdf(filename, debug: nil)
|
51
48
|
in_working_dir(debug) do |dir|
|
52
49
|
copy_files(dir)
|
@@ -54,7 +51,7 @@ module RbLatex
|
|
54
51
|
generate_src(dir)
|
55
52
|
compile_latex(dir)
|
56
53
|
end
|
57
|
-
FileUtils.cp(File.join(dir,
|
54
|
+
FileUtils.cp(File.join(dir, book_filename), filename)
|
58
55
|
end
|
59
56
|
end
|
60
57
|
|
@@ -67,18 +64,21 @@ module RbLatex
|
|
67
64
|
|
68
65
|
def generate_src(dir)
|
69
66
|
@item_list.generate(dir)
|
70
|
-
@dclass, @
|
71
|
-
if @meta_info.page_progression_direction == "rtl" && !@
|
72
|
-
@
|
67
|
+
@dclass, @dclass_option = @document_class
|
68
|
+
if @meta_info.page_progression_direction == "rtl" && !@dclass_option.split(",").include?("tate")
|
69
|
+
@dclass_option += ",tate"
|
70
|
+
end
|
71
|
+
if @latex_command =~ /lualatex/
|
72
|
+
@default_option = "lualatex"
|
73
73
|
end
|
74
74
|
book_tex = apply_template("book.tex.erb")
|
75
|
-
File.write(File.join(dir, "
|
75
|
+
File.write(File.join(dir, book_filename(".tex")), book_tex)
|
76
76
|
rblatexdefault_sty = apply_template("rblatexdefault.sty")
|
77
77
|
File.write(File.join(dir, "rblatexdefault.sty"), rblatexdefault_sty)
|
78
78
|
end
|
79
79
|
|
80
80
|
def compile_latex(dir)
|
81
|
-
texfile = "
|
81
|
+
texfile = book_filename(".tex")
|
82
82
|
cmd = "#{@latex_command} #{texfile}"
|
83
83
|
3.times do |i|
|
84
84
|
out, status = Open3.capture2e(cmd)
|
@@ -90,7 +90,7 @@ module RbLatex
|
|
90
90
|
raise RbLatex::Error, "fail to exec latex (#{i}): #{cmd}"
|
91
91
|
end
|
92
92
|
end
|
93
|
-
dvifile =
|
93
|
+
dvifile = book_filename(".dvi")
|
94
94
|
if File.exist?(dvifile)
|
95
95
|
exec_dvipdf(dvifile)
|
96
96
|
end
|
data/lib/rb_latex/version.rb
CHANGED
data/templates/book.tex.erb
CHANGED
@@ -1,11 +1,9 @@
|
|
1
|
-
\documentclass[<%= @
|
1
|
+
\documentclass[<%= @dclass_option %>]{<%= @dclass %>}
|
2
2
|
|
3
|
-
|
4
|
-
\usepackage[
|
5
|
-
<% else %>
|
6
|
-
\usepackage[dvipdfmx]{rblatexdefault}
|
7
|
-
<% end %>
|
3
|
+
%% load RbLatex default stlye
|
4
|
+
\usepackage[<%= @default_option %>]{rblatexdefault}
|
8
5
|
|
6
|
+
%% load RbLatex custom style (if you have)
|
9
7
|
\IfFileExists{rblatexcustom.sty}{
|
10
8
|
\usepackage{rblatexcustom}
|
11
9
|
}
|
@@ -2,10 +2,7 @@
|
|
2
2
|
|
3
3
|
\newif\ifrblatex@luatex
|
4
4
|
\rblatex@luatexfalse
|
5
|
-
\newif\ifrblatex@dvipdfmx
|
6
|
-
\rblatex@dvipdfmxfalse
|
7
5
|
\DeclareOption{luatex}{\rblatex@luatextrue}
|
8
|
-
\DeclareOption{dvipdfmx}{\rblatex@dvipdfmxtrue}
|
9
6
|
\ProcessOptions\relax
|
10
7
|
|
11
8
|
\RequirePackage[utf8]{inputenc}
|
@@ -17,15 +14,14 @@
|
|
17
14
|
\RequirePackage{amsthm}
|
18
15
|
\RequirePackage{amsfonts}
|
19
16
|
\RequirePackage{longtable}
|
20
|
-
\RequirePackage{graphicx}
|
21
17
|
\RequirePackage{pxrubrica}
|
22
18
|
|
23
|
-
\ifrblatex@luatex
|
19
|
+
\ifrblatex@luatex
|
20
|
+
\RequirePackage[luatex]{graphicx}
|
24
21
|
\RequirePackage[luatex,pdfencoding=auto]{hyperref}
|
25
22
|
\RequirePackage{lltjext}
|
26
|
-
\
|
27
|
-
|
28
|
-
\ifrblatex@dvipdfmx%
|
23
|
+
\else %% default
|
24
|
+
\RequirePackage[dvipdfmx]{graphicx}
|
29
25
|
\RequirePackage[dvipdfmx]{hyperref}
|
30
26
|
\RequirePackage{pxjahyper}
|
31
27
|
\RequirePackage{plext}
|
@@ -35,5 +31,6 @@
|
|
35
31
|
\VerbatimFootnotes
|
36
32
|
\setlength{\parindent}{0pt}
|
37
33
|
\newcommand{\rblatexFileSeparator}{\newpage}
|
34
|
+
\newcommand{\rblatexEmptyLine}{\hspace{0pt}\par}
|
38
35
|
|
39
36
|
\endinput
|
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.3.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-05-
|
11
|
+
date: 2018-05-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|