Open alizahid opened 5 years ago
Same for me, this is weird with [br] user has to write [br][/br] to avoid a xbbcode error.
For what it's worth to future folks looking for standalone tag support, I did some pre-processing of the input to automatically add closing tags for any tags I knew were standalone tags. It's not as nice as native support, but for the size of bbcode I'm processing, it worked fine.
I used the following regular expression to process all the standalone tags that are not in [code] blocks:
RegExp('\[code\].\[\/code\]|\[('+'|'.join(tag_list)+')([ =][^\]]?)?\]', 'gmi')
And this code for processing those:
if tagName:
return matchStr+"[/" + tagName + "]"
return matchStr
This is in a platform where most of the code is Python, but you can convert that to Javascript if needed.
I simply looked for each tags key without an closing function, and made an simple replaceAll for each of them right after ret.html = parse(config
was done.
Tags like
[br]
or[hr]
or even ones that have attributes like[tag=value]
or[tag=value attribute=value]
. Are these not supported?