Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show unmatched html tags in Notepad++

Tags:

html

notepad++

Is there a way to highlight unmatched HTML tags in Notepad++?

For instance, if I had the following HTML...

<HTML>
<!--Server: <%=(java.net.InetAddress.getLocalHost()).getHostName()%>-->
<HEAD>
   <TITLE>Vital Stats</TITLE>
   <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
   <SCRIPT SRC="vital_stats.js" TYPE="text/javascript"></SCRIPT>
   <LINK REL="STYLESHEET" HREF="../main.css">
</HTML>

I would like the <HEAD> tag to be highlighted in some way to indicate that it doesn't have a corresponding </HEAD> tag.

I would also like to see any closing tags highlighted that don't have a corresponding opening tag.

EDIT

I already know about Notepad++'s feature of clicking a tag to see it's corresponding tag. I'm looking to highlight ANY tags that aren't matched in the ENTIRE document. Even if there's some sort of utility/plugin that I could run that would list for me the line number and name of any unmatched tags would be helpful.

like image 739
Zack Macomber Avatar asked Jan 05 '12 14:01

Zack Macomber


3 Answers

I've put in a request for someone to develop a plugin to do this in Notepad++ at https://sourceforge.net/projects/notepad-plus/forums/forum/331753/topic/4936812

Until that happens, it appears that this cannot be done in Notepad++.

like image 92
Zack Macomber Avatar answered Nov 16 '22 15:11

Zack Macomber


It's highlighted. Click on the tag and you can see:

  1. Tags which are pair open-close are highlighted (violet). Tags without pair aren't highlighted.

  2. There is also red line on the margin which leads to the closing tag. If there is no closing tag you can see that it leads to nowhere.

Below are images - first shows valid situation, second - invalid.

(My Notepad++ version is 5.9.5 on Windows and choosed language is HTML)

Valid situation

Invalid situation

like image 2
psur Avatar answered Nov 16 '22 14:11

psur


For the big file I was working on, my workaround to find the extra/missing div was to rename a copy of the file to file.java. Then replace "/div" with } and "div" with {.

like image 2
user584583 Avatar answered Nov 16 '22 13:11

user584583