ruby-on-rails – 如何剥离HTML标记,包括转义的图像标记而不使用’和 东西?

我需要从我的内容中删除所有html元素.内容示例:
"<p><img alt=\"\" src=\"/ckeditor_assets/pictures/1/content_twitter-sink.jpg\" style=\"width: 570px; height: 399px;\" /></p>\r\n\r\n<h3 style=\"font-size: 1.38462em; margin: 1em 0px 0px; font-weight: 600; line-height: 1.2; font-family: freight-sans-pro,sans-serif; -webkit-font-smoothing: antialiased; text-rendering: optimizelegibility; color: rgb(46,46,46);\">Soraya Calavassy,communications manager at the Award in Australia,&nbsp;shares her organisation&#39;s experience&nbsp;piloting our new global visual identity.</h3>\r\n\r\n<p style=\"margin: 0.5em 0px 0px; text-rendering: optimizelegibility; font-size: 1.30769em; line-height: 1.3; color: rgb(78,78,78); font-family: freight-sans-pro,sans-serif;\">&quot;While Australia has a very strong brand locally,there are some great benefits for incorporating"

当显示帖子我使用raw,它确实给了我需要的输出.但我需要制作摘录.为此,我需要删除所有HTML标记,甚至删除图像.但是,当我使用消毒时,它不会删除图像.如果我使用strip_tags,它将删除图像,但它会添加&#39;撇号,& nbsp;因此,如何获得一个没有图像和没有& nbsp;的清晰摘录.东西?

解决方法

尝试strip_tags(text).html_safe

相关文章

validates:conclusion,:presence=>true,:inclusion=>{...
一、redis集群搭建redis3.0以前,提供了Sentinel工具来监控各...
分享一下我老师大神的人工智能教程。零基础!通俗易懂!风趣...
上一篇博文 ruby传参之引用类型 里边定义了一个方法名 mo...
一编程与编程语言 什么是编程语言? 能够被计算机所识别的表...
Ruby类和对象Ruby是一种完美的面向对象编程语言。面向对象编...