Skip to content
Snippets Groups Projects
Commit 4b213008 authored by Bruno Freitas Tissei's avatar Bruno Freitas Tissei
Browse files

Small fixes to latex generator

parent 55264722
No related branches found
No related tags found
No related merge requests found
...@@ -48,23 +48,35 @@ class Tree: ...@@ -48,23 +48,35 @@ class Tree:
class LatexGenerator: class LatexGenerator:
def __init__(self, tree): def __init__(self, tree):
# TODO: Create output file, add header and finish code parsing and latex
self.tree = tree self.tree = tree
self.hierarchy = ['chapter'] + [i*'sub' + 'section' for i in range(3)] self.hierarchy = ['chapter'] + [i*'sub' + 'section' for i in range(3)]
self.gen_latex(tree, 0) self.gen_latex(tree)
# Prints elements in arr in Latex format. # Prints section title in Latex format.
def gen_code_latex(self, content, depth): # TODO: Instead of parsing format, get name of section through header of
print('\\' + self.hierarchy[depth] + '{' + content + '}') # the algorithm/problem file. Capitalization should be used only for
# directories.
def gen_title_latex(self, content, depth):
text = ' '.join(list(map(lambda x : x.capitalize(),
content.split('.')[0].split('_'))))
print('\\' + self.hierarchy[depth] + '{' + text + '}')
# Prints code in Latex format.
def gen_code_latex(self, path):
# TODO: Add code parsing funcion and code to latex generation
pass
# Generates Latex for entire tree recursively # Generates Latex for entire tree recursively
def gen_latex(self, sub, depth): def gen_latex(self, sub, path = '', depth = 0):
if type(sub) == list: if type(sub) == list:
for i in sub: for i in sub:
self.gen_code_latex(i, depth) self.gen_title_latex(i, depth)
self.gen_code_latex(path + i)
else: else:
for i in sub: for i in sub:
self.gen_code_latex(i, depth) self.gen_title_latex(i, depth)
self.gen_latex(sub[i], depth + 1) self.gen_latex(sub[i], path + i + '/', depth + 1)
def main(): def main():
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment