Ajuster le nombre de niveau de titre dans le plan

This commit is contained in:
Benjamin Bohard 2021-07-19 12:16:50 +02:00
parent 7ec35b0b14
commit ea89dd2971

View File

@ -321,7 +321,7 @@ def main():
else:
return []
def filter_outlines(headers_list, max_level=None):
def filter_outlines(headers_list, max_level=0):
filtered_outlines = []
default_max_level = max([hl[1] for hl in headers_list])
if not max_level:
@ -379,6 +379,8 @@ def main():
part_re = re.compile(r'\\part\{(?P<name>.*?)}')
subsection_re = re.compile(r'\\subsection\{(?P<name>.*?)\}')
master_file = path.join('presentations', args.directory, 'diaporama.tex')
max_level = args.levels
with open(master_file, 'r') as master_tex:
master = master_tex.read()
skbconfig = SKBCONFIG_RE.search(master)
@ -392,7 +394,7 @@ def main():
sections_list = [(section.start(), section_level, section.group('name')) for section in sections]
includes_list = [element for skbinput in includes for element in outline_from_include(file_path_from_skbinput(skbinput, master_file, skbconfig), skbinput.start(), document_class)]
subsections_list = [(subsection.start(), subsection_level, subsection.group('name')) for subsection in subsections]
structured_outline = structure_outline(filter_outlines(reorder_lists(parts_list, sections_list, includes_list, subsections_list)))
structured_outline = structure_outline(filter_outlines(reorder_lists(parts_list, sections_list, includes_list, subsections_list), max_level=max_level))
content_file = path.join(path.dirname(path.abspath(master_file)), 'programme', 'contenu.tex')
with open(content_file, 'w') as content_fh:
content_fh.write(structured_outline.render())
@ -427,6 +429,7 @@ def main():
parser_outline = subparsers.add_parser('outline', help="Création du programme à partir du fichier maître")
parser_outline.add_argument('-d', '--directory', help="Sous-répertoires contenant le diaporama", required=True)
parser_outline.add_argument('-l', '--levels', help="Niveaux de titre à inclure dans le plan", type=int, default=0)
parser_outline.set_defaults(func=outline)
if subprocess.check_output(['rubber', '--version']):