phpBB-BBCode-Javascript-Parser
phpBB-BBCode-Javascript-Parser copied to clipboard
htmlToBBCode issue
bbcodeParser.htmlToBBCode doesn't work with complex tags.
For instance: bbcodeParser.addBBCode('[quote={TEXT1}]{TEXT2}[/quote]', '
{TEXT2}
My message
It returns the same HTML string, but not BB code string.
https://gist.github.com/1723831
Do you have any other BBCodes added that could be causing a conflict? I added a test case in commit 184315928a530dee and it passes. Line 320 is like what you are trying.
It is picky on how the bbcodes are setup. For example this works:
bbcodeParser.addBBCode('[quote="{TEXT1}"]{TEXT2}[/quote]', '<div class="quote"><cite>{TEXT1}</cite><p>{TEXT2}</p></div>');
bbcodeParser.addBBCode('[url={URL}]{TEXT}[/url]', '<a href="{URL}">{TEXT}</a>');
bbcodeParser.bbcodeToHtml('[quote="[url=http://www.google.com]Author[/url]"]My message[/quote]')
but this doesn't (only change is the double quotes around the author part of the quote bbcode)
bbcodeParser.addBBCode('[quote={TEXT1}]{TEXT2}[/quote]', '<div class="quote"><cite>{TEXT1}</cite><p>{TEXT2}</p></div>');
bbcodeParser.addBBCode('[url={URL}]{TEXT}[/url]', '<a href="{URL}">{TEXT}</a>');
bbcodeParser.bbcodeToHtml('[quote=[url=http://www.google.com]Author[/url]]My message[/quote]')
{TEXT1}
ends on the first ]
that it finds.
BB Code to HTML works fine.
It doesn't work with convertion from HTML to BB Code.