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

Support for list tags #9

Open
aops opened this issue May 24, 2013 · 6 comments
Open

Support for list tags #9

aops opened this issue May 24, 2013 · 6 comments

Comments

@aops
Copy link

aops commented May 24, 2013

Enhancement suggestion: Support for list tags [li] and its various attributes as well a [*] which indicated each new list item.

Or is this currently possible some how?

@jbowens
Copy link
Owner

jbowens commented May 24, 2013

This is possible with the current version but with limitations. You could define a [list] bbcode and a list item bbcode. This type of syntax is possible:

[list]
  [li]first item[/li]
  [li]second item[/li]
  [li]third item[/li]
[/list]

However, there's currently no way to prohibit li bbcodes from existing outside any list bbcode block. Additionally, the ideal syntax would likely be:

[list]
  [*] first item
  [*] second item
  [*] third item
[/list]

This is not possible with jBBCode because there's no support for unary tags. Limiting bbcodes to certain contexts and unary tags would both require modifications to the parser, but it's definitely something to consider. In the meantime, if you want to create bbcodes for the example above, you could do something like:

$builder = new JBBCode\CodeDefinitionBuilder('list', '<ul>{param}</ul>');
$parser->addCodeDefinition($builder->build());
$builder = new JBBCode\CodeDefinitionBuilder('li', '<li>{param}</li>');
$parser->addCodeDefinition($builder->build());

@jbowens
Copy link
Owner

jbowens commented May 24, 2013

I take that back. This is possible right now by defining a custom CodeDefinition. I made a gist with an example:

https://gist.github.com/jbowens/5646994

Since I don't think there are very many other use cases for unary tags, this might be preferable to baking support into the parser itself. This does have limitations though. Since you're hacking with already produced HTML of the children of the list element, this will do nasty things if there are unclosed tags within lists.

@t1gor
Copy link

t1gor commented Sep 4, 2014

It would be also great if there was a functionality that could read the bbCode template from phpBB (just as an example) and use the read template as a CodeDefinitionSet

@axelson
Copy link

axelson commented Apr 3, 2015

Any chance that gist can be merged into the main code base? I'd argue that lists are a common feature.

@jbowens
Copy link
Owner

jbowens commented Apr 4, 2015

@axelson Not as is. That gist is pretty hacky. While I agree it'd be nice to add list support by default, I'd want to find a better way to do it. In the meantime, the API is designed for adding arbitrary code definitions, so there's not much of a burden for developers who do want to use that code definition.

@DaSourcerer
Copy link
Contributor

Somewhat unrelated but then again not: I'm not really satisfied with how the SmileyVisitor is working. Are there any plans to make (text)nodes splitable? I'd like to keep smileys and freestanding URLs separate so they won't conflict with each other.

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

No branches or pull requests

5 participants