antonmedv/codejar

HTML tag Bug

Opened this issue · 0 comments

There is a problem in custom highlight:

If I type <a/> it will be removed because is is HTML tag.

You can fix demo:

import {CodeJar} from 'codejar';

const node = document.querySelector('.editor');

const my = editor => {
-  let code = editor.textContent;
+  let code = editor.textContent.replace(/&/g, "&amp;").replace(/</g, "&lt;")
+      .replace(/>/g, "&gt;").replace(/"/g, "&quot;");

  code = code.replace(
    /\((\w+?)(\b)/g,
    '(<font color="#8a2be2">$1</font>$2'
  );
  editor.innerHTML = code;
};

const jar = CodeJar(node, my);