Display HTML comment lines (<! - ->) in HTML files
I create a source code search engine and I return the results on an HTML page (more precisely, aspx, but the presentation logic is in HTML).
When someone searches for a line, I also return the entire line of code where this line can be found in the file. However, some lines of code come from HTML / aspx files, and these lines contain special HTML () comments.
When I try to print this line on an HTML page, it interprets it as a comment and does not display it on the screen .... how can I solve this solution so that it really displays?
Any help would be appreciated. Thank.
, HTML-, HTML-. , ( , ), , <script> .
(aspx,
.NET HTML , , HTMLEncode. - , HTML- , Literal literalmode encode.
HTML)
, , innerHTML script, HTML-, JS :
// HTML-encode a string for use in text content or an attribute value delimited by
// double-quotes
//
function HTMLEncode(s) {
return s.replace(/&/g, '&').replace(/</g, '<').replace(/"/g, '"');
}
, , DOM , HTML-. ( element.textContent=, element.innerText IE, .)