rb_latex 0.1.4 → 0.2.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: 5c9340241294fb887b1302e3e807067f3747ffdc42e068c20b561415fd7c7f55
4
- data.tar.gz: a4d435a081863e558f0af4c462aa11e056412a6546bc5c86118b3af9f6970fda
3
+ metadata.gz: bd8e99354f0b7d152e5466c710c743e515de594eb09a56f0265c648d1ccd262b
4
+ data.tar.gz: 3a8bf199de7ab0a7f34180944b4e7caee6acd68012dd1905aaeaaa31d600ec40
5
5
  SHA512:
6
- metadata.gz: '090761fdba380cb25eb210e0464bdd81b5a7f0d9f084e086c70b82388c6bb99bd07d9a1c83112ccd19050a16568ee91be3771d8861f73cd18716206b784483da'
7
- data.tar.gz: 06d79fd6fa249e19204527e5304531182996c6f287b3f3a6adc211b4f83faae2b2d181fb2a6c14b31762e3fe7ca077ab8486466ac95ea5aac1f7b1eb607466a6
6
+ metadata.gz: 348c9651bdae4cdec8fa1b20215653849663b624e65c0f4d81de8992a807d94443331d7c52a781eaa6a1d49f52488379ceb0fddd45d784ab068ed658be344890
7
+ data.tar.gz: 63412c101551da4bdf69ed111c5628beda8d862d28b63a9f4019643da124b8c6ab22070aa9846d2bd4ea7b4a09fac6f9813264baf750fb8ea66b7a8d37570438
@@ -8,6 +8,9 @@ module RbLatex
8
8
  extend Forwardable
9
9
 
10
10
  attr_accessor :document_class
11
+ attr_accessor :latex_command
12
+ attr_accessor :dvipdf_command
13
+ attr_accessor :debug
11
14
 
12
15
  RbLatex::MetaInfo::ATTRS.each do |name|
13
16
  def_delegator :@meta_info, name
@@ -30,9 +33,10 @@ module RbLatex
30
33
  @work_dir = ".rblatex_work"
31
34
  @item_list = RbLatex::ItemList.new
32
35
  @meta_info = RbLatex::MetaInfo.new
33
- @latex_cmd = "uplatex"
34
- @dvipdfmx_cmd = "dvipdfmx"
36
+ @latex_command = "uplatex"
37
+ @dvipdf_command = "dvipdfmx"
35
38
  @document_class = ["jlreq", "book,b5paper,openany"]
39
+ @debug = nil
36
40
  end
37
41
 
38
42
  def default_config
@@ -49,14 +53,15 @@ module RbLatex
49
53
  Dir.chdir(dir) do
50
54
  generate_src(dir)
51
55
  exec_latex(dir)
52
- exec_dvipdfmx(dir)
56
+ exec_dvipdf(dir)
53
57
  end
58
+ FileUtils.cp(File.join(dir, "book.pdf"), filename)
54
59
  end
55
60
  end
56
61
 
57
62
  def copy_files(dir)
58
63
  Dir.entries(@root_dir).each do |path|
59
- next if path == "." or path == ".."
64
+ next if path == "." or path == ".." or path =~ /\A\.rblatex/
60
65
  FileUtils.cp_r(File.join(@root_dir, path), dir, dereference_root: true)
61
66
  end
62
67
  end
@@ -69,27 +74,32 @@ module RbLatex
69
74
  end
70
75
  book_tex = apply_template("book.tex.erb")
71
76
  File.write(File.join(dir, "book.tex"), book_tex)
77
+ rblatexdefault_sty = apply_template("rblatexdefault.sty")
78
+ File.write(File.join(dir, "rblatexdefault.sty"), rblatexdefault_sty)
72
79
  end
73
80
 
74
81
  def exec_latex(dir)
75
- cmd = "#{@latex_cmd} book.tex"
82
+ cmd = "#{@latex_command} book.tex"
76
83
  3.times do |i|
77
84
  out, status = Open3.capture2e(cmd)
78
85
  if !status.success?
79
86
  @error_log = out
80
- raise RbLatex::Error, "fail to exec latex #{i}: #{cmd}"
87
+ if @debug
88
+ print STDERR, @error_log, "\n"
89
+ end
90
+ raise RbLatex::Error, "fail to exec latex (#{i}): #{cmd}"
81
91
  end
82
92
  end
83
93
  end
84
94
 
85
- def exec_dvipdfmx(dir)
86
- cmd = "#{@dvipdfmx_cmd} book.dvi"
95
+ def exec_dvipdf(dir)
96
+ return unless @dvipdf_command
97
+ cmd = "#{@dvipdf_command} book.dvi"
87
98
  out, status = Open3.capture2e(cmd)
88
99
  if !status.success?
89
100
  @error_log = out
90
- raise RbLatex::Error, "fail to exec latex #{i}: #{cmd}"
101
+ raise RbLatex::Error, "fail to exec dvipdf: #{cmd}"
91
102
  end
92
- FileUtils.cp("book.pdf", File.join(@root_fullpath, "book.pdf"))
93
103
  end
94
104
 
95
105
  def work_dir=(dir)
@@ -1,3 +1,3 @@
1
1
  module RbLatex
2
- VERSION = "0.1.4"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -1,33 +1,20 @@
1
1
  \documentclass[<%= @dclass_opt %>]{<%= @dclass %>}
2
- \usepackage[utf8]{inputenc}
3
- \usepackage[T1]{fontenc}
4
- \usepackage{plext}
5
- \usepackage{listings}
6
- \usepackage[dvipdfmx]{hyperref}
7
- \usepackage{pxjahyper}
8
- \usepackage{fancyvrb}
9
- \usepackage{amssymb}
10
- \usepackage{amsmath}
11
- \usepackage{amsthm}
12
- \usepackage{amsfonts}
13
- \usepackage{longtable}
14
- \usepackage{graphicx}
15
- \usepackage{pxrubrica}
16
- \newcommand{\rblatexNewpage}{\newpage}
17
2
 
18
- %%\usepackage{acronym}
19
-
20
- \VerbatimFootnotes
21
-
22
- \hypersetup{colorlinks=false,urlcolor=blue}
3
+ <% if @latex_command =~ /lualatex/ %>
4
+ \usepackage[luatex]{rblatexdefault}
5
+ <% else %>
6
+ \usepackage[dvipdfmx]{rblatexdefault}
7
+ <% end %>
23
8
 
24
- \setlength{\parindent}{0pt}
9
+ \IfFileExists{rblatexcustom.sty}{
10
+ \usepackage{rblatexcustom}
11
+ }
25
12
 
26
13
  \begin{document}
27
14
  <% @item_list.filenames.each_with_index do |filename, idx| %>
28
15
  \input{<%= filename %>}
29
16
  <% if @item_list.filenames.size > idx + 1 %>
30
- \rblatexNewpage
17
+ \rblatexFileSeparator
31
18
  <% end %>
32
19
  <% end %>
33
20
  \end{document}
@@ -0,0 +1,39 @@
1
+ \ProvidesPackage{rblatexdefault}[2018/05/09 v1.0]
2
+
3
+ \newif\ifrblatex@luatex
4
+ \rblatex@luatexfalse
5
+ \newif\ifrblatex@dvipdfmx
6
+ \rblatex@dvipdfmxfalse
7
+ \DeclareOption{luatex}{\rblatex@luatextrue}
8
+ \DeclareOption{dvipdfmx}{\rblatex@dvipdfmxtrue}
9
+ \ProcessOptions\relax
10
+
11
+ \RequirePackage[utf8]{inputenc}
12
+ \RequirePackage[T1]{fontenc}
13
+ \RequirePackage{listings}
14
+ \RequirePackage{fancyvrb}
15
+ \RequirePackage{amssymb}
16
+ \RequirePackage{amsmath}
17
+ \RequirePackage{amsthm}
18
+ \RequirePackage{amsfonts}
19
+ \RequirePackage{longtable}
20
+ \RequirePackage{graphicx}
21
+ \RequirePackage{pxrubrica}
22
+
23
+ \ifrblatex@luatex%
24
+ \RequirePackage[luatex,pdfencoding=auto]{hyperref}
25
+ \RequirePackage{lltjext}
26
+ \fi
27
+
28
+ \ifrblatex@dvipdfmx%
29
+ \RequirePackage[dvipdfmx]{hyperref}
30
+ \RequirePackage{pxjahyper}
31
+ \RequirePackage{plext}
32
+ \fi
33
+
34
+ %%\hypersetup{colorlinks=false,urlcolor=blue}
35
+ \VerbatimFootnotes
36
+ \setlength{\parindent}{0pt}
37
+ \newcommand{\rblatexFileSeparator}{\newpage}
38
+
39
+ \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.1.4
4
+ version: 0.2.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-09 00:00:00.000000000 Z
11
+ date: 2018-05-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -104,6 +104,7 @@ files:
104
104
  - lib/rb_latex/version.rb
105
105
  - rb_latex.gemspec
106
106
  - templates/book.tex.erb
107
+ - templates/rblatexdefault.sty
107
108
  homepage: https://github.com/takahashim/rb_latex
108
109
  licenses: []
109
110
  metadata: {}