jBBCode icon indicating copy to clipboard operation
jBBCode copied to clipboard

Is it possible to create valid table code-set?

Open nokimaro opened this issue 11 years ago • 4 comments

Yes it's easy to create bb-codes for table [table], [th], [tr], [td] with CodeDefinitionBuilder like this

//table
$builder = new CodeDefinitionBuilder('table', '<table>{param}</table>');
array_push($this->definitions, $builder->build());

//thead
$builder = new CodeDefinitionBuilder('th', '<th>{param}</th>');
array_push($this->definitions, $builder->build());

//tr
$builder = new CodeDefinitionBuilder('tr', '<tr>{param}</tr>');
array_push($this->definitions, $builder->build());

//td
$builder = new CodeDefinitionBuilder('td', '<td>{param}</td>');
array_push($this->definitions, $builder->build());

But how to create definitions to parse [tr] only if it's inside [table][/table], and parse [td] if it's inside [tr][/tr]

Any solutions?

nokimaro avatar Dec 09 '14 18:12 nokimaro

why is this a problem, first place? Do you use those short-codes somewhere else? Can you please provide an example?

t1gor avatar Dec 09 '14 20:12 t1gor

This short-codes for users use. Simple table

[table]
[tr]
[td] content [td]
[tr]
[table]

Will be replaced to

<table>
<tr>
<td> content </td>
</tr>
</table>

But this will be invalid HTML, because no <table> around <td> etc...

[td]
[tr]
[table] invalid html [/table]
[/tr]
[/td]
<td>
<tr>
<table> invalid html</table>
</tr>
</td>

nokimaro avatar Dec 10 '14 02:12 nokimaro

My [table] BBCode is not converted, is it an issue ?

lobodol avatar Jan 05 '15 09:01 lobodol

@lobodol How can we know? We don't even know, how your actual code looks like.

Kubo2 avatar Apr 06 '15 19:04 Kubo2