Author: Tim Düsterhus (TimWolla) Committer: GitHub (web-flow) Pusher: Girgias Date: 2023-08-30T18:40:00+01:00
Commit: https://github.com/php/web-php/commit/2a5e5a44ab8272b47e928f74e04f2c95fe140a38 Raw diff: https://github.com/php/web-php/commit/2a5e5a44ab8272b47e928f74e04f2c95fe140a38.diff 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 7d4038829e601bfdff3c434f5d8f20d84b344e27 * Unify `highlight_php()` with PhD see php/phd@01d6beb366bfb5e5b99bfdcc44393d8d1ee2d433 * Fix markup for notes in add-note.php Changed paths: M include/layout.inc M manual/add-note.php M styles/theme-base.css Diff: diff --git a/include/layout.inc b/include/layout.inc index 14d6d3607d..7378d66ec1 100644 --- a/include/layout.inc +++ b/include/layout.inc @@ -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, [ - ' ', - '<br>', - '<span style="color: ', - '</font>', - "\n ", - ' ', - ' ' - ], - [ - ' ', - "<br>\n", - '<span class="', - '</span>', - "\n ", - ' ', - ' ' + ' ' => ' ', + "\n" => '', + + '<span style="color: ' => '<span class="', ], - $highlighted ) . '</div>'; if ($return) { return $highlighted; } diff --git a/manual/add-note.php b/manual/add-note.php index 72d931bfac..e05a191da3 100644 --- a/manual/add-note.php +++ b/manual/add-note.php @@ -190,11 +190,7 @@ </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 @@ </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 @@ </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> diff --git a/styles/theme-base.css b/styles/theme-base.css index 69866024a2..01164945cb 100644 --- a/styles/theme-base.css +++ b/styles/theme-base.css @@ -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 * { -- PHP Webmaster List Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php