diff --git a/notebook/gen_latex.py b/notebook/gen_latex.py index 1bdd8505becc2b5b1c95b7389a7d911da980aec7..9d0bb0807414c5bf86c77b2a6132ef3c3cd8a207 100644 --- a/notebook/gen_latex.py +++ b/notebook/gen_latex.py @@ -48,23 +48,35 @@ class Tree: class LatexGenerator: def __init__(self, tree): + # TODO: Create output file, add header and finish code parsing and latex self.tree = tree self.hierarchy = ['chapter'] + [i*'sub' + 'section' for i in range(3)] - self.gen_latex(tree, 0) - - # Prints elements in arr in Latex format. - def gen_code_latex(self, content, depth): - print('\\' + self.hierarchy[depth] + '{' + content + '}') + self.gen_latex(tree) + + # Prints section title in Latex format. + # TODO: Instead of parsing format, get name of section through header of + # 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 - def gen_latex(self, sub, depth): + def gen_latex(self, sub, path = '', depth = 0): if type(sub) == list: for i in sub: - self.gen_code_latex(i, depth) + self.gen_title_latex(i, depth) + self.gen_code_latex(path + i) else: for i in sub: - self.gen_code_latex(i, depth) - self.gen_latex(sub[i], depth + 1) + self.gen_title_latex(i, depth) + self.gen_latex(sub[i], path + i + '/', depth + 1) def main():