Jump to content

Conversion XenForo > IPB : Add bbcode Rules on LegacyParser.php : <table> removed

Alexis Compain

Recommended Posts

Hello !

I'm trying to convert post from my xenforo forum to Ipboard. All seem to work fine but I'm trying to add rules for my custom bbcode.
I edited LegacyParser.php for add rules here.

Here an example of my working rules : 

$value = str_replace( "[hr]", '<hr />', $value );
$value = preg_replace( '/\[spoiler=.*?\]/im', '</p><div class="ipsSpoiler" data-ipsSpoiler><div class="ipsSpoiler_header"><span></span></div><div class="ipsSpoiler_contents"><p>', $value );
$value = preg_replace( '/\[format=h2\](.*?)\[\/format\]/im', '<h2>\\1</h2>', $value );
$value = preg_replace( '/\[format=h3\](.*?)\[\/format\]/im', '<h3>\\1</h3>', $value );
$value = preg_replace( '/\[format=h4\](.*?)\[\/format\]/im', '<h4>\\1</h4>', $value );
$value = preg_replace( '/\[format=h5\](.*?)\[\/format\]/im', '<h5>\\1</h5>', $value );

Now I have these rules too 

$value = preg_replace( '/\[table(?:=(.*?))?\]/im', '<table>', $value );
  $value = str_replace( "[/table]", "</table>", $value );
$value = preg_replace( '/\[td(?:=(.*?))?\]/im', '<td colspan="\\1">', $value );
  $value = str_replace( "[/td]", "</td>", $value );
$value = preg_replace( '/\[th(?:=(.*?))?\]/im', '<th colspan="\\1">', $value );
  $value = str_replace( "[/th]", "</th>", $value );
$value = str_replace( "[tr]", "<tr>", $value );
  $value = str_replace( "[/tr]", "</tr>", $value );

It seems working, but I don't know why, after conversation tableS tag get removed.

Why ? And where can I try to disable that just for the conversion ? 
I tried to find it, but nothing more at the moment :( 

Link to comment
Share on other sites

Update :

I've found something (if someone could be interested)

If i loose all of my table, that because htmlpurifier is called. But htmlpufifier shouldn't remove table.
This is only because I have many <br> and <p> added between my table tags

Issue on line 254 in function _LegacyParser->parse

$value = nl2br( $value );

Now, i'm trying to prevent <br> between table bbcode....
I'll come back if I found a trick

Link to comment
Share on other sites

Resolved by addin before 

$result = $this->parser->parse( $value );


This : 

$matches = array();
		if(preg_match_all('/<table>(.*)<\/table>/isU', $value, $matches)) {
			foreach ($matches as $match) {
				$temp = str_replace('</p><p>', '', $match);
				$value = str_replace($match, $temp, $value);


Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...