使用 Ruby 格式化 HTML 源

发布于 2024-09-15 06:28:42 字数 153 浏览 2 评论 0原文

是否有任何 Ruby 库可用于格式化 HTML 源。我所说的格式化是指删除多余的空格、应用适当的缩进等。

我已经在使用 Hpricot 来解析 HTML。如果 Hpricot 能胜任这项工作就好了。但我不坚持使用 Hpricot 来进行格式化。

谢谢, 伊姆兰

Is there any Ruby library available to format the HTML source. By formatting I mean removing the extra spacing, apply proper indentation etc.

I am already using Hpricot for parsing HTML. It would be nice if Hpricot could do this job. But I am not stick with Hpricot for the formatting stuff.

Thanks,
Imran

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

笑,眼淚并存 2024-09-22 06:28:42

额外的间距和格式在 HTML 中并不重要,因此无论格式和空白如何,浏览器都应该以相同的方式显示代码。

Extra spacing and formatting don't really matter in HTML, so regardless of the formatting and white space, the browser should display the code as the same.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文