本文介绍了减少生成的HTML大小的工具的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是谷歌文档,我们使用的一些模板是使用MS-Office创建的。

由此产生的HTML非常胖且丑陋,并且每个谷歌文档限制500KB使得一些清理功能成为必需。
我能够找到多余的风格属性并将它们移动到一些CSS类中,并将最冗余的类名重命名为较短的类,这使我节省了大约原始大小的50%。

您是否知道一些现有的工具/脚本/ lib可以为我做这个痛苦的工作,或者至少帮我写这个神奇的工具?



谢谢提前!

编辑:我尝试了整齐,demoronizer和手动重写:

- 输入:140Kb

- Tidy'ed:110Kb

- Demoronized:135Kb



所以我最喜欢的答案是重写它!



谢谢!

解决方案

MS-Office让蹩脚的HTML, 。你最好花时间从原始文本重建HTML,而不是试图穿越那个雷区。



我制作了一些宏来执行一些搜索/替换功能Word做基本的事情,比如在段落和类似内容中包装< p> 标签,然后从头开始重新标记整个事物。


I'm using google docs, and some templates we are using were created using MS-Office.
The resulting HTML is fat and ugly, and the 500KB per doc limitation on google makes some cleanup mandatory.I was able to find redundant "style" attributes and move them to some CSS class, and rename the most redundant classes names to shorter ones, which makes me save about 50% of the original size.
Are you aware of some existing tools/scripts/lib which could do this painful job for me, or at least help me to write this magic tool ?

Thanks in advance !

EDIT: I gave a try to both tidy, demoronizer and "manual rewrite":
- Input : 140Kb
- Tidy'ed : 110Kb
- Demoronized : 135Kb

So my favorite answer will be "rewrite it!"

Thanks !

解决方案

MS-Office makes crappy HTML, period. You're better of spending time rebuilding the HTML from the original text than trying to walk through that minefield.

I made a few macros that do some search/replace functions on Word to do basic things like wrap <p> tags around paragraphs and stuff like that, then re-markup the whole thing from scratch.

这篇关于减少生成的HTML大小的工具的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 04:31
查看更多