DeltaHF
Well-known member
I threw
Use at your own risk!
From Gemini:
The issues with pasting tables were caused by two distinct bugs in the HTML-to-BBCode renderer. One bug created invalid BBCode that broke the table structure, while the other caused the table to render with an unusable width.
The original
This caused the function to generate a
The solution is to add a stricter check that only accepts width values that are greater than zero.
The original
This "double application" of styles would corrupt the BBCode for any cell that had styling, such as centered text. The main renderer would correctly style the cell's content, but then
The fix is to remove the redundant call to renderCss(), ensuring styles are applied only once.
src/XF/Html/Renderer/BbCode.php
along with descriptions, samples, and screenshots of the errors at Gemini 2.5 Pro and it offered its own suggested changes below. I have modified the two functions and tables appear to be working now. Formatting like color, bold, and italics are preserved. Remember: editing the XF source files is not recommended and these changes will be overwritten the next time you upgrade XenForo.Use at your own risk!
From Gemini:
The issues with pasting tables were caused by two distinct bugs in the HTML-to-BBCode renderer. One bug created invalid BBCode that broke the table structure, while the other caused the table to render with an unusable width.
The original
handleTagTable()
function was too trusting and would accept any width value from the source HTML, including zero-value widths (like 0px) that are sometimes included when pasting from applications like Google Sheets.This caused the function to generate a
[TABLE width="0px"]
tag, which would correctly (but undesirably) render a table with no width.The solution is to add a stricter check that only accepts width values that are greater than zero.
PHP:
public function handleTagTable($text, Tag $tag)
{
$width = $tag->attributes()['style']['width'] ?? null;
// Check if width exists AND its integer value is greater than 0
if ($width && intval($width) > 0)
{
$output = "[TABLE width=\"$width\"]\n{$text}\n[/TABLE]";
}
else
{
$output = "[TABLE]\n{$text}\n[/TABLE]";
}
return $output;
}
The original
handleTagCell()
function was incorrectly applying CSS styles a second time, after they had already been processed.This "double application" of styles would corrupt the BBCode for any cell that had styling, such as centered text. The main renderer would correctly style the cell's content, but then
handleTagCell()
would re-apply the same style to the entire BBCode for that cell, creating an invalid structure.The fix is to remove the redundant call to renderCss(), ensuring styles are applied only once.
PHP:
public function handleTagCell($text, Tag $tag)
{
$tagName = $tag->tagName();
$width = $tag->attributes()['style']['width'] ?? null;
if ($width)
{
$output = "[$tagName width=\"$width\"]{$text}[/$tagName]";
}
else
{
$output = "[$tagName]{$text}[/$tagName]";
}
return $output;
}
Last edited: