So I have been struggling to use Highlight.JS in a textarea, because this doesn't work:
<!DOCTYPE html>
<html>
<head>
<title>Hello World</title>
<link rel="stylesheet" href="styles/default.css">
<script src="highlight.pack.js"></script>
<script>
hljs.initHighlightingOnLoad();
</script>
</head>
<body>
<form>
JavaScript Injection: <br>
<pre>
<code>
<textarea name="js_execute" cols="50" rows="10"></textarea>
</code>
</pre>
<input type="button" name="Inject_Execute_Button" value="Inject" onclick="executeJS()">
</form>
<script type="text/javascript">
function executeJS() {
alert("Wohoo");
}
</script>
<style type="text/css"></style>
</body>
</html>
I'm pretty sure there's an easy way to do this, so I am not going to explain it in too detail. But at the end, I would prefer to have code typed into the textarea highlighted in JavaScript.