Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Showing HTML comment strings (<!-- -->) in HTML files

Tags:

comments

html

I'm building a source code search engine, and I'm returning the results on a HTML page (aspx to be exact, but the view logic is in HTML).

When someone searches a string, I also return the whole line of code where this string can be found in a file. However, some lines of code come from HTML/aspx files and these lines contain HTML specific comments ().

When I try to print this line on the HTML page, it interprets it as a comment and does not show it on the screen....how should I go about solving this so that it actually shows up?

Any help would be welcomed. Thanks.

like image 587
Alex Avatar asked Dec 02 '25 10:12

Alex


1 Answers

As with any other HTML — covert special characters to entities. In particular < to &lt;

like image 142
Quentin Avatar answered Dec 05 '25 01:12

Quentin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!