简体   繁体   English

反正有做自定义BBCode吗?

[英]Is There Anyway To Make Custom BBCode?

I have my own forum, currently I have features like editing, deleting and reporting both posts and replies but now I want to add features like BBCode. 我有自己的论坛,目前拥有编辑,删除和报告帖子和回复的功能,但现在我想添加BBCode之类的功能。 Right now I only want to try a [QUOTE][/QUOTE] feature where if the user selects the quote button it will take the quoted post, place it in a textarea with the quotes around the text. 现在,我只想尝试一种[QUOTE] [/ QUOTE]功能,如果用户选择引用按钮,它将采用被引用的帖子,将其放置在文本区域中,并在文本周围加上引号。 Then when it is submitted the page displays the quoted persons name and quote along with users post. 然后,提交后,页面将显示被引用人员的姓名和引用以及用户的帖子。

Eg [QUOTE name=Jane]This is a quote[/QUOTE] Hello. 例如[QUOTE name = Jane]这是一个报价[/ QUOTE]您好。

"Originally posted by Jane: This is a quote." “最初由简发布:这是一个报价。” Hello. 你好。

I'm sure I could use JavaScript / AJAX to get the user quoted and putting their post in a textarea with the [QUOTE] tags but not sure about have it display when the page loads as the example I mentioned about. 我确定我可以使用JavaScript / AJAX来获得用户的报价,并使用[QUOTE]标签将其帖子放置在textarea中,但不确定如何在页面加载时显示该帖子,如我所提到的示例。

If I can get this to work I could expand on other BBCode but right now this is the major feature I want. 如果我可以使用它,我可以在其他BBCode上进行扩展,但是现在这是我想要的主要功能。

It will probably be easier to use a third-party BBCode parser than to write your own, and then either use configuration to disallow other formatting options, or to remove those tags from the text. 使用第三方BBCode解析器可能比编写自己的解析器更容易,然后使用配置禁止其他格式设置选项,或者从文本中删除这些标记。

If you choose to write your own parser, I recommend a test-driven approach. 如果选择编写自己的解析器,则建议使用测试驱动的方法。 It can be tricky to handle things like escape characters, and there are often corner cases you may not discover right away. 处理转义字符之类的内容可能很棘手,而且经常出现一些极端情况,您可能不会立即发现。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM