Skip to content

Commit

Permalink
Add a try-except clause in ParsableText
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeDerval committed Feb 3, 2015
1 parent cd1b93a commit 66696b5
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions common/parsable_text.py → parsable_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
# License along with INGInious. If not, see <http://www.gnu.org/licenses/>.
""" Tools to parse text """
from docutils import core
import cgi

from common.base import INGIniousConfiguration

Expand All @@ -37,10 +38,13 @@ def __init__(self, content, mode="rst"):

def parse(self):
"""Returns parsed text"""
if self.mode == "HTML":
return self.html(self.content)
else:
return self.rst(self.content)
try:
if self.mode == "HTML":
return self.html(self.content)
else:
return self.rst(self.content)
except:
return "<b>Parsing failed: <pre>"+cgi.escape(self.content)+"</pre>"

def __str__(self):
"""Returns parsed text"""
Expand Down

0 comments on commit 66696b5

Please sign in to comment.