有一个html css规范化程序工作? [英] Is there an html css normalizer that works?
问题描述
很久以前,我写了一个风格的规范化程序来扫描一大堆经典ASP页面的ASP / HTML代码(其中大部分是最初从MS-Word文档生成的,所以自然而然地,和大规模一次性风格)。样式规范化器生成一组最小的样式表和样式,以及一个新的'sanitized'asp / html文档,以便经过消毒的文档产生与原始的完全相同的渲染输出(通过屏幕截图图像比较验证)。
每一次,我都遇到了一个像这样的程序的需要,并开始写一个商业版本的想法。
我的Google搜寻技术并没有打开任何完全相同的样子(HTML:Normalize Perl module和HTML Tidy project只是似乎清除标记)。
问题是:
- 是否已经有商业或其他工具?
- is there such a tool already, commercial or otherwise?
- if not, does anybody really need it?
- if so, what features would make it truly worthwhile?
> re#3,例如,为一组页面收集基本样式表,或者调整所有页面以使用给定的基本样式表;保留经典的asp命令,下面的#includes,保存asp.net嵌入脚本,et al。
示例:
旧html w /嵌入式标签
< html>< head>
< title> title< / title>
< style type ='css / text'>
.cls1 {font-family:arial; font-size:10px; font-weight:bold; }
< / style>
< / head>
< body>
<%somefunction()%>
< div class ='cls1'style ='font-size:10px;'> test div< / div>
< / body>
< / html>
新html
< html>< head>
< title> title< / title>
< style type ='css / text'>
.cls1 {font-family:arial; font-size:10px; font-weight:bold; }
< / style>
< / head>
< body>
<%somefunction()%>
< div class ='cls1'> test div< / div>
< / body>
< / html>
请注意,div上的样式已经删除了,因为它是类cls1的多余
编辑:删除术语'sanitizer',因为我不专注于XSS攻击或过滤输入的评论,只是巩固了很多ad-hoc样式和随机CSS类
好吧,我不能肯定地说,这个工作的一切描述,
请参阅 HTML Tidy Configuration Options ,尤其是与Microsoft Word相关的选项(如 word-2000 )
Long ago, I wrote a style 'normalizer' program to scan the ASP/HTML code of a big pile of classic ASP pages (most of which were originally generated from MS-Word documents, so naturally they were littered with superflous stylesheets and massive one-off styles). The style normalizer generated a minimal set of stylesheets and styles and a new 'sanitized' asp/html document, so that the sanitized document produced exactly the same rendered output as the original (verified with screenshot image comparisons).
Every now and then, I run across a need for a program like this, and am toying with the idea of writing one for commercial release.
My googling skills have not turned up anything exactly like this (HTML:Normalize Perl module and HTML Tidy project just seem to clean up tags).
So, my questions are:
re #3 for example, collecting a base stylesheet for a set of pages, or adjusting all pages to use a given base stylesheet; preserving classic asp commands, following #includes, preserving asp.net embedded scripts, et al. The more specific and numerous, the better.
Example:
Old html w/embedded tags
<html><head>
<title>title</title>
<style type='css/text'>
.cls1 { font-family: arial; font-size: 10px; font-weight: bold; }
</style>
</head>
<body>
<% somefunction() %>
<div class='cls1' style='font-size:10px;'>test div</div>
</body>
</html>
New html
<html><head>
<title>title</title>
<style type='css/text'>
.cls1 { font-family: arial; font-size: 10px; font-weight: bold; }
</style>
</head>
<body>
<% somefunction() %>
<div class='cls1'>test div</div>
</body>
</html>
Note that the style on the div is gone, since it was redundant with the class cls1
EDIT: removed the term 'sanitizer' since i'm not focused on XSS attacks or filtering input in comments, merely on consolidating a lot of ad-hoc styles and random CSS classes into a minimal coherent set of stylesheets.
Well, I can't say definitively that this "works" for everything described, but Tidy does a bit more than clean up tags.
See the HTML Tidy Configuration Options, especially those relating to Microsoft Word (like word-2000)
这篇关于有一个html css规范化程序工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!