svenslaggare / BBCodeParser

BB code parser written in TypeScript.
MIT License
34 stars 18 forks source link

No list functionality for single tags #7

Open marksyzm opened 9 years ago

marksyzm commented 9 years ago

Nearly all BBCode engines I've used in the past use the following format:

[list]
[*]List item 1
[*]List item 2
[*]List item 3
[/list]

Same as:

<ul>
  <li>List item 1</li>
  <li>List item 2</li>
  <li>List item 3</li>
</ul>

But this is impossible with the parser in its current set up. I can have a look to alter it one day, but I don't know if I'll find the time. Can you help with this?

svenslaggare commented 9 years ago

The easiest way is to implement this is when parsing and encountering a [] tag and the previous tag is a [] tag, we see this as the end tag for the previous tag and the start tag of the current. We also need to see [/list] tag as the end tag for [*] tag.

This is not such a nice solution, but probably the easiest one to implement.

marksyzm commented 9 years ago

@svenslaggare agreed, checking that anything following a [*] tag with an open close bracket regardless of content will probably do it.