出于文档原因生成所有有效 BBCode 实体的列表
我已经成功地集成了 BBCode,但我想知道如果我想动态列出所有允许/接受的 BBCode - 我怎样才能做到这一点? (因为手动写出可能很乏味......如果 BBCode 发生变化,我必须更新书写)
我当前有一个 BBCode() 函数,其中包含 2 个数组,一个包含正则表达式,另一个包含其中包含替换项 (HTML),然后我返回正则表达式数组的 preg_replace()
以及替换项 (HTML) 数组。
I've managed to successfully integrate BBCode, but I was wondering say if I wanted to dynamically list all the allowed/accepted BBCode - how would I be able to do that? (as it can be tedious manually writing out...and if the BBCode ever changed I'd have to update the writing)
I current have a BBCode() function, which contains 2 arrays, one which contains the regex, and the other which contains the replacements (HTML), and then I return a preg_replace()
of the regex array with the replacement (HTML) array.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
考虑使用不同的标记语言,例如 Textile 或 Markdown。简单地说你支持 Markdown 或 Textile 就足够了;它们的使用非常广泛,用户可以轻松地在线查找它们的标记。
Textile 的语法自 2006 年以来就没有更新过,因此在未来几年内它可能会保持非常稳定。 Markdown 的语法自 2004 年以来就没有更新过。
两者都提供了优秀的 PHP 库:
Consider using a different markup language like Textile or Markdown. Simply saying that you support Markdown or Textile is decent enough; they're so widely used that users could easily look up the markup for them online.
Textile's syntax hasn't been updated since 2006, so it will likely remain very solid for years to come. Markdown's syntax hasn't been updated since 2004.
Both provide excellent PHP libraries: