How can I remove the first doctype hint in the ace editor in my html editor?

We are asking the user here to define html, so add a div or section or something like that. So, I want the validation tips to be changed when editing my HTML. But I do not want to have a document type warning.

ace editor hint

+5
source share
2 answers

try it

 var session = editor.getSession(); session.on("changeAnnotation", function() { var annotations = session.getAnnotations()||[], i = len = annotations.length; while (i--) { if(/doctype first\. Expected/.test(annotations[i].text)) { annotations.splice(i, 1); } } if(len>annotations.length) { session.setAnnotations(annotations); } }); 
+8
source

With "Unexpected file completion. Expected DOCTYPE." warning filtered.

 var session = editor.getSession(); session.on("changeAnnotation", function () { var annotations = session.getAnnotations() || [], i = len = annotations.length; while (i--) { if (/doctype first\. Expected/.test(annotations[i].text)) { annotations.splice(i, 1); } else if (/Unexpected End of file\. Expected/.test(annotations[i].text)) { annotations.splice(i, 1); } } if (len > annotations.length) { session.setAnnotations(annotations); } }); 
+3
source

Source: https://habr.com/ru/post/1234099/


All Articles