Merge branch 'master' into xelatex/Togo

This commit is contained in:
Benjamin Bohard 2021-07-19 12:27:14 +02:00
commit 0c8507b02f
2 changed files with 9 additions and 7 deletions

View File

@ -321,7 +321,7 @@ def main():
else: else:
return [] return []
def filter_outlines(headers_list, max_level=None): def filter_outlines(headers_list, max_level=0):
filtered_outlines = [] filtered_outlines = []
default_max_level = max([hl[1] for hl in headers_list]) default_max_level = max([hl[1] for hl in headers_list])
if not max_level: if not max_level:
@ -379,6 +379,8 @@ def main():
part_re = re.compile(r'\\part\{(?P<name>.*?)}') part_re = re.compile(r'\\part\{(?P<name>.*?)}')
subsection_re = re.compile(r'\\subsection\{(?P<name>.*?)\}') subsection_re = re.compile(r'\\subsection\{(?P<name>.*?)\}')
master_file = path.join('presentations', args.directory, 'diaporama.tex') master_file = path.join('presentations', args.directory, 'diaporama.tex')
max_level = args.levels
with open(master_file, 'r') as master_tex: with open(master_file, 'r') as master_tex:
master = master_tex.read() master = master_tex.read()
skbconfig = SKBCONFIG_RE.search(master) skbconfig = SKBCONFIG_RE.search(master)
@ -392,7 +394,7 @@ def main():
sections_list = [(section.start(), section_level, section.group('name')) for section in sections] 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)] 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] 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') content_file = path.join(path.dirname(path.abspath(master_file)), 'programme', 'contenu.tex')
with open(content_file, 'w') as content_fh: with open(content_file, 'w') as content_fh:
content_fh.write(structured_outline.render()) 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 = 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('-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) parser_outline.set_defaults(func=outline)
if subprocess.check_output(['rubber', '--version']): if subprocess.check_output(['rubber', '--version']):

View File

@ -42,15 +42,14 @@
\input{./programme/objectifs.tex} \input{./programme/objectifs.tex}
\section{Durée de la formation} \section{Durée de la formation}
\input{./programme/duree.tex} \input{./programme/duree.tex}
\IfFileExists{./programme/moyens.tex}{%
\section{Moyens pédagogiques, techniques et d'encadrement}
\input{./programme/moyens.tex}
}{}
\section{Évaluation des acquis} \section{Évaluation des acquis}
\input{./programme/evaluation.tex} \input{./programme/evaluation.tex}
\newpage \newpage
\section{Contenu de la formation} \section{Contenu de la formation}
\input{./programme/contenu.tex} \input{./programme/contenu.tex}
\IfFileExists{./programme/moyens.tex}{%
\section{Moyens pédagogiques, techniques et d'encadrement}
\input{./programme/moyens.tex}
\section{Évaluation des acquis}
}{}
\end{document} \end{document}