Skip to content

Commit

Permalink
Added support for interaction section
Browse files Browse the repository at this point in the history
  • Loading branch information
cip999 committed Jan 14, 2023
1 parent ccd99e5 commit c668be1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions p2d/resources/statement_template.tex
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,8 @@ \section*{Input}
\section*{Output}
??OUTPUT??

\section*{Interaction}
??INTERACTION??

\section*{Samples}
??SAMPLES??
9 changes: 9 additions & 0 deletions p2d/tex_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ def generate_statement_tex(problem, tex_dir):

with open(os.path.join(RESOURCES_PATH, 'statement_template.tex')) as f:
statement_template = f.read()

# Some of these sections may be empty, in that case remove them.
for section_title in ['input', 'output', 'interaction']:
section_content = problem['statement'][section_title]
if section_content is None or str(section_content).strip() == '':
statement_template = statement_template.replace(
'\\section*{%s}' % section_title.capitalize(), ''
)

replacements_statement = {
'LABEL': problem['label'],
Expand All @@ -77,6 +85,7 @@ def generate_statement_tex(problem, tex_dir):
'LEGEND': problem['statement']['legend'],
'INPUT': problem['statement']['input'],
'OUTPUT': problem['statement']['output'],
'INTERACTION': '' if problem['statement']['interaction'] is None else problem['statement']['interaction'],
'SAMPLES': samples_tex
}
for placeholder in replacements_statement:
Expand Down

0 comments on commit c668be1

Please sign in to comment.