Ghost: inline script in the editor has problems with ==
Put this in the editor (Ghost v0.6.4)
<script>
var x = 0;
if ( x === 0 ) {
alert("yay");
}
</script>
then publish.
View the blog post in a web browser. Would expect an alert box saying ‘yay’. However, we get a javascript error.
Inspecting the rendered HTML/JS code and we see
<script>
var x = 0;
if ( x <mark>= 0 ) {
alert("yay");
}
</script>
It looks like some macro replacement magic is taking place, replacing any == characters with <mark>.
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Reactions: 2
- Comments: 17 (5 by maintainers)
I have the same issue on Ghost Pro, the only way to avoid the problem is to add
<pre>tags before and after the<script>tags.@intositeme The work around I’m using is to modify showdown-ghost v0.3.6 to escape
<script>blocks before applying highlighting. Assuming you are using Ghost v0.7.6 simply replacenode_modules\showdown-ghost\src\extensions\highlight.jswith the following and restart Ghost: