We don’t allow questions seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(6)
建议使用正则表达式。
其他解决方案:
这可能会由于错误关闭标签而中断解析,最终导致内容在不关闭的情况下用 HTML 标签包装。
It is recommended to use regex.
Other solution:
This can break parsing due to mis-closing tags can end up content being wrapped with a HTML tag without closing.
有一个 bbcode 的 PECL 扩展。您需要了解如何安装 PECL 扩展以便利用它。
There's a PECL extension for bbcode. You'll need to take a look on how to install PECL extensions in order to utilize it.
Zend 解析器可能就是您正在寻找的 http://framework.zend .com/manual/en/zend.markup.parsers.html
不幸的是,我发现它是我评估的 BBCode 解析器中最不实用的:当遇到格式错误的标记时(
[b] asdf [/ wops 我忘记关闭我的标签
)它往往会丢弃第一个格式错误的标签之后的所有内容。其他 bbcode 解析器在忽略不良标记方面做得更好。Zend parser might be what you're looking for http://framework.zend.com/manual/en/zend.markup.parsers.html
Unfortunately, I found it the least practically functional of the BBCode parsers I evaluated: when encountering malformed markup (
[b] asdf [/ wops I forgot to close my tag
) it tends to throw away all content after the first malformed tag. Other bbcode parsers do a much better job of simply ignoring bad markup.所以我知道你说没有正则表达式,但我最近用 JavaScript 编写了一个 BBCode 解析器,我相信它解决了你的担忧,因为它不是一个简单的查找和替换,它使你可以访问其中的内容标签。您可以在这里看到它的演示:
http://patorjk.com/bbcode-previewer/
并且获取源代码并在此处写下:
http: //patorjk.com/blog/2011/05/07/extendible-bbcode-parser-in-javascript/
So I know you said no regex, but I recently wrote a BBCode parser in JavaScript, and I believe it addresses your concerns since it is not a simple find and replace and it gives you access to the content within the tags. You can see a demo of it here:
http://patorjk.com/bbcode-previewer/
And get the source and write up on it here:
http://patorjk.com/blog/2011/05/07/extendible-bbcode-parser-in-javascript/
我最近用 javascript 编写了一个 bbcode 解析器。
它能做什么:
查看演示:UBBParser
I recently write a bbcode parser in javascript.
What it can do:
Check the demo: UBBParser
如果您可以安装 PECL 扩展,您将能够使用 BBCode 函数
If you can install a PECL extension, you will be able to use the BBCode functions