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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c0b9a42b31411e59612673356412e6f753f6d8786a0218a144473718e3f49d5f
4
- data.tar.gz: 271eb929d4d760929d7b4a42ff122022c57dcf91a262669f50dfb9836b9adf86
3
+ metadata.gz: dad0ca7be7d5e599b0d18cb0f14a5b687375159b581ce703c1f736e06128ac40
4
+ data.tar.gz: 901e7d2140823b9faa57d1f8085d8cdc063da5680de6e83489458c9cd4c1e805
5
5
  SHA512:
6
- metadata.gz: 55275c961565f9baf3b50299c59fa2f372ff51424a7868bff72797e60df37d14ea779582664d8836154ef81d98db34cc599c8f81955b835d37804fe6a50d9bfb
7
- data.tar.gz: 48dfbb3ed6f6be6a48ea1fd486177e64cca9a13ebe5b20220e99c01391af7733777de3a728777b8c06559fbc775a8c33a00cd19484c84310a0c6eba913194bdc
6
+ metadata.gz: d97a6af5181ee7d18311a73630200dbb0dbb245dcca3971b6e4e95dabe9561832b7afd0b492f4955d173261402c30a8c681a7bf9207ed29948a7150cacfa4410
7
+ data.tar.gz: 7be3517b348028970c83a84bad4b90028db1fea4c70a9a257791c384841cb2895a7cd0feeb6e93845f88e92828c9fbc450a06dc9edf6eb4638ad299f478e3463
@@ -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
- def_delegator :@meta_info, :date
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
- end
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, "book.pdf"), filename)
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, @dclass_opt = @document_class
71
- if @meta_info.page_progression_direction == "rtl" && !@dclass_opt.split(",").include?("tate")
72
- @dclass_opt += ",tate"
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, "book.tex"), book_tex)
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 = "book.tex"
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 = File.basename(texfile, ".*") + ".dvi"
93
+ dvifile = book_filename(".dvi")
94
94
  if File.exist?(dvifile)
95
95
  exec_dvipdf(dvifile)
96
96
  end
@@ -1,3 +1,3 @@
1
1
  module RbLatex
2
- VERSION = "0.2.2"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -1,11 +1,9 @@
1
- \documentclass[<%= @dclass_opt %>]{<%= @dclass %>}
1
+ \documentclass[<%= @dclass_option %>]{<%= @dclass %>}
2
2
 
3
- <% if @latex_command =~ /lualatex/ %>
4
- \usepackage[luatex]{rblatexdefault}
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
- \fi
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.2.2
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-10 00:00:00.000000000 Z
11
+ date: 2018-05-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler