aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBobby <[email protected]>2023-07-25 23:55:53 -0400
committerBobby <[email protected]>2023-07-25 23:55:53 -0400
commitcbce3e49fcec9fd1a5da03cdbe91d4297f66f11c (patch)
treede035758c534bff06aadfb01fc88caa823b11d4b
parent8a75093f63d7dae11553f0348b211d74708d9154 (diff)
downloadthatcomputerscientist-cbce3e49fcec9fd1a5da03cdbe91d4297f66f11c.tar.xz
thatcomputerscientist-cbce3e49fcec9fd1a5da03cdbe91d4297f66f11c.zip
Fix post view in admin
-rw-r--r--templates/blog_admin/edit_post.html2
-rw-r--r--thatcomputerscientist/templatetags/escape.py5
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