html - 在 Firefox 或 Chrome Inspector 中复制显示的 HTML(保持缩进和格式)

标签 html google-chrome-devtools firefox-developer-tools

我想知道是否有办法在 Firefox 或 Chrome 的检查器(开发人员工具)中复制 html,就像开发工具正在显示它一样。

很多页面没有格式正确的代码。如果您转到“查看源代码”(CTRL+U),有时会一团糟。两种浏览器的开发工具都做了非常整洁的格式和缩进,但我不知道如何复制它。

例如,检查器中的代码如下所示:

[Firefox 开发工具中的格式化代码]

粘贴到sublime text,就是一长串代码:

<div class="mod_customnav block"><a href="startseite.html#skipNavigation50" class="invisible">Navigation überspringen</a><ul class="level_1"><li class="verband first"><a href="vereine.html" title="Die Vereine im Badischen Sportschützenverband" class="verband first">Vereine</a></li><li class="geschaeftsstelle"><a href="oeffnungzeiten.html" title="Die Öffnungszeiten der Geschäftsstelle" class="geschaeftsstelle">Öffnungzeiten</a></li><li class="geschaeftsstelle"><a href="anfahrtsplan.html" title="So finden Sie uns" class="geschaeftsstelle">Anfahrtsplan</a></li><li class="formulare"><a href="waffenrecht.html" title="Waffenrechtliche Formulare" class="formulare">Waffenrecht</a></li><li><a href="sitemap.html" title="Die Website im Überblick">Sitemap</a></li><li><a href="kontakt.html" title="Kontaktformular">Nachricht an uns</a></li><li class="last"><a href="impressum.html" title="Impressum" class="last">Impressum</a></li></ul><a id="skipNavigation50" class="invisible">&nbsp;</a></div>

最佳答案

据我所知,没有办法以格式化的方式复制 HTML。虽然,至少对于 Firefox DevTools 存在 feature request asking to allow to select the elements shown within the tree , 所以你可以复制它们。不过,我不确定这是要以格式化方式复制元素还是仅复制 HTML 源代码。

话虽如此,还是有像 Free Online HTML Formatter 这样的在线工具。 ,它允许这样做。

关于html - 在 Firefox 或 Chrome Inspector 中复制显示的 HTML(保持缩进和格式),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49791749/

相关文章:

html - 导航栏位置问题解决

google-chrome - Chrome 开发工具在检索时间线时卡住

Javascript 堆栈跟踪显示为空

javascript - 如何像 Firefox 打印函数一样打印 Node.js 中的函数(即给出名称)?

google-chrome - Chrome 开发者工具中的 Webpack 3.5.5 调试显示两个源文件。 webpack下1个://and other under webpack-internal://

firefox - 如何更改Mozilla开发人员工具主题

html - 如何在 Azure DevOps 中将图像居中

html - 表格只能在 Chrome 中正常工作

css - Web 浏览器样式表是否会覆盖所有其他 CSS 样式?

google-chrome-devtools - 脱机时,Workbox 的offlineFallback 不起作用