1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-05-05 15:16:16 +02:00

[ticket/11768] Moved the routine that replaces tabs with spaces

...to its own method. Also added a quick stripos() check for performance.

PHPBB3-11768
This commit is contained in:
JoshyPHP 2015-03-27 01:52:26 +01:00
parent d8e7e11ee3
commit 76088d64a6

View File

@ -229,12 +229,37 @@ class renderer implements \phpbb\textformatter\renderer_interface
}
$html = $this->renderer->render($xml);
if (stripos($html, '<code') !== false)
{
$html = $this->replace_tabs_in_code($html);
}
/**
* @see bbcode::bbcode_second_pass_code()
* Modify a rendered text
*
* @event core.text_formatter_s9e_render_after
* @var string html The rendered text's HTML
* @var \phpbb\textformatter\s9e\renderer renderer This renderer service
* @since 3.2.0-a1
*/
$html = preg_replace_callback(
'#(<code[^>]*>)(.*?)(</code>)#is',
$vars = array('html', 'renderer');
extract($this->dispatcher->trigger_event('core.text_formatter_s9e_render_after', compact($vars)));
return $html;
}
/**
* Replace tabs in code elements
*
* @see bbcode::bbcode_second_pass_code()
*
* @param string $html Original HTML
* @return string Modified HTML
*/
protected function replace_tabs_in_code($html)
{
return preg_replace_callback(
'((<code[^>]*>)(.*?)(</code>))is',
function ($captures)
{
$code = $captures[2];
@ -260,19 +285,6 @@ class renderer implements \phpbb\textformatter\renderer_interface
},
$html
);
/**
* Modify a rendered text
*
* @event core.text_formatter_s9e_render_after
* @var string html The rendered text's HTML
* @var \phpbb\textformatter\s9e\renderer renderer This renderer service
* @since 3.2.0-a1
*/
$vars = array('html', 'renderer');
extract($this->dispatcher->trigger_event('core.text_formatter_s9e_render_after', compact($vars)));
return $html;
}
/**