phpBB-BBCode-Javascript-Parser icon indicating copy to clipboard operation
phpBB-BBCode-Javascript-Parser copied to clipboard

htmlToBBCode issue

Open HarpyWar opened this issue 13 years ago • 3 comments

bbcodeParser.htmlToBBCode doesn't work with complex tags.

For instance: bbcodeParser.addBBCode('[quote={TEXT1}]{TEXT2}[/quote]', '

{TEXT1}

{TEXT2}

'); var bbcode = bbcodeParser.htmlToBBCode('
Author

My message

');

It returns the same HTML string, but not BB code string.

HarpyWar avatar Feb 02 '12 14:02 HarpyWar

https://gist.github.com/1723831

HarpyWar avatar Feb 02 '12 14:02 HarpyWar

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.

wGEric avatar Feb 03 '12 04:02 wGEric

BB Code to HTML works fine.

It doesn't work with convertion from HTML to BB Code.

HarpyWar avatar Feb 03 '12 08:02 HarpyWar