hiki2latex 0.9.10 → 0.9.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -3
- data/Rakefile +9 -6
- data/lib/#hiki2latex.rb# +145 -0
- data/lib/hiki2latex/hiki2latex.rb +9 -1
- data/lib/hiki2latex/version.rb +1 -1
- data/lib/hiki2latex.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb8c1fa1c37fd149c824756bd2dc02122c4b60f8
|
4
|
+
data.tar.gz: 6da596d8344c2e70a979ca4a2ceb00c2615b3fff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f27211c548971a71452b268cbe379011ba1192acdf2faff1ce19eea5771c08535697e836906eb9b9de10b46ea82caf5cc050a1970904381c251bde46f2183649
|
7
|
+
data.tar.gz: 0057a9233740483c5edf0291c2462795f197b902f3d3def42d426501b08587eb2449575a1e578fca5b75eca493eb54522e1894385f8c939127dabe8831cdc180
|
data/README.md
CHANGED
@@ -8,11 +8,12 @@ Add this line to your application's Gemfile:
|
|
8
8
|
|
9
9
|
```ruby
|
10
10
|
gem 'hiki2latex'
|
11
|
+
|
11
12
|
```
|
12
13
|
|
13
14
|
And then execute:
|
14
15
|
|
15
|
-
$ bundle
|
16
|
+
$ bundle
|
16
17
|
|
17
18
|
Or install it yourself as:
|
18
19
|
|
@@ -21,12 +22,15 @@ Or install it yourself as:
|
|
21
22
|
## Usage
|
22
23
|
|
23
24
|
Use as a gem library:
|
24
|
-
|
25
|
+
```ruby
|
25
26
|
require 'hiki2latex'
|
27
|
+
|
28
|
+
puts HikiDoc.to_latex(File.read(ARGV[0]),{:level=>@level,:listings=>@listings})
|
29
|
+
```
|
26
30
|
|
27
31
|
or as a command line tool:
|
28
32
|
|
29
|
-
```
|
33
|
+
```csh
|
30
34
|
Usage: hiki2latex [options] FILE
|
31
35
|
-v, --version show program Version.
|
32
36
|
-l, --level VALUE set Level for output section.
|
@@ -36,6 +40,9 @@ Usage: hiki2latex [options] FILE
|
|
36
40
|
--pre FILE put preamble file.
|
37
41
|
--post FILE put post file.
|
38
42
|
--listings use listings.sty for preformat with style.
|
43
|
+
|
44
|
+
> hiki2latex --pre PRICM_preamble.tex --post biblio.tex -p test.hiki > test.tex
|
45
|
+
> hiki2latex --listings --post post.tex -p ./test.hiki > test.tex
|
39
46
|
```
|
40
47
|
|
41
48
|
## Development
|
data/Rakefile
CHANGED
@@ -33,10 +33,13 @@ end
|
|
33
33
|
|
34
34
|
desc "setenv for release from Kwansei gakuin."
|
35
35
|
task :setenv do
|
36
|
-
status, stdout, stderr = systemu "scselect \| grep \'\*\' |grep KG"
|
37
|
-
puts stdout
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
36
|
+
# status, stdout, stderr = systemu "scselect \| grep \'\*\' |grep KG"
|
37
|
+
# puts stdout
|
38
|
+
# p stdout != nil
|
39
|
+
# if stdout != nil then
|
40
|
+
p command='setenv HTTP_PROXY http://proxy.ksc.kwansei.ac.jp:8080'
|
41
|
+
system command
|
42
|
+
p command='setenv HTTPS_PROXY http://proxy.ksc.kwansei.ac.jp:8080'
|
43
|
+
system command
|
44
|
+
# end
|
42
45
|
end
|
data/lib/#hiki2latex.rb#
ADDED
@@ -0,0 +1,145 @@
|
|
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 document.') { |file| plain_doc(file) }
|
30
|
+
opt.on('-b FILE', '--bare','make Bare 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
|
+
|
@@ -130,6 +130,13 @@ class LatexOutput
|
|
130
130
|
end
|
131
131
|
end
|
132
132
|
|
133
|
+
# def compile_inline_markup(text)
|
134
|
+
def wiki_name(text)
|
135
|
+
text
|
136
|
+
end
|
137
|
+
|
138
|
+
|
139
|
+
|
133
140
|
def escape_html(text)
|
134
141
|
text
|
135
142
|
end
|
@@ -326,7 +333,8 @@ class LatexOutput
|
|
326
333
|
# buf << "#{ele} &"
|
327
334
|
buf << escape_snake_names(ele)+" &"
|
328
335
|
}
|
329
|
-
buf.slice!(-
|
336
|
+
# buf.slice!(-2)
|
337
|
+
buf.slice!(-4..-1)
|
330
338
|
buf << ((i==0)? "\\\\ \\hline\n" : "\\\\\n")
|
331
339
|
}
|
332
340
|
buf << "\\hline\n\\end{tabular}\n"
|
data/lib/hiki2latex/version.rb
CHANGED
data/lib/hiki2latex.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.11
|
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-
|
11
|
+
date: 2016-03-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -128,6 +128,7 @@ files:
|
|
128
128
|
- bin/setup
|
129
129
|
- exe/hiki2latex
|
130
130
|
- hiki2latex.gemspec
|
131
|
+
- lib/#hiki2latex.rb#
|
131
132
|
- lib/hiki2latex.rb
|
132
133
|
- lib/hiki2latex/hiki2latex.rb
|
133
134
|
- lib/hiki2latex/version.rb
|