Open pedjas opened 8 years ago
Well, I guess you could implement a NodeVisitor
that is removing all leading and trailing whitespaces via trim()
in the TextNode
s of your table. In general it is not a good idea to implement tables in BBCode, though.
Well it is necessity. The same issue is with lists or other HTML tags that have inner structure.
Thing is trim should not be executed always. IT should be optional. I guess good solution would be to provide events so we can add our own code to handle such situations for BBC that needs it.
For complex tags like [list]
or [table]
I would recommend to create a own CodeDefinition
instead of using CodeDefinitionBuilder
.
Here you can see my implementation for [list]
: https://github.com/youthweb/bbcode-parser/blob/master/src/Definition/ListDefinition.php
Hope this will help you.
I have set definitions to parse BBC for table as:
It forks fine except it requires all BBC in a table to be in single line. If any part of table is split to new line, empty line will be inserted on top of rendered TABLE.
When dealing with tables it is necessary to split table to several lines and even make indentation for elements to make it readable.
Is there a way to clean all new lines and spaces outside of TR and TD tags within a TABLE?