hiki2latex 0.9.15 → 0.9.16
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/hiki2latex.rb +8 -8
- data/lib/hiki2latex/hiki2latex.rb +3 -2
- data/lib/hiki2latex/version.rb +1 -1
- metadata +2 -3
- data/lib/#hiki2latex.rb# +0 -145
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d313774a64d10f03b7baf54e0a9f62438fb7512
|
4
|
+
data.tar.gz: 66b38b8812b11528f5c140b01d0a6cdae3e9adc7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a54bbaac1171aceb5ddd5e5b9cfc43cc90007d4d96a546fae5eff4576de5bf899bec3e86306443ba1a1f5a580d7debe7e4d7dca0e7052b93dc8883dc259b407b
|
7
|
+
data.tar.gz: f6902b1fac6a2e2ca48253a0aaf09703cb858750ee58f69fe69bc6f475b70cce5e6e7b6f3d443bc81cb46a0e510bdf63cf3b7fc3092fdffb93362ff14db66ad6
|
data/lib/hiki2latex.rb
CHANGED
@@ -105,21 +105,21 @@ module Hiki2latex
|
|
105
105
|
\\usepackage{listings}
|
106
106
|
% to use japanese correctly, install jlistings.
|
107
107
|
\\lstset{
|
108
|
-
basicstyle={\\
|
109
|
-
identifierstyle={
|
110
|
-
commentstyle={\\
|
111
|
-
keywordstyle={\\
|
112
|
-
ndkeywordstyle={
|
113
|
-
stringstyle={\\
|
108
|
+
basicstyle={\\ttfamily},
|
109
|
+
identifierstyle={},
|
110
|
+
commentstyle={\\color{red}},
|
111
|
+
keywordstyle={\\bfseries\\color{cyan}},
|
112
|
+
ndkeywordstyle={},
|
113
|
+
stringstyle={\\color{blue}},
|
114
114
|
frame={tb},
|
115
115
|
breaklines=true,
|
116
116
|
numbers=left,
|
117
|
-
numberstyle={
|
117
|
+
numberstyle={},
|
118
118
|
stepnumber=1,
|
119
119
|
numbersep=1zw,
|
120
120
|
xrightmargin=0zw,
|
121
121
|
xleftmargin=3zw,
|
122
|
-
lineskip
|
122
|
+
lineskip=0.5ex
|
123
123
|
}
|
124
124
|
\\lstdefinestyle{customCsh}{
|
125
125
|
language={csh},
|
@@ -198,7 +198,7 @@ class LatexOutput
|
|
198
198
|
if (@listings==true and info!=nil) then
|
199
199
|
style='customRuby' if info=='ruby'
|
200
200
|
style='customCsh' if (info=='tcsh' or info=='csh')
|
201
|
-
style='customTeX' if info=='tex'
|
201
|
+
style='customTeX' if ( info=='tex' or info=='latex')
|
202
202
|
style='customJava' if info=='java'
|
203
203
|
preformatted_with_style(str,style)
|
204
204
|
else
|
@@ -215,7 +215,8 @@ class LatexOutput
|
|
215
215
|
|
216
216
|
def preformatted_with_style(str,style)
|
217
217
|
@f.slice!(-1)
|
218
|
-
@f << "\\begin{lstlisting}[style=#{style}]\n"
|
218
|
+
@f << "\\begin{lstlisting}[style=#{style},basicstyle={\\scriptsize\\ttfamily}]\n"
|
219
|
+
# @f << "\\begin{lstlisting}[style=#{style}]\n"
|
219
220
|
@f << str+"\n"
|
220
221
|
@f << "\\end{lstlisting}\n"
|
221
222
|
end
|
data/lib/hiki2latex/version.rb
CHANGED
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.16
|
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: 2017-02-
|
11
|
+
date: 2017-02-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -222,7 +222,6 @@ files:
|
|
222
222
|
- latexes/lpso_abst.pdf
|
223
223
|
- latexes/post.tex
|
224
224
|
- latexes/table.png
|
225
|
-
- lib/#hiki2latex.rb#
|
226
225
|
- lib/hiki2latex.rb
|
227
226
|
- lib/hiki2latex/hiki2latex.rb
|
228
227
|
- lib/hiki2latex/version.rb
|
data/lib/#hiki2latex.rb#
DELETED
@@ -1,145 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
require 'optparse'
|
3
|
-
require "hiki2latex/version"
|
4
|
-
#require "hiki2latex/hikidoc"
|
5
|
-
require "hiki2latex/hiki2latex"
|
6
|
-
require 'pp'
|
7
|
-
|
8
|
-
module Hiki2latex
|
9
|
-
class Command
|
10
|
-
|
11
|
-
def self.run(argv=[])
|
12
|
-
new(argv).execute
|
13
|
-
end
|
14
|
-
|
15
|
-
def initialize(argv=[])
|
16
|
-
@argv = argv
|
17
|
-
@pre=@head=@post=nil
|
18
|
-
@listings=false
|
19
|
-
end
|
20
|
-
|
21
|
-
def execute
|
22
|
-
@argv << '--help' if @argv.size==0
|
23
|
-
command_parser = OptionParser.new do |opt|
|
24
|
-
opt.on('-v', '--version','show program Version.') { |v|
|
25
|
-
opt.version = Hiki2latex::VERSION
|
26
|
-
puts opt.ver
|
27
|
-
}
|
28
|
-
opt.on('-l VALUE','--level','set Level for output section.'){|level| @level=level.to_i}
|
29
|
-
opt.on('-p FILE', '--plain','make Plain latex document.') { |file| plain_doc(file) }
|
30
|
-
opt.on('-b FILE', '--bare','make Bare latex document.') { |file| bare_doc(file) }
|
31
|
-
opt.on('--head FILE', 'put headers of maketitle file.') { |file| @head=file }
|
32
|
-
opt.on('--pre FILE', 'put preamble file.') { |file| @pre=file }
|
33
|
-
opt.on('--post FILE', 'put post file.') { |file| @post=file }
|
34
|
-
opt.on('--listings', 'use listings.sty for preformat with style.') {@listings=true }
|
35
|
-
end
|
36
|
-
command_parser.banner = "Usage: hiki2latex [options] FILE"
|
37
|
-
command_parser.parse!(@argv)
|
38
|
-
plain_doc(@argv[0]) if @argv[0]!=nil
|
39
|
-
exit
|
40
|
-
end
|
41
|
-
|
42
|
-
# pre, post, listings��ʒ�ɒ�Β�Ȓĥ������
|
43
|
-
def plain_doc(file)
|
44
|
-
if @listings==true then
|
45
|
-
puts listings_preamble
|
46
|
-
elsif @pre==nil then
|
47
|
-
puts "\\documentclass[12pt,a4paper]{jsarticle}"
|
48
|
-
puts "\\usepackage[dvipdfmx]{graphicx}"
|
49
|
-
else
|
50
|
-
puts File.read(@pre)
|
51
|
-
end
|
52
|
-
puts "\\begin{document}"
|
53
|
-
puts File.read(@head) if @head!=nil
|
54
|
-
plain_tex = HikiDoc.to_latex(File.read(file),{:listings=>@listings})
|
55
|
-
puts mod_abstract(plain_tex)
|
56
|
-
puts File.read(@post) if @post!=nil
|
57
|
-
puts "\\end{document}"
|
58
|
-
end
|
59
|
-
|
60
|
-
def bare_doc(file)
|
61
|
-
bare_doc = HikiDoc.to_latex(File.read(file),{:level=>@level,:listings=>@listings})
|
62
|
-
puts kill_head_tableofcontents(bare_doc)
|
63
|
-
end
|
64
|
-
|
65
|
-
def kill_head_tableofcontents(text)
|
66
|
-
text.gsub!(/^\\tableofcontents/,'')
|
67
|
-
return text
|
68
|
-
end
|
69
|
-
|
70
|
-
# convert section to abstract in the plain text
|
71
|
-
def mod_abstract(text)
|
72
|
-
# return text
|
73
|
-
abstract,section = [],[]
|
74
|
-
content = ""
|
75
|
-
text.split("\n").each do |line|
|
76
|
-
case line
|
77
|
-
when /^\\section(.+)/
|
78
|
-
section.push $1
|
79
|
-
end
|
80
|
-
# p section[-1]
|
81
|
-
case section[-1]
|
82
|
-
when /\{abstract\}/, /\{���abstract���\}/
|
83
|
-
abstract << line+"\n"
|
84
|
-
when /\{������\}/, /\{��ڒ����ג��\}/
|
85
|
-
abstract << line+"\n"
|
86
|
-
else
|
87
|
-
content << line+"\n"
|
88
|
-
end
|
89
|
-
end
|
90
|
-
# p abstract
|
91
|
-
if abstract.size>1 then
|
92
|
-
abstract.delete_at(0)
|
93
|
-
content.gsub!(/\\tableofcontents/){|text|
|
94
|
-
tt="\n\\abstract\{\n#{abstract.join}\}\n\\tableofcontents"
|
95
|
-
}
|
96
|
-
end
|
97
|
-
return content
|
98
|
-
end
|
99
|
-
|
100
|
-
def listings_preamble
|
101
|
-
str = <<"EOS"
|
102
|
-
\\documentclass[12pt,a4paper]{jsarticle}
|
103
|
-
\\usepackage[dvipdfmx]{graphicx}
|
104
|
-
\\usepackage[dvipdfmx]{color}
|
105
|
-
\\usepackage{listings}
|
106
|
-
% to use japanese correctly, install jlistings.
|
107
|
-
\\lstset{
|
108
|
-
basicstyle={\\small\\ttfamily},
|
109
|
-
identifierstyle={\\small},
|
110
|
-
commentstyle={\\small\\itshape\\color{red}},
|
111
|
-
keywordstyle={\\small\\bfseries\\color{cyan}},
|
112
|
-
ndkeywordstyle={\\small},
|
113
|
-
stringstyle={\\small\\color{blue}},
|
114
|
-
frame={tb},
|
115
|
-
breaklines=true,
|
116
|
-
numbers=left,
|
117
|
-
numberstyle={\\scriptsize},
|
118
|
-
stepnumber=1,
|
119
|
-
numbersep=1zw,
|
120
|
-
xrightmargin=0zw,
|
121
|
-
xleftmargin=3zw,
|
122
|
-
lineskip=-0.5ex
|
123
|
-
}
|
124
|
-
\\lstdefinestyle{customCsh}{
|
125
|
-
language={csh},
|
126
|
-
numbers=none,
|
127
|
-
}
|
128
|
-
\\lstdefinestyle{customRuby}{
|
129
|
-
language={ruby},
|
130
|
-
numbers=left,
|
131
|
-
}
|
132
|
-
\\lstdefinestyle{customTex}{
|
133
|
-
language={tex},
|
134
|
-
numbers=none,
|
135
|
-
}
|
136
|
-
\\lstdefinestyle{customJava}{
|
137
|
-
language={java},
|
138
|
-
numbers=left,
|
139
|
-
}
|
140
|
-
EOS
|
141
|
-
end
|
142
|
-
|
143
|
-
end
|
144
|
-
end
|
145
|
-
|