import os import helper import slides as slides_helper root = "" lang = "" # Compiles a presentation's chapters (the content without the wrapper) # according to slides.yml and returns them as one string of
s. def compile_chapters(root_directory, language): global root root = root_directory global lang lang = language structure = helper.read_yaml(root, 'slides.yml') chapters = "" for chapter in structure: chapters += '
\n' + compile_chapter(chapter) + '\n
' return chapters # string # Compiles a presentation's chapter (given its name) by splitting it into # slides, compiling those, and returning them as a string of
s. def compile_chapter(chapter): global root if type(chapter) != str: raise Exception('Chapters with attributes are not supported yet.\n' + str(chapter)) chapter_file = open(os.path.join(root, 'slides/' + chapter + '.' + lang + '.md'), 'r') delimiter = '\n@slide' chapter_input = ('\n' + chapter_file.read()).split(delimiter) slides = [delimiter + slide for slide in chapter_input][1:] chapter = '' for slide in slides: chapter += '
\n' + slides_helper.compile_slide(slide, root) + '\n
\n' return chapter