使用所见即所得编辑器解析用户输入

发布于 2024-11-29 16:52:14 字数 601 浏览 1 评论 0原文

新手尝试解析 TINYMCE 提供的 html。我允许用户在页面内创建选项卡和导航部分(基于 ID 的可链接 DIV)。目前我已经设置用户必须直接编辑 TINYMCE 的 HTML 源代码才能输入如下代码:

blah blah

服务器使用 PHP Simple DOM 解析器 解析此内容。最终结果是正确的,但会强制用户编辑 HTML 源代码,并且正如您可以想象的那样,它可能会变得非常草率。

理想情况下,用户无需编辑 HTML 源代码即可放置书签/选项卡。他们只需以独特的方式设计样式,例如将每个选项卡标题放在带有 H6 标题的列表中。

我正在考虑简单地实现类似的东西:[tabs]Tab Title 1[/tabs],但是解析它是否实用?使用 Simple DOM 解析器是不可能做到的。

也许我的做法是错误的?

Newbie here attempting to parse the html supplied from TINYMCE. I allow the user to create TABS and a navigation section inside the page (linkable DIVs based on ID). Currently I have it setup that the user must edit the HTML source directly of TINYMCE to put in code such as: <div id="tabs"> blah blah </div>

Server parses this by using the PHP Simple DOM parser. The end result is correct, but forces the user to edit the HTML source and it can get quite sloppy as you can imagine.

Ideally, the user would not have to edit the HTML source to place their bookmarks/tabs. They would merely have to style it in a unique way, such as putting each tab title in a list with a H6 heading.

I was thinking of simply implementing something like: [tabs]Tab Title 1[/tabs], but would parsing this be practical? It is impossible to do with Simple DOM parser.

Perhaps my approach is wrong?

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

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

发布评论

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

评论(1

债姬 2024-12-06 16:52:14

您可能可以使用方括号方法,然后使用正则表达式专门解析它以获取包含的文本。

示例:http://regexr.com?2uf83

You could probably use a square-bracket approach, and then parse that specifically using regex to get the contained text.

Example: http://regexr.com?2uf83

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