Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Single element tags #22

Open
alizahid opened this issue Jan 22, 2019 · 3 comments
Open

Single element tags #22

alizahid opened this issue Jan 22, 2019 · 3 comments

Comments

@alizahid
Copy link

alizahid commented Jan 22, 2019

Tags like [br] or [hr] or even ones that have attributes like [tag=value] or [tag=value attribute=value]. Are these not supported?

@EricSTremblay
Copy link

Same for me, this is weird with [br] user has to write [br][/br] to avoid a xbbcode error.

@jshaffstall
Copy link

jshaffstall commented Sep 3, 2021

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.

@Merulast
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants