清理 HTML 格式的内容以便在 Flash 中显示?

发布于 2025-01-08 01:00:06 字数 328 浏览 0 评论 0原文

我想在 Flash Flex 应用程序中显示来自各种来源的 HTML 格式的内容。 Flash 在其文本字段中支持 HTML 格式,但与 Web 浏览器相比,它的功能非常有限。是否有任何脚本可以将常见的 HTML 格式文本转换为 Flash 可以处理的格式?我的具体用例是:

  • 在 Flash 中显示 HTML 格式的电子邮件
  • 在 Flash 中显示 RTF 文件(在服务器上运行 RTF2HTML 转换后)
  • 显示从其他来源复制并粘贴到 Flash 中的随机 HTML 内容

我愿意接受在 Flash 中运行的代码客户端或服务器,但服务器可能更可取。

I want to display HTML formatted content from various sources inside a Flash Flex application. Flash supports HTML formatting in its text fields, however it is very limited compared to a web browser. Are there any scripts out there that will convert common HTML formatted text into a format that Flash can handle? My particular use cases are:

  • Displaying HTML formatted emails inside Flash
  • Displaying RTF files inside Flash (after running an RTF2HTML conversion on the server)
  • Displaying random HTML content copied and pasted from other sources into Flash

I'm open to code that runs either on the client or the server, but server is probably preferable.

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

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

发布评论

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

评论(3

情绪失控 2025-01-15 01:00:06

支持的 html 标签子集非常少,并且永远不会改变:

<a>, <b>, <br>, <font>, <img>, <i>, <li>, <p>, <textformat>, <u>

这意味着无论转换质量如何,html 都无法完全按照预期呈现;如果您用更基本的标签替换不受支持的标签,您也可能会放弃大部分 CSS 样式。

话虽这么说, http://simplehtmldom.sourceforge.net/ (PHP) 可以进行一些调整,并且它是也有足够的能力来处理无效的标记(看看你在处理来自不同来源的内容后的情况,我想说,从长远来看,这个功能本身就可以节省很多痛苦)-而不是将

<h1>,...,<h6> => <b>
<strong>      => <b>
<em>          => <i>

其余部分替换为明文你会的段落惊讶于它的可读性。你也可以像这样有点奇特:

<h1> => <b class="header1">

并根据需要添加一些CSS(尽管Flash CSS支持也非常有限)

我一直在为沙漠保存这个 - 你要么喜欢它,要么讨厌它,但它会做诡计。假设您的应用程序部署在浏览器中(如果没有,我误读了您的内容,请避免尴尬并停止阅读)您可以使用 iframe 来显示您的 html,说真的。

JS<->AS 通信相当简单,您可以将其放置在应用程序的预定区域上,给人一种它是应用程序一部分的错觉;只需记住正确设置 Flash 对象/嵌入的窗口模式,使其不会渲染在其他页面元素之上,然后增加 iframe z-index。

如果这被视为一种“丑陋”的方法,我不会感到惊讶,但它的内部很漂亮 - 您最终将获得逐字 html 和真正的 css 支持。至于用户交互,您甚至可以拦截 iframe 中的链接点击等,并从影片剪辑请求操作。

The subset of html tags supported is quite poor and has not changed in forever:

<a>, <b>, <br>, <font>, <img>, <i>, <li>, <p>, <textformat>, <u>

This means is that regardless of conversion quality, html cannot be rendered as fully intended; you could also be giving up a significant portion of css styling if you replace unsupported tags with more basic ones.

That being said, http://simplehtmldom.sourceforge.net/ (PHP) would work with some tweaks and it's competent enough to cope with invalid markup as well (seeing how you're after processing content from various sources, I'd say this feature alone would save a lot of pain in the long run) - than replace

<h1>,...,<h6> => <b>
<strong>      => <b>
<em>          => <i>

and plaintext the rest of it into paragraphs you'd be surprised at how readable it would still be. You could be a bit fancy too like so:

<h1> => <b class="header1">

and add some css as appropriate (although flash css support is pretty limited too)

I've been saving this one for desert - you'll either love it or hate it but it would do the trick. Assuming your app is deployed in-browser (if not and I misread you, save me the embarrassment and stop reading right here) you could use an iframe to display your html, seriously.

JS<->AS communication is fairly straightforward and you could have it positioned over a predetermined area of your app, giving the illusion that it's part of it; just remember to set windowmode on the flash object/embed correctly so it does not render on top of other page elements, then increase the iframe z-index.

I would not be surprised if this is seen as an "ugly" approach, but it's beautiful on the inside - you'll end up with verbatim html and real css support. As for user interactions, you could even intercept link clicks etc. in the iframe and request an action from the movieclip.

暖树树初阳… 2025-01-15 01:00:06

您可以使用 HTMLPurifier 并指定您想要支持的标签白名单。

You can use HTMLPurifier and specify a whitelist of tags that you want to support.

泪眸﹌ 2025-01-15 01:00:06

AS3 HTML Parser Library 不太符合我的要求,因为它不会转换 HTML,而是呈现它位于 Flash 中,这意味着它不可编辑。但在某些情况下,我只想显示而不是编辑文本,这可能很有用。

另一种选择是查看我希望能够显示的几个示例 HTML,然后编写正则表达式将它们转换为 Flash/TLF 期望的格式。但我觉得这可能是一项巨大的努力,因为 HTML 的范围很广。

AS3 HTML Parser Library is not quite what I'm looking for, since it does not convert the HTML but instead renders it within Flash, meaning that it wont be editable. But it may be useful in some cases that I only want to display and not edit text.

Another option is to look at several sample HTML that I'd like to be able to display, and then write regex to convert them to the format Flash/TLF expects. But I feel like that may be a huge endeavor, due to the wide range of HTML out there.

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