edwardez / bbob_dart

⚡️Blazing fast port of the BBCode parser and transformer [bbob](https://github.com/JiLiZART/bbob) in dart.
https://pub.dev/packages/bbob_dart
MIT License
9 stars 5 forks source link

Render attributes when a tag is not part of `validTags` #5

Open RomainFranceschini opened 1 year ago

RomainFranceschini commented 1 year ago

Currently when an invalid tag is emitted from the lexer, the parser renders the tag as a text node but strips all attributes.

Example:

parse('[h1 name=value]Foo [Bar=Quz]Quux[/Bar] [/h1]', validTags: {'h1'});

results in the following AST:

[
  Element(
    'h1',
    {'name': 'value'},
    [
      Text('Foo'),
      Text(' '),
      Text('[Bar]'),
      Text('Quux'),
      Text('[/Bar]'),
      Text(' '),
    ],
  )
]

Expected result:

[
  Element(
    'h1',
    {'name': 'value'},
    [
      Text('Foo'),
      Text(' '),
      Text('[Bar=Quz]'),
      Text('Quux'),
      Text('[/Bar]'),
      Text(' '),
    ],
  )
]