Closed javawolfpack closed 1 year ago
For reference in both cases, err
is the stderr
from subprocess for make
decoded as utf-8
:
Templates and run code 1:
Compiler Error:
{{ err }}
Run Code:
feedback_msg = {}
feedback_msg["err"] = err
feedback.set_feedback_from_tpl("compiler", feedback_msg, append = True)
Templates and run code 2:
Compiler Error:
{% for line in err %}
{{ line }}
{% endfor %}
Run Code:
feedback.set_feedback_from_tpl("compiler",
{"err":err.split("\n")}
)
Both generate the same parsing error message and logs.
Also, I'm pretty sure it's the ^
and ;
symbols in the output that is the culprit.
Feedback is parsed as reStructuredText using the docutils library (https://docutils.sourceforge.io/docs/user/rst/quickstart.html) and indents have syntaxic meaning. For code-blocks, you need to use the .. code ::
directive or simply ::
and indent each line in order for docutils to detect the end of the code block. For new paragraphs you need a double \n
The template should therefore more or less look like (first case):
Compiler error:
::
{{ err | indent(first=True,blank=True) }}
using the indent
jinja filter : https://jinja.palletsprojects.com/en/3.0.x/templates/#jinja-filters.indent
or (second case)
Compiler error:
::
{% for line in err %}
{{ line }}
{% endfor %}
Ok, that ::
directive was what I was missing. Thanks.
Describe the bug It appears that the way feedback is rendered from a template or generally, there are a few issues I've noticed. Firstly newline symbols are ignored. To fix this, I made a template, and have gone so far as to have the template iterate over output from say
make
split by new lines in my run script.Have now discovered that there are parsing exceptions in the syslogs from uwsgi:
Interestingly I get the result I want outside of a Parsing Error message, which might be confusing for my students.
INGInious installation details
To Reproduce Steps to reproduce the behavior:
Expected behavior Basically the screenshot without the "Parsing failed" message
Screenshots
Desktop (please complete the following information):
Additional context None