在 Notepad++ 中显示不匹配的 html 标签

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8744063/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 12:21:52  来源:igfitidea点击:

Show unmatched html tags in Notepad++

htmlnotepad++

提问by Zack Macomber

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

有没有办法在 Notepad++ 中突出显示不匹配的 HTML 标签?

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

例如,如果我有以下 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.

我希望<HEAD>以某种方式突出显示该标签,以表明它没有相应的</HEAD>标签。

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.

我已经知道 Notepad++ 的点击标签来查看它对应的标签的功能。我希望突出显示在整个文档中不匹配的任何标签。即使我可以运行某种实用程序/插件,它也会为我列出任何不匹配标签的行号和名称。

采纳答案by Zack Macomber

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

我已经请求某人开发一个插件来在 Notepad++ 中执行此操作,网址https://sourceforge.net/projects/notepad-plus/forums/forum/331753/topic/4936812

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

在此之前,这似乎无法在 Notepad++ 中完成。

回答by user584583

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 {.

对于我正在处理的大文件,我找到额外/丢失 div 的解决方法是将文件的副本重命名为 file.java。然后将“/div”替换为},将“div”替换为{。

回答by psur

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.

  1. 成对打开-关闭的标签突出显示(紫色)。没有配对的标签不会突出显示。

  2. 边距上还有一条红线,通向结束标记。如果没有结束标记,您可以看到它无处可去。

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

下面是图像 - 第一个显示有效情况,第二个 - 无效。

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

(我的 Notepad++ 版本在 Windows 上是 5.9.5,选择的语言是 HTML)

Valid situation

有效情况

Invalid situation

无效情况