推荐的HTML格式化程序脚本/实用程序?

时间:2020-03-06 14:49:19  来源:igfitidea点击:

一个简单的问题是,我需要清理一大堆粗糙的html页面,并且正在寻找一种开源或者免费的脚本/实用程序,以删除所有垃圾并将其重新格式化为布局合理的一致代码。有什么建议吗?

如果合适的话,我通常会在Dreamweaver中操作HTML,但是可以通过编辑代码并使用所见即所得窗口作为预览而不是vica来进行预览,因此,与Dreamweaver兼容的脚本将是一个加分。

解决方案

我不认为它可以插入Dreamweaver,但是每当我需要html清理HTML时,Tidy就是我的最佳选择

我第二个HTML Tidy。
我只是想添加它,它是一个具有各种端口和绑定的库。因此,它还集成在HTML-Kit或者NoteTab之类的某些编辑器中,并且具有GUI前端。所有这些都在上面给出的页面中链接。
另请注意,W3C标记验证服务具有"使用HTML Tidy清理标记"的选项(在显示验证结果之后)。

如果站点很少,我们甚至可以在HTML Tidy到达浏览器之前通过HTML Tidy缓冲现有的HTML,这将使事情变得整洁而无需任何努力。

Dreamweaver CS3在"命令"菜单项下具有内置的"清理HTML"选项。我不认为它比HTML Tidy还要全面。

从Adobe网站:

Clean up code
  
  You can automatically remove empty tags, combine nested font tags, and otherwise improve messy or unreadable HTML or XHTML code.
  
  For information on how to clean up HTML generated from a Microsoft Word document, see Open and edit existing documents.
  
  
  Open a document:
  
  
  If the document is in HTML, select Commands > Clean Up HTML.
  If the document is in XHTML, select Commands > Clean Up XHTML. -- For an XHTML document, the Clean Up XHTML command fixes XHTML syntax errors, sets the case of tag attributes to lowercase, and adds or reports the missing required attributes for a tag in addition to performing the HTML cleanup operations.
  
  In the dialog box that appears, select any of the options, and click OK. -- Note: Depending on the size of your document and the number of options selected, it may take several seconds to complete the cleanup.
  
  
  Remove Empty Container Tags  Removes any tags that have no content between them. For example, <b></b> and <font color="#FF0000"></font> are empty tags, but the &ly;b> tag in &ltb>some text</b> is not. 
  
  Remove Redundant Nested Tags  Removes all redundant instances of a tag. For example, in the code <b>This is what I <b>really</b> wanted to say</b>, the b tags surrounding the word really are redundant and would be removed. 
  
  Remove Non-Dreamweaver HTML Comments  Removes all comments that were not inserted by Dreamweaver. For example, <!--begin body text--> would be removed, but <!-- TemplateBeginEditable name="doctitle" --> wouldn’t, because it’s a Dreamweaver comment that marks the beginning of an editable region in a template. 
  
  Remove Dreamweaver Special Markup Removes comments that Dreamweaver adds to code to allow documents to be automatically updated when templates and library items are updated. If you select this option when cleaning up code in a template-based document, the document is detached from the template. For more information, see Detach a document from a template. 
  
  Remove Specific Tag(s)  Removes the tags specified in the adjacent text box. Use this option to remove custom tags inserted by other visual editors and other tags that you don’t want to appear on your site (for example, blink). Separate multiple tags with commas (for example, font,blink). 
  
  Combine Nested <font> Tags When Possible  Consolidates two or more font tags when they control the same range of text. For example, <font size="7"><font color="#FF0000">big red</font></font> would be changed to <font size="7" color="#FF0000">big red</font>. 
  
  Show Log On Completion Displays an alert box with details about the changes made to the document as soon as the cleanup is finished.

我使用HTML Formatter ...它确实可以满足需求。

我也推荐HTML Tidy,尽管它不再由Dave Ragett维护,但该工具肯定会经常通过调整进行更新。

我使用HTML Trim(这是一个Win32应用程序)来清理一些可怕的自动生成的Blob,我们的一些开发人员将这些Blob删除了。

我们还可以获取可以集成到Dreamweaver中的命令行版本。

抱歉,我不能在这里发布多个超链接。

我绝对认为最好的工具是Logichammer.com的HTML Formatter。它完全可以满足需求,并且使用起来非常简单。值得一试...这个家伙甚至在他的网站上都有一个视频,显示它的易用性。我已经使用了两年了,无法忍受了……我得到了很多凌乱的代码。

我会推荐vim。我们可以使用v格式化代码块以选择代码块,并使用'='缩进代码。