8
如何分辨页面上的一段 HTML 是富文本编辑器生成的还是直接用 html 的语法书写的?
source link: https://www.v2ex.com/t/804216
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
如何分辨页面上的一段 HTML 是富文本编辑器生成的还是直接用 html 的语法书写的?
富文本编辑器能将一段普通文本形成对应的 HTML 标签,有什么特征可以分辨出这段 html 是富文本编辑器生成还是直接用 html 的语法书写的?
例如这张页面框中的这部分,是如何形成的呢: https://developer.mozilla.org/zh-CN/docs/Learn
10 条回复 • 2021-09-26 13:55:55 +08:00
Pipecraft 1 天前 1
富文本编辑器生成的网页代码一般会包含 inline style 代码。有的设置字体大小,颜色的会用到 <font size=` ,<font color=` 这种标签。直接用 html 的语法书写的一般会用 class 设置字体和颜色。
2i2Re2PLMaDnghL 21 小时 24 分钟前 1
你只能通过一些启发式的方法去判断,比如你 #6 说的 class,或者 #8 说的 font,或者 span style (毕竟 html5 好像移除了 font )
至于通用的方法,应当是无解。
至于通用的方法,应当是无解。
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK