From c7785d8f54bce10dc36eb2e91fc7778ef9eadfd3 Mon Sep 17 00:00:00 2001 From: Alexander Kryklia Date: Mon, 24 Feb 2014 15:19:31 +0200 Subject: [PATCH] Allow HTML in grader messages. --- common/lib/capa/capa/inputtypes.py | 14 ++++- common/lib/capa/capa/responsetypes.py | 16 ++++-- common/lib/capa/capa/tests/test_inputtypes.py | 39 ++++++++++++++ .../lib/capa/capa/tests/test_responsetypes.py | 53 +++++++++++++++++++ 4 files changed, 116 insertions(+), 6 deletions(-) diff --git a/common/lib/capa/capa/inputtypes.py b/common/lib/capa/capa/inputtypes.py index 790e93679d..d638b41350 100644 --- a/common/lib/capa/capa/inputtypes.py +++ b/common/lib/capa/capa/inputtypes.py @@ -46,6 +46,7 @@ import re import shlex # for splitting quoted strings import sys import pyparsing +import html5lib from .registry import TagRegistry from chem import chemcalc @@ -286,7 +287,18 @@ class InputTypeBase(object): context = self._get_render_context() html = self.capa_system.render_template(self.template, context) - return etree.XML(html) + + try: + output = etree.XML(html) + except etree.XMLSyntaxError as ex: + # If `html` contains attrs with no values, like `controls` in