hiki2latex 0.9.12 → 0.9.12.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +1 -3
- data/{README.en.md → README.md} +6 -4
- data/Rakefile +56 -28
- data/exe/#hiki2latex# +5 -0
- data/hiki2latex.gemspec +3 -0
- data/hiki2latex.wiki/AbstSample.pdf +0 -0
- data/hiki2latex.wiki/Math.png +0 -0
- data/hiki2latex.wiki/Report_head.png +0 -0
- data/hiki2latex.wiki/handout_sample.md +73 -0
- data/{docs/README.ja.md → hiki2latex.wiki/hiki2latex.md} +14 -16
- data/hiki2latex.wiki/hiki2latex_gemizing.md +221 -0
- data/hiki2latex.wiki/hiki2latex_init.md +97 -0
- data/hiki2latex.wiki/hiki2latex_listings.md +113 -0
- data/hiki2latex.wiki/hiki2latex_manual.md +31 -0
- data/hiki2latex.wiki/hiki2latex_math.md +147 -0
- data/hiki2latex.wiki/hiki2latex_table.md +103 -0
- data/hiki2latex.wiki/lpso_abst.pdf +0 -0
- data/hiki2latex.wiki/readme_en.md +60 -0
- data/{README.ja.md → hiki2latex.wiki/readme_ja.md} +46 -26
- data/hiki2latex.wiki/table.png +0 -0
- data/hikis/AbstSample.pdf +0 -0
- data/hikis/Math.png +0 -0
- data/hikis/Report_head.png +0 -0
- data/{docs/readme.ja.hiki → hikis/hiki2latex.hiki} +4 -6
- data/hikis/hiki2latex_gemizing.hiki +222 -0
- data/hikis/hiki2latex_init.hiki +95 -0
- data/hikis/hiki2latex_listings.hiki +113 -0
- data/hikis/hiki2latex_manual.hiki +32 -0
- data/hikis/hiki2latex_math.hiki +145 -0
- data/hikis/hiki2latex_table.hiki +102 -0
- data/hikis/lpso_abst.pdf +0 -0
- data/{docs/readme.hiki → hikis/readme_en.hiki} +2 -0
- data/hikis/readme_ja.hiki +133 -0
- data/hikis/table.png +0 -0
- data/latexes/AbstSample.pdf +0 -0
- data/latexes/Math.png +0 -0
- data/latexes/Report_head.png +0 -0
- data/latexes/head.tex +4 -0
- data/latexes/hiki2latex.aux +60 -0
- data/latexes/hiki2latex.log +307 -0
- data/latexes/hiki2latex.pdf +0 -0
- data/latexes/hiki2latex.synctex.gz +0 -0
- data/latexes/hiki2latex.tex +213 -0
- data/latexes/hiki2latex.toc +47 -0
- data/latexes/hiki2latex_gemizing.tex +212 -0
- data/latexes/hiki2latex_init.tex +103 -0
- data/latexes/hiki2latex_listings.tex +106 -0
- data/latexes/hiki2latex_manual.tex +38 -0
- data/latexes/hiki2latex_math.tex +151 -0
- data/latexes/hiki2latex_table.tex +108 -0
- data/latexes/lpso_abst.pdf +0 -0
- data/latexes/post.tex +17 -0
- data/latexes/table.png +0 -0
- data/lib/#hiki2latex.rb# +145 -0
- data/lib/hiki2latex/hiki2latex.rb +2 -1
- data/lib/hiki2latex/version.rb +1 -1
- data/lib/hiki2latex.rb +2 -2
- metadata +84 -13
- data/#Rakefile# +0 -42
- data/#hiki2latex.gemspec# +0 -42
- data/{docs/README.en.md → hiki2latex.wiki/readme.md} +4 -4
@@ -0,0 +1,38 @@
|
|
1
|
+
|
2
|
+
\subsubsection{【概要】}
|
3
|
+
hikiで書いたのを中間発表の予稿集用に変換するマニュアル.
|
4
|
+
|
5
|
+
\subsubsection{【下準備】}\begin{enumerate}
|
6
|
+
\item yahataProjectをinstall
|
7
|
+
\item rake initを実行.passwordを聞かれたときはdonkeyかnishitaniに知らせる
|
8
|
+
\item setenvでpathを設定
|
9
|
+
\end{enumerate}
|
10
|
+
\subsubsection{【手順】}\begin{enumerate}
|
11
|
+
\item hikiにGraduate\_handout原稿を作成
|
12
|
+
\item 作業用のdirectoryを作成
|
13
|
+
\item そこで,hiki2abst.rb ~/Sites/hiki-1.0/data/text/Graduate\_handout > Graduate\_handout.tex
|
14
|
+
\item open Graduate\_handout.tex
|
15
|
+
\item command-Tでpdfへ変換.
|
16
|
+
\end{enumerate}
|
17
|
+
\subsubsection{【graph作成手順】}
|
18
|
+
\paragraph{hiki}\begin{enumerate}
|
19
|
+
\item 適当なサイズに調整したファイルを添付ファイルとしてUpLoad
|
20
|
+
\end{enumerate}\begin{itemize}
|
21
|
+
\item ImageMagickがinstallされているとして,convert A.png -scale 50% B.png
|
22
|
+
\end{itemize}
|
23
|
+
\paragraph{latex directory}\begin{enumerate}
|
24
|
+
\item hikiでファイルを選択してDownLoad
|
25
|
+
\item 作業用のlatex directoryへ移す.
|
26
|
+
\item ebb B.pngでB.bbを作成.
|
27
|
+
\item TeXShopでcompileすればいけるはず.
|
28
|
+
\end{enumerate}
|
29
|
+
\subsubsection{【TeXShopの設定】}
|
30
|
+
\paragraph{ファイルが文字化け}\begin{itemize}
|
31
|
+
\item 「設定」->書類->エンコーディング Unicode(UTF-8)
|
32
|
+
\item 同じタグの「設定プロファイル」-> pTeX(ptex2pdf)を選択
|
33
|
+
\item TeXShopを再起動
|
34
|
+
\item compileすればいけるはず.
|
35
|
+
\end{itemize}
|
36
|
+
\paragraph{compileうまくいかないとき.}\begin{itemize}
|
37
|
+
\item *.auxファイルを消去して,再compile.
|
38
|
+
\end{itemize}
|
@@ -0,0 +1,151 @@
|
|
1
|
+
|
2
|
+
\subsubsection{【概要】}
|
3
|
+
dmath,math環境をequationに変換
|
4
|
+
|
5
|
+
\subsubsection{【入力:hiki】}\begin{quote}\begin{verbatim}
|
6
|
+
mathがうまくいくかどうかの検討用サンプルです.
|
7
|
+
{{dmath 'f_x'}}
|
8
|
+
さらにinlineで{{math 'x_i'}}なんかもできるといいのですが.
|
9
|
+
\end{verbatim}\end{quote}
|
10
|
+
mathがうまくいくかどうかの検討用サンプルです.
|
11
|
+
\begin{equation}
|
12
|
+
f_x
|
13
|
+
\end{equation}
|
14
|
+
さらにinlineで$x_i$なんかもできるといいのですが.
|
15
|
+
|
16
|
+
\subsubsection{【出力:latex】}\begin{quote}\begin{verbatim}
|
17
|
+
\begin{document}
|
18
|
+
mathがうまくいくかどうかの検討用サンプルです.
|
19
|
+
\begin{equation}
|
20
|
+
f_x
|
21
|
+
\end{equation}
|
22
|
+
さらにinlineで$x_i$なんかもできるといいのですが.
|
23
|
+
\end{verbatim}\end{quote}\begin{description}
|
24
|
+
\item[注2016/02/20] このあたりでhiki, rubyを指定するとlistingsがうまく処理できない.preformatted\_without\_styleで対応.
|
25
|
+
|
26
|
+
\end{description}
|
27
|
+
\begin{figure}[htbp]\begin{center}
|
28
|
+
\includegraphics[width=6cm]{./Math.png}
|
29
|
+
\caption{}
|
30
|
+
\label{default}\end{center}\end{figure}
|
31
|
+
\subsubsection{【コード解説】}
|
32
|
+
\paragraph{evaluate\_plugin\_block}
|
33
|
+
すこしトリッキーだったので,メモです.
|
34
|
+
\begin{lstlisting}[style=customRuby]
|
35
|
+
def evaluate_plugin_block(str, buf = nil)
|
36
|
+
buf ||= @output.container
|
37
|
+
str.split(/(\0\d+\0)/).each do |s|
|
38
|
+
if s[0, 1] == "\0" and s[-1, 1] == "\0"
|
39
|
+
buf << @output.inline_plugin(plugin_block(s[1..-2].to_i))
|
40
|
+
else
|
41
|
+
buf << @output.text(s)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
buf
|
45
|
+
end
|
46
|
+
\end{lstlisting}
|
47
|
+
としてinline\_pluginはblock\_pluginと違った扱いになっています.bufに一度溜め込んでそれを@fに吐いているようです.
|
48
|
+
そこで,@output.inline\_pluginで行き着く先が,LatexOutputの
|
49
|
+
\begin{lstlisting}[style=customRuby]
|
50
|
+
def inline_plugin(src)
|
51
|
+
tmp=[]
|
52
|
+
if ( /(\w+)\((.+)\)/ =~ src ) or ( /(\w+).\'(.+)\'/ =~src ) or (/(\w+)/ =~ src)
|
53
|
+
tmp = [$1,$2]
|
54
|
+
end
|
55
|
+
|
56
|
+
case tmp[0]
|
57
|
+
when 'dmath'
|
58
|
+
"\\begin{equation}\n#{tmp[1]}\n\\end{equation}"
|
59
|
+
when 'math'
|
60
|
+
"\$#{tmp[1]}\$"
|
61
|
+
else
|
62
|
+
%Q(<span class="plugin">{{#{src}}}</span>)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
\end{lstlisting}
|
66
|
+
としてmath,dmathを処理しています.必要ならそれ以外のinlineもここに付け足すことで対応できます.
|
67
|
+
|
68
|
+
\paragraph{snake\_nameがlatexで引っかかる}
|
69
|
+
math環境の移し替えはうまくいったが,underscore\_namesがすべて引っかかるequationとして引っかかる.
|
70
|
+
\begin{quote}\begin{verbatim}
|
71
|
+
\usepackage{underscore}
|
72
|
+
\end{verbatim}\end{quote}
|
73
|
+
だけでもできるようだが,できればto\_latexで対応したい.ということで,paragraphにescape\_snake\_namesを入れた.
|
74
|
+
|
75
|
+
paragraphはpreformattedからは呼ばれない.しかし,\verb|$$|や\verb|\begin{equation}...\end{equation}|が含まれる.そこで
|
76
|
+
一旦全置換してそこだけ戻すようにした.gsubのなかでなんどもできるか自信がなくて.二重のgsubにしているが...
|
77
|
+
\begin{lstlisting}[style=customRuby]
|
78
|
+
def escape_snake_names(str)
|
79
|
+
str.gsub!(/_/,"\\_")
|
80
|
+
str.gsub!(/\$.+?\$/){ |text| text.gsub!(/\\_/,"_") }
|
81
|
+
str.gsub!(/equation.+?equation/m){ |text| text.gsub!(/\\_/,"_") }
|
82
|
+
end
|
83
|
+
|
84
|
+
def paragraph(lines)
|
85
|
+
lines.each{|line| line = escape_snake_names(line) }
|
86
|
+
@f << "#{lines.join("\n")}\n\n"
|
87
|
+
end
|
88
|
+
\end{lstlisting}
|
89
|
+
gsub!で置換できなかったときには,nilが返るので対応.なんかえらく冗長.
|
90
|
+
\begin{lstlisting}[style=customRuby]
|
91
|
+
def escape_snake_names(str)
|
92
|
+
str.gsub!(/_/,"\\_")
|
93
|
+
str.gsub!(/\$.+?\$/){ |text|
|
94
|
+
if text =~ /\\_/ then
|
95
|
+
text.gsub!(/\\_/,"_")
|
96
|
+
else
|
97
|
+
text
|
98
|
+
end
|
99
|
+
}
|
100
|
+
str.gsub!(/equation.+?equation/m){ |text|
|
101
|
+
if text =~ /\\_/ then
|
102
|
+
text.gsub!(/\\_/,"_")
|
103
|
+
else
|
104
|
+
text
|
105
|
+
end
|
106
|
+
}
|
107
|
+
str
|
108
|
+
end
|
109
|
+
\end{lstlisting}
|
110
|
+
\paragraph{escape\_snake\_namesを改良(2016/02/14)}
|
111
|
+
gemへの公開にあたって冗長部を簡略化.verbだけはここを切り出した検証とは違う.testにuriを埋め込んでverb変換とsnakeを検証.
|
112
|
+
\begin{lstlisting}[style=customRuby]
|
113
|
+
def escape_snake_names(str)
|
114
|
+
str.gsub!(/_/,"\\_")
|
115
|
+
patterns = [/\$(.+?)\$/ , /\\verb\|(.+?)\|/, /equation(.+?)equation/m ]
|
116
|
+
patterns.each{|pattern|
|
117
|
+
str.gsub!(/\\_/,"_") if str.match(pattern)
|
118
|
+
}
|
119
|
+
str
|
120
|
+
end
|
121
|
+
\end{lstlisting}
|
122
|
+
\paragraph{escape\_snake\_namesを再改良(2016/02/16)}
|
123
|
+
underscoreではincludeなどでsnake\_named\_fileも変換してしまい,だめ.hiki2latexで対応.
|
124
|
+
|
125
|
+
上のやり方では,うまくいかない場合が存在.元へ戻す.
|
126
|
+
\begin{lstlisting}[style=customRuby]
|
127
|
+
def escape_snake_names(str)
|
128
|
+
str.gsub!(/_/,"\\_")
|
129
|
+
patterns = [/\$(.+?)\$/ , /\\verb\|(.+?)\|/, /equation(.+?)equation/m ]
|
130
|
+
patterns.each{|pattern|
|
131
|
+
# str.gsub!(/\\_/,"_") if str.match(pattern)
|
132
|
+
str.gsub!(pattern){|text|
|
133
|
+
if text =~ /\\_/ then
|
134
|
+
text.gsub!(/\\_/,'_')
|
135
|
+
else
|
136
|
+
text
|
137
|
+
end
|
138
|
+
}
|
139
|
+
}
|
140
|
+
str
|
141
|
+
end
|
142
|
+
\end{lstlisting}
|
143
|
+
さらに
|
144
|
+
tableでescape\_snake\_namesを通ってなかった.
|
145
|
+
\begin{quote}\begin{verbatim}
|
146
|
+
# buf << "#{ele} &"
|
147
|
+
buf << escape_snake_names(ele)+" &"
|
148
|
+
\end{verbatim}\end{quote}
|
149
|
+
\subsubsection{【copyright】}
|
150
|
+
cc by Shigeto R. Nishitani, 2015
|
151
|
+
|
@@ -0,0 +1,108 @@
|
|
1
|
+
|
2
|
+
\subsubsection{【概要】}
|
3
|
+
hiki2latexのtable処理部
|
4
|
+
|
5
|
+
\subsubsection{【仕様】}\begin{itemize}
|
6
|
+
\item hiki記法の表をtabularへ変換
|
7
|
+
\item 連結作用素に対応
|
8
|
+
\item 行連結では中心に表示を移動
|
9
|
+
\item 縦罫は基本使わない
|
10
|
+
\item 横罫はheader内枠と上下外枠のみ
|
11
|
+
\end{itemize}
|
12
|
+
\subsubsection{【hiki】}\begin{quote}\begin{verbatim}
|
13
|
+
||>A11||>A12||
|
14
|
+
||^^A21||A22||>A23||
|
15
|
+
||A11||^A22||A12||
|
16
|
+
||A21||A23||
|
17
|
+
\end{verbatim}\end{quote}
|
18
|
+
\begin{table}[htbp]\begin{center}
|
19
|
+
\caption{}
|
20
|
+
\begin{tabular}{lllll}
|
21
|
+
\hline
|
22
|
+
\multicolumn{2}{l}{A11 } &\multicolumn{2}{l}{A12 } \\ \hline
|
23
|
+
&A22 &\multicolumn{2}{l}{A23 } \\
|
24
|
+
A21 &A11 &A22 &A12 \\
|
25
|
+
&A21 & &A23 \\
|
26
|
+
\hline
|
27
|
+
\end{tabular}
|
28
|
+
\label{default}
|
29
|
+
\end{center}\end{table}
|
30
|
+
%for inserting separate lines, use \hline, \cline{2-3} etc.
|
31
|
+
|
32
|
+
\subsubsection{【latex】}\begin{lstlisting}[style=]
|
33
|
+
¥begin{center}¥begin{table}[htbp]¥begin{tabular}{ccccc}
|
34
|
+
¥hline
|
35
|
+
¥multicolumn{2}{c}{A11 } &¥multicolumn{2}{c}{A12 } & ¥¥ ¥hline
|
36
|
+
&A22 &¥multicolumn{2}{c}{A23 } & ¥¥
|
37
|
+
A21 &A11 &A22 &A12 & ¥¥
|
38
|
+
&A21 & &A23 & ¥¥
|
39
|
+
¥hline
|
40
|
+
¥end{tabular}¥end{table}¥end{center}
|
41
|
+
%横罫を入れる場合は, ¥hline, ¥cline{2-3}などで.
|
42
|
+
\end{lstlisting}
|
43
|
+
\begin{figure}[htbp]\begin{center}
|
44
|
+
\includegraphics[width=6cm]{./table.png}
|
45
|
+
\caption{}
|
46
|
+
\label{default}\end{center}\end{figure}
|
47
|
+
\subsubsection{【コード解説】}
|
48
|
+
元のHTMLOutputではそれぞれの要素で対応していたが,LatexOutputではtable\_closeにて
|
49
|
+
\begin{lstlisting}[style=customRuby]
|
50
|
+
def table_close
|
51
|
+
@f << make_table
|
52
|
+
end
|
53
|
+
\end{lstlisting}
|
54
|
+
としている.make\_tableは下請けにmake\_matrixを読んでおり,ここでほぼ全ての作業をしている.作業内容は
|
55
|
+
\begin{itemize}
|
56
|
+
\item matrixを作る
|
57
|
+
\item 縦連結を処理\begin{itemize}
|
58
|
+
\item 縦連結の数(rs)だけ下行に追加
|
59
|
+
\item 連結の中心(c\_rs)に内容を表記
|
60
|
+
\end{itemize}
|
61
|
+
\item 横連結をmulticolumnで処理\begin{itemize}
|
62
|
+
\item ついでに最大列数(max\_col)を記録
|
63
|
+
\end{itemize}
|
64
|
+
\end{itemize}\begin{lstlisting}[style=customRuby]
|
65
|
+
bob% cat table.rb
|
66
|
+
cont = File.readlines("table")
|
67
|
+
|
68
|
+
cont.each{|line|
|
69
|
+
p tmp=line.split('||')
|
70
|
+
}
|
71
|
+
|
72
|
+
t_matrix=[]
|
73
|
+
cont.each{|line|
|
74
|
+
tmp=line.split('||')
|
75
|
+
tmp.slice!(0)
|
76
|
+
tmp.slice!(-1) if tmp.slice(-1)=="\n"
|
77
|
+
tmp.each_with_index{|ele,i| tmp[i] = ele.match(/\s*(.+)/)[1]}
|
78
|
+
t_matrix << tmp
|
79
|
+
}
|
80
|
+
|
81
|
+
t_matrix.each_with_index{|line,i|
|
82
|
+
line.each_with_index{|ele,j|
|
83
|
+
if ele=~/\^+/ then
|
84
|
+
t_matrix[i][j]=""
|
85
|
+
rs=$&.size
|
86
|
+
c_rs=rs/2
|
87
|
+
rs.times{|k| t_matrix[i+k+1].insert(j,"")}
|
88
|
+
t_matrix[i+c_rs][j]=$'
|
89
|
+
end
|
90
|
+
}
|
91
|
+
}
|
92
|
+
p t_matrix
|
93
|
+
|
94
|
+
max_col=0
|
95
|
+
t_matrix.each_with_index{|line,i|
|
96
|
+
n_col=line.size
|
97
|
+
line.each_with_index{|ele,j|
|
98
|
+
if ele=~/>+/ then
|
99
|
+
cs=$&.size
|
100
|
+
t_matrix[i][j]= "\\multicolumn{#{cs+1}}{c}{#{$'}} "
|
101
|
+
n_col+=cs
|
102
|
+
end
|
103
|
+
}
|
104
|
+
max_col = n_col if n_col>max_col
|
105
|
+
}
|
106
|
+
p t_matrix
|
107
|
+
p max_col
|
108
|
+
\end{lstlisting}
|
Binary file
|
data/latexes/post.tex
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
\appendix
|
2
|
+
\section{詳細な使用法}
|
3
|
+
\input{hiki2latex_gemizing}
|
4
|
+
\pagebreak
|
5
|
+
\section{コード内容}
|
6
|
+
\subsection{起動}
|
7
|
+
\input{hiki2latex_init}
|
8
|
+
\pagebreak
|
9
|
+
\subsection{math環境}
|
10
|
+
\input{hiki2latex_math}
|
11
|
+
\pagebreak
|
12
|
+
\subsection{table環境}
|
13
|
+
\input{hiki2latex_table}
|
14
|
+
\pagebreak
|
15
|
+
\subsection{source code環境}
|
16
|
+
\input{hiki2latex_listings}
|
17
|
+
\pagebreak
|
data/latexes/table.png
ADDED
Binary file
|
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 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
|
+
|
@@ -222,7 +222,8 @@ class LatexOutput
|
|
222
222
|
end
|
223
223
|
|
224
224
|
def list_open(type)
|
225
|
-
@f.slice!(-1)
|
225
|
+
# @f.slice!(-1)
|
226
|
+
#こいつがわからん.\begin{item..}の前に改行が入るから...なぜ?
|
226
227
|
#二重のitemizeでおかしくなるが,へんなところで改行は入らないので.
|
227
228
|
case type
|
228
229
|
when 'ul' then
|
data/lib/hiki2latex/version.rb
CHANGED
data/lib/hiki2latex.rb
CHANGED
@@ -26,8 +26,8 @@ module Hiki2latex
|
|
26
26
|
puts opt.ver
|
27
27
|
}
|
28
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) }
|
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
31
|
opt.on('--head FILE', 'put headers of maketitle file.') { |file| @head=file }
|
32
32
|
opt.on('--pre FILE', 'put preamble file.') { |file| @pre=file }
|
33
33
|
opt.on('--post FILE', 'put post file.') { |file| @post=file }
|
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.12
|
4
|
+
version: 0.9.12.1
|
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:
|
11
|
+
date: 2017-01-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -108,6 +108,34 @@ dependencies:
|
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: mathjax-yard
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: hiki2latex
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
111
139
|
- !ruby/object:Gem::Dependency
|
112
140
|
name: hikidoc
|
113
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -122,17 +150,15 @@ dependencies:
|
|
122
150
|
- - "~>"
|
123
151
|
- !ruby/object:Gem::Version
|
124
152
|
version: 0.1.0
|
125
|
-
description:
|
126
|
-
hiki2latex is a format converter from hikidoc to latex, using hikidoc.
|
153
|
+
description: " hiki2latex is a format converter from hikidoc to latex, using hikidoc.\n"
|
127
154
|
email:
|
128
155
|
- shigeto_nishitani@me.com
|
129
156
|
executables:
|
157
|
+
- "#hiki2latex#"
|
130
158
|
- hiki2latex
|
131
159
|
extensions: []
|
132
160
|
extra_rdoc_files: []
|
133
161
|
files:
|
134
|
-
- "#Rakefile#"
|
135
|
-
- "#hiki2latex.gemspec#"
|
136
162
|
- ".gitignore"
|
137
163
|
- ".rspec"
|
138
164
|
- ".travis.yml"
|
@@ -140,17 +166,63 @@ files:
|
|
140
166
|
- CODE_OF_CONDUCT.md
|
141
167
|
- Gemfile
|
142
168
|
- LICENSE.txt
|
143
|
-
- README.
|
144
|
-
- README.ja.md
|
169
|
+
- README.md
|
145
170
|
- Rakefile
|
146
171
|
- bin/console
|
147
172
|
- bin/setup
|
148
|
-
-
|
149
|
-
- docs/README.ja.md
|
150
|
-
- docs/readme.hiki
|
151
|
-
- docs/readme.ja.hiki
|
173
|
+
- exe/#hiki2latex#
|
152
174
|
- exe/hiki2latex
|
153
175
|
- hiki2latex.gemspec
|
176
|
+
- hiki2latex.wiki/AbstSample.pdf
|
177
|
+
- hiki2latex.wiki/Math.png
|
178
|
+
- hiki2latex.wiki/Report_head.png
|
179
|
+
- hiki2latex.wiki/handout_sample.md
|
180
|
+
- hiki2latex.wiki/hiki2latex.md
|
181
|
+
- hiki2latex.wiki/hiki2latex_gemizing.md
|
182
|
+
- hiki2latex.wiki/hiki2latex_init.md
|
183
|
+
- hiki2latex.wiki/hiki2latex_listings.md
|
184
|
+
- hiki2latex.wiki/hiki2latex_manual.md
|
185
|
+
- hiki2latex.wiki/hiki2latex_math.md
|
186
|
+
- hiki2latex.wiki/hiki2latex_table.md
|
187
|
+
- hiki2latex.wiki/lpso_abst.pdf
|
188
|
+
- hiki2latex.wiki/readme.md
|
189
|
+
- hiki2latex.wiki/readme_en.md
|
190
|
+
- hiki2latex.wiki/readme_ja.md
|
191
|
+
- hiki2latex.wiki/table.png
|
192
|
+
- hikis/AbstSample.pdf
|
193
|
+
- hikis/Math.png
|
194
|
+
- hikis/Report_head.png
|
195
|
+
- hikis/hiki2latex.hiki
|
196
|
+
- hikis/hiki2latex_gemizing.hiki
|
197
|
+
- hikis/hiki2latex_init.hiki
|
198
|
+
- hikis/hiki2latex_listings.hiki
|
199
|
+
- hikis/hiki2latex_manual.hiki
|
200
|
+
- hikis/hiki2latex_math.hiki
|
201
|
+
- hikis/hiki2latex_table.hiki
|
202
|
+
- hikis/lpso_abst.pdf
|
203
|
+
- hikis/readme_en.hiki
|
204
|
+
- hikis/readme_ja.hiki
|
205
|
+
- hikis/table.png
|
206
|
+
- latexes/AbstSample.pdf
|
207
|
+
- latexes/Math.png
|
208
|
+
- latexes/Report_head.png
|
209
|
+
- latexes/head.tex
|
210
|
+
- latexes/hiki2latex.aux
|
211
|
+
- latexes/hiki2latex.log
|
212
|
+
- latexes/hiki2latex.pdf
|
213
|
+
- latexes/hiki2latex.synctex.gz
|
214
|
+
- latexes/hiki2latex.tex
|
215
|
+
- latexes/hiki2latex.toc
|
216
|
+
- latexes/hiki2latex_gemizing.tex
|
217
|
+
- latexes/hiki2latex_init.tex
|
218
|
+
- latexes/hiki2latex_listings.tex
|
219
|
+
- latexes/hiki2latex_manual.tex
|
220
|
+
- latexes/hiki2latex_math.tex
|
221
|
+
- latexes/hiki2latex_table.tex
|
222
|
+
- latexes/lpso_abst.pdf
|
223
|
+
- latexes/post.tex
|
224
|
+
- latexes/table.png
|
225
|
+
- lib/#hiki2latex.rb#
|
154
226
|
- lib/hiki2latex.rb
|
155
227
|
- lib/hiki2latex/hiki2latex.rb
|
156
228
|
- lib/hiki2latex/version.rb
|
@@ -179,4 +251,3 @@ signing_key:
|
|
179
251
|
specification_version: 4
|
180
252
|
summary: convert hikidoc text to latex format.
|
181
253
|
test_files: []
|
182
|
-
has_rdoc:
|
data/#Rakefile#
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
require "bundler/gem_tasks"
|
2
|
-
require "rspec/core/rake_task"
|
3
|
-
require "rake/testtask"
|
4
|
-
require 'yard'
|
5
|
-
require 'systemu'
|
6
|
-
|
7
|
-
#task :default => :test
|
8
|
-
task :default do
|
9
|
-
system 'rake -T'
|
10
|
-
end
|
11
|
-
|
12
|
-
|
13
|
-
desc "make documents by yard"
|
14
|
-
task :yard do
|
15
|
-
system "hiki2md docs/readme.hiki > docs/README.en.md"
|
16
|
-
system "hiki2md docs/readme.ja.hiki > docs/README.ja.md"
|
17
|
-
YARD::Rake::YardocTask.new
|
18
|
-
end
|
19
|
-
|
20
|
-
RSpec::Core::RakeTask.new(:spec)
|
21
|
-
|
22
|
-
desc "all procedure for release."
|
23
|
-
task :update =>[:setenv] do
|
24
|
-
system 'emacs ./lib/hiki2latex/version.rb'
|
25
|
-
system 'git add -A'
|
26
|
-
system 'git commit'
|
27
|
-
system 'git push -u origin master'
|
28
|
-
system 'bundle exec rake release'
|
29
|
-
end
|
30
|
-
|
31
|
-
desc "setenv for release from Kwansei gakuin."
|
32
|
-
task :setenv do
|
33
|
-
# status, stdout, stderr = systemu "scselect \| grep \'\*\' |grep KG"
|
34
|
-
# puts stdout
|
35
|
-
# p stdout != nil
|
36
|
-
# if stdout != nil then
|
37
|
-
p command='setenv HTTP_PROXY http://proxy.ksc.kwansei.ac.jp:8080'
|
38
|
-
system command
|
39
|
-
p command='setenv HTTPS_PROXY http://proxy.ksc.kwansei.ac.jp:8080'
|
40
|
-
system command
|
41
|
-
# end
|
42
|
-
end
|