1
0
mirror of https://github.com/php/web-php.git synced 2026-03-23 23:02:13 +01:00

Use white-space: pre-wrap for code formatting (#810)

* Use `white-space: pre-wrap` for code formatting

Apparently code formatting is used for the entire user comments. Use
`white-space: pre-wrap` to avoid horizontal scrolling of the plaintext
description.


see 7d4038829e

* Unify `highlight_php()` with PhD

see php/phd@01d6beb366

* Fix markup for notes in add-note.php
This commit is contained in:
Tim Düsterhus
2023-08-30 19:40:00 +02:00
committed by GitHub
parent bd160d89cf
commit 2a5e5a44ab
3 changed files with 11 additions and 35 deletions

View File

@@ -20,26 +20,14 @@ function highlight_php($code, $return = false)
}
// Fix output to use CSS classes and wrap well
$highlighted = '<div class="phpcode">' . str_replace(
$highlighted = '<div class="phpcode">' . strtr(
$highlighted,
[
'&nbsp;',
'<br>',
'<span style="color: ',
'</font>',
"\n ",
' ',
' '
'&nbsp;' => ' ',
"\n" => '',
'<span style="color: ' => '<span class="',
],
[
' ',
"<br>\n",
'<span class="',
'</span>',
"\n&nbsp;",
'&nbsp; ',
'&nbsp; '
],
$highlighted
) . '</div>';
if ($return) { return $highlighted; }

View File

@@ -190,11 +190,7 @@ else {
</div>
<div class="text">
<div class="phpcode">
<code>
<span class="html">
<p>eval() is the best for all sorts of things</p>
</span>
</code>
<code><span class="html">eval() is the best for all sorts of things</span></code>
</div>
</div>
</div>
@@ -220,11 +216,7 @@ else {
</div>
<div class="text">
<div class="phpcode">
<code>
<span class="html">
<p>If eval() is the answer, you're almost certainly asking the wrong question.</p>
</span>
</code>
<code><span class="html">If eval() is the answer, you're almost certainly asking the wrong question.</span></code>
</div>
</div>
</div>
@@ -250,11 +242,7 @@ else {
</div>
<div class="text">
<div class="phpcode">
<code>
<span class="html">
<p>egg bacon sausage spam spam baked beans</p>
</span>
</code>
<code><span class="html">egg bacon sausage spam spam baked beans</span></code>
</div>
</div>
</div>

View File

@@ -1325,10 +1325,10 @@ div.tip p:first-child {
margin-bottom: 1.5rem;
}
.docs .phpcode code {
.phpcode code {
display: block;
overflow-x: auto;
white-space: pre;
white-space: pre-wrap;
}
.docs .qandaentry dt .phpcode * {