Skip to content

Instantly share code, notes, and snippets.

@funwarioisii
Created January 27, 2018 07:34
Show Gist options
  • Save funwarioisii/3d24764202cf7aeec195a39b89a222ed to your computer and use it in GitHub Desktop.
Save funwarioisii/3d24764202cf7aeec195a39b89a222ed to your computer and use it in GitHub Desktop.
Beamerでスライド作ると発表用原稿とか作れないからmdで原稿出力するやつ作った
class NoteGenerator:
def __init__(self, source, target):
self.source = source
self.target = target
with open(self.target,'wt') as f:
f.write('')
def write(self, comment):
with open(self.target, "at") as f:
f.write('{}{}'.format(comment, '\n'))
def generate(self):
with open(self.source, 'rt') as f:
for row in f:
if "%% " in row:
comment = row.split("%% ")[1]
self.write(comment)
if '\section' in row:
comment = row.split('\section')[1].split('{')[1].split('}')[0]
self.write('{}{}'.format('#', comment))
if '\subsection' in row:
comment = row.split('\subsection')[1].split('{')[1].split('}')[0]
self.write('{}{}'.format('##', comment))
if __name__ == '__main__':
script_gene = NoteGenerator('sample.tex', 'sample.md')
script_gene.generate()
@funwarioisii
Copy link
Author

こんな感じで書かれるのを想定して作ってある

\begin{document}

\section{はじめに}
\subsection{概要}
%% ここにコメントを書くのが推奨
\begin{frame}
\end{frame}

\section{関連研究}
\subsection{あああ}
%% てすてす
\begin{frame}
\end{frame}

\subsection{いいい}
%% ててて
\begin{frame}
\end{frame}

\section{おわりに}
\subsection{概要}
%% おわりです
\begin{frame}
\end{frame}

\end{document}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment