我们不允许为书籍、工具、软件库等寻求推荐的问题。你可以编辑问题,以便用事实和引文来回答。
Closed 4 years ago.
我正在寻找一个使用Javascript或PHP的BBCode解析器,而不需要使用Regex。有人能给我推荐一个好的吗?
我们不允许为书籍、工具、软件库等寻求推荐的问题。你可以编辑问题,以便用事实和引文来回答。
Closed 4 years ago.
我正在寻找一个使用Javascript或PHP的BBCode解析器,而不需要使用Regex。有人能给我推荐一个好的吗?
建议使用regex。
其他解决方案:
function bb_parse($str)
{
return str_replace(array( [b] , [/b] ), array( <strong> , </strong> ), $str);
}
这可能会中断解析,因为错误关闭标记可能导致内容在不关闭的情况下被HTML标记包装。
有一个bbcode的PECL扩展。您需要查看如何安装PECL扩展以便使用它。
Zend解析器可能是您想要的http://framework.zend.com/manual/en/zend.markup.parsers.html
不幸的是,我发现它是我评估的BBCode解析器中功能最差的:当遇到格式错误的标记([b]asdf[/wops我忘了关闭标记
)时,它往往会丢弃第一个格式错误标记之后的所有内容。其他BBCode解析器在忽略错误标记方面做得更好。
所以我知道你说没有regex,但我最近用JavaScript编写了一个BBCode解析器,我相信它解决了你的问题,因为它是而不是一个简单的查找和替换,它可以让你访问标签中的内容。你可以在这里看到它的演示:
http://patorjk.com/bbcode-previewer/
获取来源并在此处写下:
http://patorjk.com/blog/2011/05/07/extendible-bbcode-parser-in-javascript/
我最近用javascript编写了一个bbcode解析器。
它可以做什么:
查看演示:UBB Parser
如果可以安装PECL扩展,则可以使用BBCode函数
How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.
I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...
Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...
Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...
I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...
Is it possible for someone to give me a few pointers on how to display a multidimensional array in the form of a bar graph? The array is multidimensional, with three elements in each part - and the ...
Is it possible to reload a form after file-input change? I have a form where the user can chose an image for upload. I also have a php script which displays that image resized. I only wonder if it ...
I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.