aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoshyPHP <s9e.dev@gmail.com>2015-03-27 01:52:26 +0100
committerJoshyPHP <s9e.dev@gmail.com>2015-04-02 19:16:04 +0200
commit76088d64a69ac8fdd10b8a633e72eefc1e36321b (patch)
tree53b8b70aaab8e882ca3fba1896404b01ac4acc13
parentd8e7e11ee3a5c49e80a4ec3e0bdf2011ba5e9ce7 (diff)
downloadforums-76088d64a69ac8fdd10b8a633e72eefc1e36321b.tar
forums-76088d64a69ac8fdd10b8a633e72eefc1e36321b.tar.gz
forums-76088d64a69ac8fdd10b8a633e72eefc1e36321b.tar.bz2
forums-76088d64a69ac8fdd10b8a633e72eefc1e36321b.tar.xz
forums-76088d64a69ac8fdd10b8a633e72eefc1e36321b.zip
[ticket/11768] Moved the routine that replaces tabs with spaces
...to its own method. Also added a quick stripos() check for performance. PHPBB3-11768
-rw-r--r--phpBB/phpbb/textformatter/s9e/renderer.php44
1 files changed, 28 insertions, 16 deletions
diff --git a/phpBB/phpbb/textformatter/s9e/renderer.php b/phpBB/phpbb/textformatter/s9e/renderer.php
index 168b13e692..7c58cd3d03 100644
--- a/phpBB/phpbb/textformatter/s9e/renderer.php
+++ b/phpBB/phpbb/textformatter/s9e/renderer.php
@@ -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;
}
/**