hiki2latex 0.9.5 → 0.9.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/Rakefile +2 -0
- data/lib/hiki2latex/hiki2latex.rb +23 -5
- data/lib/hiki2latex/version.rb +1 -1
- data/lib/hiki2latex.rb +44 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5a5cb80fa71a49cb6dfb51866f8d441984b26358
|
4
|
+
data.tar.gz: d0aaf58a2706e6a9c9dcdf13a92af15b2d506b2d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7dff3f64abe07c2df59b2e8695dcd1cc8083dd8f7606f987eae8a575c641c5cd6e192224468f68a1a64a772add9d8369f12463610c3fe91754f103d4b056a677
|
7
|
+
data.tar.gz: ad24fe77bfce62f53eed05914e05e1b64ce796fdea7cb33b1da23fd140461cf0f6164dbec25674521437ce99ed053b59d6d78aa58b058d09b16300ee281e0c98
|
data/README.md
CHANGED
data/Rakefile
CHANGED
@@ -13,6 +13,7 @@ YARD::Rake::YardocTask.new
|
|
13
13
|
|
14
14
|
RSpec::Core::RakeTask.new(:spec)
|
15
15
|
|
16
|
+
desc "test using unit/test"
|
16
17
|
Rake::TestTask.new(:test) do |test|
|
17
18
|
test.libs << "test"
|
18
19
|
test.libs << "lib"
|
@@ -20,6 +21,7 @@ Rake::TestTask.new(:test) do |test|
|
|
20
21
|
test.verbose = true
|
21
22
|
end
|
22
23
|
|
24
|
+
desc "all procedure for release."
|
23
25
|
task :update do
|
24
26
|
system 'emacs ./lib/hiki2latex/version.rb'
|
25
27
|
system 'git add -A'
|
@@ -6,14 +6,15 @@ require 'hikidoc'
|
|
6
6
|
|
7
7
|
class HikiDoc
|
8
8
|
def HikiDoc.to_latex(src, options = {})
|
9
|
-
new(LatexOutput.new(), options).compile(src)
|
9
|
+
new(LatexOutput.new(options), options).compile(src)
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
13
|
|
14
14
|
class LatexOutput
|
15
|
-
def initialize(
|
16
|
-
@suffix =
|
15
|
+
def initialize(options={})
|
16
|
+
@suffix = ""
|
17
|
+
@listings = options[:listings]
|
17
18
|
# @f = nil
|
18
19
|
reset
|
19
20
|
end
|
@@ -51,8 +52,10 @@ class LatexOutput
|
|
51
52
|
tmp=title.split(/:/)
|
52
53
|
if tmp.size!=1 then
|
53
54
|
case tmp[0]
|
54
|
-
when 'title','author','date'
|
55
|
+
when 'title','author','date','abstract'
|
55
56
|
@head << "\\#{tmp[0]}\{#{tmp[1]}\}\n"
|
57
|
+
when 'Title','Author','Date','Abstract'
|
58
|
+
@head << "\\#{tmp[0].downcase}\{#{tmp[1]}\}\n"
|
56
59
|
when 'caption'
|
57
60
|
@caption << "#{tmp[1]}"
|
58
61
|
when 'reference'
|
@@ -164,8 +167,16 @@ class LatexOutput
|
|
164
167
|
end
|
165
168
|
|
166
169
|
def block_preformatted(str, info)
|
167
|
-
|
170
|
+
if (@listings==true and info!=nil) then
|
171
|
+
style='customRuby' if info=='ruby'
|
172
|
+
style='customCsh' if (info=='tcsh' or info=='csh')
|
173
|
+
style='customTeX' if info=='tex'
|
174
|
+
preformatted_with_style(str,style)
|
175
|
+
else
|
176
|
+
preformatted(text(str))
|
177
|
+
end
|
168
178
|
end
|
179
|
+
|
169
180
|
def preformatted(str)
|
170
181
|
@f.slice!(-1)
|
171
182
|
@f << "\\begin{quote}\\begin{verbatim}\n"
|
@@ -173,6 +184,13 @@ class LatexOutput
|
|
173
184
|
@f << "\\end{verbatim}\\end{quote}\n"
|
174
185
|
end
|
175
186
|
|
187
|
+
def preformatted_with_style(str,style)
|
188
|
+
@f.slice!(-1)
|
189
|
+
@f << "\\begin{lstlisting}[style=#{style}]\n"
|
190
|
+
@f << str+"\n"
|
191
|
+
@f << "\\end{lstlisting}\n"
|
192
|
+
end
|
193
|
+
|
176
194
|
def list_begin
|
177
195
|
end
|
178
196
|
|
data/lib/hiki2latex/version.rb
CHANGED
data/lib/hiki2latex.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
require 'optparse'
|
2
3
|
require "hiki2latex/version"
|
3
4
|
#require "hiki2latex/hikidoc"
|
@@ -13,6 +14,7 @@ module Hiki2latex
|
|
13
14
|
def initialize(argv=[])
|
14
15
|
@argv = argv
|
15
16
|
@pre=@head=@post=nil
|
17
|
+
@listings=false
|
16
18
|
end
|
17
19
|
|
18
20
|
def execute
|
@@ -28,6 +30,7 @@ module Hiki2latex
|
|
28
30
|
opt.on('--head FILE', 'put headers of maketitle file.') { |file| @head=file }
|
29
31
|
opt.on('--pre FILE', 'put preamble file.') { |file| @pre=file }
|
30
32
|
opt.on('--post FILE', 'put post file.') { |file| @post=file }
|
33
|
+
opt.on('--listings', 'use listings.sty for preformat with style.') {@listings=true }
|
31
34
|
end
|
32
35
|
command_parser.banner = "Usage: hiki2latex [options] FILE"
|
33
36
|
command_parser.parse!(@argv)
|
@@ -37,7 +40,9 @@ module Hiki2latex
|
|
37
40
|
end
|
38
41
|
|
39
42
|
def plain_doc(file)
|
40
|
-
if @
|
43
|
+
if @listings==true then
|
44
|
+
puts listings_str
|
45
|
+
elsif @pre==nil then
|
41
46
|
puts "\\documentclass[12pt,a4paper]{jsarticle}"
|
42
47
|
puts "\\usepackage[dvipdfmx]{graphicx}"
|
43
48
|
else
|
@@ -45,18 +50,50 @@ module Hiki2latex
|
|
45
50
|
end
|
46
51
|
puts "\\begin{document}"
|
47
52
|
puts File.read(@head) if @head!=nil
|
48
|
-
puts HikiDoc.to_latex(File.read(file))
|
53
|
+
puts HikiDoc.to_latex(File.read(file),{:listings=>@listings})
|
49
54
|
puts File.read(@post) if @post!=nil
|
50
55
|
puts "\\end{document}"
|
51
56
|
end
|
57
|
+
|
52
58
|
def bare_doc(file)
|
53
|
-
puts HikiDoc.to_latex(File.read(file),{:level=>@level})
|
59
|
+
puts HikiDoc.to_latex(File.read(file),{:level=>@level,:listings=>@listings})
|
54
60
|
end
|
55
61
|
|
56
|
-
|
57
|
-
|
62
|
+
def listings_str
|
63
|
+
str = <<"EOS"
|
64
|
+
\\documentclass[12pt,a4paper]{jsarticle}
|
65
|
+
\\usepackage[dvipdfmx]{graphicx}
|
66
|
+
\\usepackage[dvipdfmx]{color}
|
67
|
+
\\usepackage{listings}
|
58
68
|
|
69
|
+
\\lstset{
|
70
|
+
basicstyle={\\small\\ttfamily},
|
71
|
+
identifierstyle={\\small},
|
72
|
+
commentstyle={\\small\\itshape\\color{red}},
|
73
|
+
keywordstyle={\\small\\bfseries\\color{cyan}},
|
74
|
+
ndkeywordstyle={\\small},
|
75
|
+
stringstyle={\\small\\color{blue}},
|
76
|
+
frame={tb},
|
77
|
+
breaklines=true,
|
78
|
+
numbers=left,
|
79
|
+
numberstyle={\\scriptsize},
|
80
|
+
stepnumber=1,
|
81
|
+
numbersep=1zw,
|
82
|
+
xrightmargin=0zw,
|
83
|
+
xleftmargin=3zw,
|
84
|
+
lineskip=-0.5ex
|
85
|
+
}
|
86
|
+
\\lstdefinestyle{customCsh}{
|
87
|
+
language={csh},
|
88
|
+
numbers=none,
|
89
|
+
}
|
90
|
+
\\lstdefinestyle{customRuby}{
|
91
|
+
language={ruby},
|
92
|
+
numbers=left,
|
93
|
+
}
|
94
|
+
EOS
|
95
|
+
end
|
59
96
|
|
60
|
-
|
61
|
-
|
97
|
+
end
|
98
|
+
end
|
62
99
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hiki2latex
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shigeto R. Nishitani
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-02-
|
11
|
+
date: 2016-02-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|