Skip to content

Commit 6225467

Browse files
committed
Fix bool formatting
1 parent baba357 commit 6225467

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

djangocms_rest/plugin_rendering.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,12 @@ def escapestr(s: str) -> str:
9292
"""
9393
Escape a string for safe HTML rendering.
9494
"""
95-
return escape(s).replace(""", "\"").replace("\n", "\n")
95+
return (
96+
escape(s)
97+
.replace("\\", "\\")
98+
.replace(""", "\"")
99+
.replace("\n", "\n")
100+
)
96101

97102

98103
def highlight_data(json_data: Any, drop_frame: bool = False) -> str:
@@ -103,10 +108,10 @@ def highlight_data(json_data: Any, drop_frame: bool = False) -> str:
103108
if len(json_data) > 60:
104109
return f'<span class="str">"<span class="ellipsis">{escapestr(json_data)}</span>"</span>'
105110
return f'<span class="str">"{escapestr(json_data)}"</span>'
106-
if isinstance(json_data, (int, float)):
107-
return f'<span class="num">{json_data}</span>'
108111
if isinstance(json_data, bool):
109112
return f'<span class="bool">{str(json_data).lower()}</span>'
113+
if isinstance(json_data, (int, float)):
114+
return f'<span class="num">{json_data}</span>'
110115
if json_data is None:
111116
return '<span class="null">null</span>'
112117
if isinstance(json_data, dict):

0 commit comments

Comments
 (0)