bbcode

Javascript BBCode Parser recognizes only first list element

旧街凉风 提交于 2019-12-06 04:11:26
I have a really simple Javascript BBCode Parser for client-side live preview (don't want to use Ajax for that). The problem ist, this parser only recognizes the first list element: function bbcode_parser(str) { search = new Array( /\[b\](.*?)\[\/b\]/, /\[i\](.*?)\[\/i\]/, /\[img\](.*?)\[\/img\]/, /\[url\="?(.*?)"?\](.*?)\[\/url\]/, /\[quote](.*?)\[\/quote\]/, /\[list\=(.*?)\](.*?)\[\/list\]/i, /\[list\]([\s\S]*?)\[\/list\]/i, /\[\*\]\s?(.*?)\n/); replace = new Array( "<strong>$1</strong>", "<em>$1</em>", "<img src=\"$1\" alt=\"An image\">", "<a href=\"$1\">$2</a>", "<blockquote>$1</blockquote>

Linebreaks in TinyMCE editor show extra line on preview, not in code

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-05 04:12:29
I'm using the BBCode plugin with TinyMCE and see that line breaks are not showing the same between the preview and the HTML code. I have the following lines in the editor window: This is line one This is line three Line two is empty. When I'm viewing this in HTML I get the following. This is line one This is line three Without the extra empty line. tinyMCE.init({ mode : "textareas", theme : "advanced", plugins : "bbcode", entity_encoding : "raw", remove_linebreaks : false, force_p_newlines : false, force_br_newlines : true, forced_root_block : '' }); What am I missing? I have tested it on my

Javascript Not Parsing Nested Bbcode

左心房为你撑大大i 提交于 2019-12-04 05:22:14
问题 I have coded a Javascript bbcode similar to the one I'm using to write this message. It also incorporates a live preview box like the one I see below. The only problem I'm facing at the moment is that some nested bbcode is not parsing. For example: [quote] [quote][/quote] [/quote] Is not parsing correctly. This is my Javascript currently. function preview() { var txt = $('#editor').val(); txt = txt.replace(/</g,'<'); txt = txt.replace(/>/g,'>'); txt = txt.replace(/[\r\n]/g,'%lb%'); var find =

Regex & BBCode - Perfecting Nested Quote

China☆狼群 提交于 2019-12-03 20:25:42
问题 I'm working on some BBcode for my website. I've managed to get most of the codes working perfectly, however the [QUOTE] tag is giving me some grief. When I get something like this: [QUOTE=1] [QUOTE=2] This is a quote from someone else [/QUOTE] This is someone else quoting someone else [/QUOTE] It will return: > 1 said: [QUOTE=2]This is a quote from > someone else This is someone else quoting someone else[/QUOTE] So what is happening is the [/quote] from the nested quote is closing the quote

preg_replace() [function.preg-replace]: Unknown modifier '/' in /home/

时间秒杀一切 提交于 2019-12-02 20:57:50
问题 in my website i want to replace links with some other link like this www.abc.com or http://abc.com will be replaced with http://www.XXXXXX.com/sonal?www.abc.com or http://www.XXXXXX.com/sonal?http://abc.com so i am using this code but this code is giving some error Warning: preg_replace() [function.preg-replace]: Unknown modifier '/' in /home/XXXXX/public_html/YYYYYYYYY/KKKKKK.php on line 495 $search_array = array( "/\[url]www|http://.([^'\"]*)\[\/url]/iU", "/\[url]([^'\"]*)\[\/url]/iU", "/\

Simple BBparser in PHP that lets you replace content outside tags

ぐ巨炮叔叔 提交于 2019-12-02 20:15:51
问题 I'm trying to parse strings that represent source code, something like this: [code lang="html"] <div>stuff</div> [/code] <div>stuff</div> As you can see from my previous 20 questions, I tried to do it with PHP's regex functions, but ran into many problems, especially when the string is very big... Do you guys know a BB parser class written in PHP that I can use for this, instead of regexes? What I need it to do is: be able to convert all content from within [code] tags with html entities be

Skip parsing the BBCode inside the CODE tag

核能气质少年 提交于 2019-12-02 14:41:15
问题 I'm parsing the BBCode using the regex in order to replace it into the HTML. I'm stuck right now because of the [code] tags parsing. Basically, when you do [code][b]this is bb[/b] [u]code in[/u] [i]code[/i][/code] it shouldnt replace the [b] , [u] , [i] and similar tags that are INSIDE of the [code] tag. Unfortunately, using the preg_replace: $this->_text = preg_replace('/\[i](.+?)\[\/i]/i', '<em>\1</em>', $this->_text); $this->_text = preg_replace('/\[code](.+?)\[\/code]]/i', '<code>\1</code

how do I make a bbcode to parse url tags into links?

爱⌒轻易说出口 提交于 2019-12-02 12:57:36
问题 How should I go about parsing a url in php? I wanna make it so it goes [url=http://www.google.com]Google[/url] Turns into: <a href="http://www.google.com">Google</a> This is the code I'm using for my other bb codes: function postparser($post){ $post = str_replace("\n",'END_OF_LINE',$post); $post = str_replace("[line]",'HORIZONTAL_LINE',$post); $post = str_replace("[bold]",'BOLD_TEXT_START',$post); $post = str_replace("[/bold]",'BOLD_TEXT_END',$post); $post = str_replace("[yt]",'YOUTUBE_START'

preg_replace() [function.preg-replace]: Unknown modifier '/' in /home/

回眸只為那壹抹淺笑 提交于 2019-12-02 11:24:38
in my website i want to replace links with some other link like this www.abc.com or http://abc.com will be replaced with http://www.XXXXXX.com/sonal?www.abc.com or http://www.XXXXXX.com/sonal?http://abc.com so i am using this code but this code is giving some error Warning: preg_replace() [function.preg-replace]: Unknown modifier '/' in /home/XXXXX/public_html/YYYYYYYYY/KKKKKK.php on line 495 $search_array = array( "/\[url]www|http://.([^'\"]*)\[\/url]/iU", "/\[url]([^'\"]*)\[\/url]/iU", "/\[url=www|http://.([^'\"\s]*)](.*)\[\/url]/iU", "/\[url=([^'\"\s]*)](.*)\[\/url]/iU" ); $replace_array =

Simple BBparser in PHP that lets you replace content outside tags

最后都变了- 提交于 2019-12-02 10:59:54
I'm trying to parse strings that represent source code, something like this: [code lang="html"] <div>stuff</div> [/code] <div>stuff</div> As you can see from my previous 20 questions, I tried to do it with PHP's regex functions, but ran into many problems, especially when the string is very big... Do you guys know a BB parser class written in PHP that I can use for this, instead of regexes? What I need it to do is: be able to convert all content from within [code] tags with html entities be able to run some kind of a filter (a callback function of mine) only on content outside of the [code]