Skip to content

Instantly share code, notes, and snippets.

@sasamijp
Created January 23, 2017 13:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sasamijp/cab62dd169199301f7fb2d2cee28aeca to your computer and use it in GitHub Desktop.
Save sasamijp/cab62dd169199301f7fb2d2cee28aeca to your computer and use it in GitHub Desktop.
inputs = []
while line = gets
inputs.push line.chomp!
end
puts '\documentclass[onecolumn, a4paper, dvipdfmx]{jsarticle}
\usepackage{listings}
\usepackage{color}
%\usepackage{pdfcolparallel}
\usepackage{layout}
\usepackage[dvipdfmx]{graphicx}
\usepackage[margin=2cm, bottom=3cm, footskip=1.5cm]{geometry}
\usepackage{url}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{here}
\begin{document}
\definecolor{OliveGreen}{cmyk}{0.64,0,0.95,0.40}
\definecolor{colFunc}{rgb}{1,0.07,0.54}
\definecolor{CadetBlue}{cmyk}{0.62,0.57,0.23,0}
\definecolor{Brown}{cmyk}{0,0.81,1,0.60}
\definecolor{colID}{rgb}{0.63,0.44,0}
\lstset{
breaklines=true,%折り返し
}
\title{'+ inputs[0] +'}
\author{なまえ}
\maketitle
'
inputs[1..-1].each do |line|
if line[0..1] == '##'
puts '\subsection{' + line.sub('##', '').lstrip + '}'
next
end
if line[0] == '#'
puts '\section{' + line.sub('#', '').lstrip + '}'
next
end
if line[0..1] == '!['
img_path = line[line.index('(')+1..line.index(')')-1]
caption = line[2..line.index(']')-1]
width = line.split(') ')[1].to_i
puts '\begin{figure}[H]
\begin{center}
\includegraphics[width='+width.to_s+'cm]{./'+img_path+'}
\caption{'+caption+'}
\end{center}
\end{figure}
'
next
end
if line =='listing'
puts '\begin{lstlisting}[basicstyle=\ttfamily\footnotesize, frame=single]'
next
end
if line=='\listing'
puts '\end{lstlisting}'
next
end
if line=='itemize'
puts '\begin{itemize}'
next
end
if line=='\itemize'
puts '\end{itemize}'
next
end
if line[0] == '-'
puts line.sub('-', '\item')
next
end
if line=='enumerate'
puts '\begin{enumerate}'
next
end
if line=='\enumerate'
puts '\end{enumerate}'
next
end
if line=='equation'
puts '\begin{equation}'
next
end
if line=='\equation'
puts '\end{equation}'
next
end
if line=='eqnarray'
puts '\begin{eqnarray}'
next
end
if line=='\eqnarray'
puts '\end{eqnarray}'
next
end
puts line
end
puts '
\end{document}
'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment