Hello @tecmint,
We spoke with our tech team, and apparently you should only rely on Text mode while using the SyntaxHighlighter Enhanced plugin.
There isn’t an easy way to handle this properly I’m afraid, using only our own plugin or additional plugins to implement this (our developers even tested using the Raw HTML plugin and even then they recommend just relying on the Text tab to avoid escaping issues).
It looks more like a TinyMCE problem, and there’s no good way around that.
One thing that’s been suggested, but is not optimal, is to escape the?<script
?tag as?<script
?and?</script>
? as?</script>
, and use a snippet to replace it for the final user.? The snippet would look like that:
add_filter( 'do_shortcode_tag', function( $output, $tag, $attr, $m ) {
if ( in_array($tag, ["code", "html", "javascript"], true) ) {
$output = str_replace("&lt;", "<", $output);
}
return $output;
}, 10, 4 );
Keep in mind that the second line defines for what shortcodes this filter will run.
For instance, the code that you initially sent would look like this with this escaping:
<html>
<head>
<title>GeeksVeda</title>
<script type="module" src="main.js">
</script>
>
</head>
<body>
<h2>Including one file into another JS file</h2>
</body>
</html>
Note that, only two <
need to be replaced, and only for the <script>
tag (and its closing tag). That’s enough for blocking the TinyMCE from messing with the content.
Hopefully this fixes the issue!
-
This reply was modified 1 year, 4 months ago by Stef (a11n).
-
This reply was modified 1 year, 4 months ago by Stef (a11n).