mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-30 21:40:43 +02:00
Merge pull request #3625 from s9e/ticket/11742
[ticket/11742] Remove tabs-to-space conversion in [code]
This commit is contained in:
8
phpBB/composer.lock
generated
8
phpBB/composer.lock
generated
@@ -220,12 +220,12 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/s9e/TextFormatter.git",
|
||||
"reference": "29c5959f4425934a53b6fdb42760d719b95a6e82"
|
||||
"reference": "0a6016ab96ab1da5be73f7a407f96f57d307b6b6"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/s9e/TextFormatter/zipball/29c5959f4425934a53b6fdb42760d719b95a6e82",
|
||||
"reference": "29c5959f4425934a53b6fdb42760d719b95a6e82",
|
||||
"url": "https://api.github.com/repos/s9e/TextFormatter/zipball/0a6016ab96ab1da5be73f7a407f96f57d307b6b6",
|
||||
"reference": "0a6016ab96ab1da5be73f7a407f96f57d307b6b6",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -270,7 +270,7 @@
|
||||
"parser",
|
||||
"shortcodes"
|
||||
],
|
||||
"time": "2015-05-18 04:48:32"
|
||||
"time": "2015-05-23 17:07:15"
|
||||
},
|
||||
{
|
||||
"name": "symfony/config",
|
||||
|
@@ -234,10 +234,6 @@ class renderer implements \phpbb\textformatter\renderer_interface
|
||||
}
|
||||
|
||||
$html = $this->renderer->render($xml);
|
||||
if (stripos($html, '<code') !== false)
|
||||
{
|
||||
$html = $this->replace_tabs_in_code($html);
|
||||
}
|
||||
|
||||
/**
|
||||
* Modify a rendered text
|
||||
@@ -253,45 +249,6 @@ class renderer implements \phpbb\textformatter\renderer_interface
|
||||
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];
|
||||
|
||||
$code = str_replace("\t", ' ', $code);
|
||||
$code = str_replace(' ', ' ', $code);
|
||||
$code = str_replace(' ', ' ', $code);
|
||||
$code = str_replace("\n ", "\n ", $code);
|
||||
|
||||
// keep space at the beginning
|
||||
if (!empty($code) && $code[0] == ' ')
|
||||
{
|
||||
$code = ' ' . substr($code, 1);
|
||||
}
|
||||
|
||||
// remove newline at the beginning
|
||||
if (!empty($code) && $code[0] == "\n")
|
||||
{
|
||||
$code = substr($code, 1);
|
||||
}
|
||||
|
||||
return $captures[1] . $code . $captures[3];
|
||||
},
|
||||
$html
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
@@ -12,8 +12,8 @@
|
||||
<!-- BEGIN quote_open --><blockquote class="uncited"><div><!-- END quote_open -->
|
||||
<!-- BEGIN quote_close --></div></blockquote><!-- END quote_close -->
|
||||
|
||||
<!-- BEGIN code_open --><div class="codebox"><p>{L_CODE}{L_COLON} <a href="#" onclick="selectCode(this); return false;">{L_SELECT_ALL_CODE}</a></p><code><!-- END code_open -->
|
||||
<!-- BEGIN code_close --></code></div><!-- END code_close -->
|
||||
<!-- BEGIN code_open --><div class="codebox"><p>{L_CODE}{L_COLON} <a href="#" onclick="selectCode(this); return false;">{L_SELECT_ALL_CODE}</a></p><pre><code><!-- END code_open -->
|
||||
<!-- BEGIN code_close --></code></pre></div><!-- END code_close -->
|
||||
|
||||
<!-- BEGIN inline_attachment_open --><div class="inline-attachment"><!-- END inline_attachment_open -->
|
||||
<!-- BEGIN inline_attachment_close --></div><!-- END inline_attachment_close -->
|
||||
|
@@ -513,7 +513,6 @@ blockquote .codebox {
|
||||
display: block;
|
||||
height: auto;
|
||||
max-height: 200px;
|
||||
white-space: normal;
|
||||
padding-top: 5px;
|
||||
font: 0.9em Monaco, "Andale Mono","Courier New", Courier, mono;
|
||||
line-height: 1.3em;
|
||||
|
Reference in New Issue
Block a user