Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

codemirror fails when adding </textarea> tag inside it

I'm using codemirror http://marijn.haverbeke.nl/codemirror/ to let users create their own web templates inside a web application.

Codemirror works great, except for the time that users have put a tag inside their source code. When I load that up inside code mirror, it breaks everything in the source code that follows after because it thinks my codemirror text area is closed.

I'm using the following way to launch codemirror:

CodeMirror.fromTextArea('code')

It works great on my existing textarea "code" except when users add inside their templates (in the codemirror textarea).

like image 291
Jorre Avatar asked May 12 '10 08:05

Jorre


People also ask

How do I reset CodeMirror editor?

If you don't want to kill the CodeMirror instance, just change the entire document holding the text, data on markers etc. This can be done by calling cm. swapDoc(doc: CodeMirror. Doc) .


1 Answers

solved by wrapping htmlspecialchars() around the code, before putting it in code mirror!

like image 105
Jorre Avatar answered Sep 30 '22 09:09

Jorre