diff options
| -rw-r--r-- | templates/blog_admin/edit_post.html | 2 | ||||
| -rw-r--r-- | thatcomputerscientist/templatetags/escape.py | 5 |
2 files changed, 5 insertions, 2 deletions
diff --git a/templates/blog_admin/edit_post.html b/templates/blog_admin/edit_post.html index d3d17a8c..6ce7af18 100644 --- a/templates/blog_admin/edit_post.html +++ b/templates/blog_admin/edit_post.html @@ -35,7 +35,7 @@ <script src="https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.40.0/min/vs/loader.js"></script> <script src="{% static 'js/editor-theme.js' %}"></script> <script> - const postBody = `{{ post.body|escape|safe }}"`; + const postBody = `{{ post.body|escape|safe }}`; var editorInstance; // default loads diff --git a/thatcomputerscientist/templatetags/escape.py b/thatcomputerscientist/templatetags/escape.py index 854803bf..82453945 100644 --- a/thatcomputerscientist/templatetags/escape.py +++ b/thatcomputerscientist/templatetags/escape.py @@ -1,7 +1,10 @@ from django import template +import re register = template.Library() @register.filter(name='escape') def escape(value): - return value.replace("`", "\`") + val = value.replace("\\", '\\\\') + val = re.sub(r'`', r'\`', val) + return val |
