Skip to content

Multiple tags with the same name #2

@NickThissen

Description

@NickThissen

Hi! Thanks for these fixes to the BBCode parser. I hope you are still reading this.
I am having some parsing trouble and hoped you could help.

I am trying to parse two possible flavors of the [url] tag:

1. [url]http://www.google.com[/url]
2. [url=http://www.google.com]Google[/url]

This is my desired output:

1. <a href="http://www.google.com" />
2. <a href="http://www.google.com">Google</a>

I know how to configure either of these, e.g.:

1. new BBTag("url", "<a href=\"${content}\" />", "", false, true)
2. new BBTag("url", "<a href=\"${href}\">", "</a>", new BBAttribute("href", ""))

The problem is, I cannot declare both of these at the same time because tags should have unique names. Both of these tags are named "url" so there's an error in the parser where it tries to obtain the tag by name.

Is this not supported? Isn't this an extremely common use-case and how pretty much every forum works?

I suppose to fix you'd have to get a list of all matching tags, and then figure out by their attributes which one is meant... But I haven't been able to get anywhere close to this. Hope you have an idea!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions