HTML tag Bug
Opened this issue · 0 comments
rinrab commented
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, "&").replace(/</g, "<")
+ .replace(/>/g, ">").replace(/"/g, """);
code = code.replace(
/\((\w+?)(\b)/g,
'(<font color="#8a2be2">$1</font>$2'
);
editor.innerHTML = code;
};
const jar = CodeJar(node, my);