Created
January 27, 2018 07:34
-
-
Save funwarioisii/3d24764202cf7aeec195a39b89a222ed to your computer and use it in GitHub Desktop.
Beamerでスライド作ると発表用原稿とか作れないからmdで原稿出力するやつ作った
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
こんな感じで書かれるのを想定して作ってある