From 2a5e5a44ab8272b47e928f74e04f2c95fe140a38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Wed, 30 Aug 2023 19:40:00 +0200 Subject: [PATCH] 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 --- include/layout.inc | 24 ++++++------------------ manual/add-note.php | 18 +++--------------- styles/theme-base.css | 4 ++-- 3 files changed, 11 insertions(+), 35 deletions(-) diff --git a/include/layout.inc b/include/layout.inc index 14d6d3607..7378d66ec 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 = '
' . str_replace( + $highlighted = '
' . strtr( + $highlighted, [ - ' ', - '
', - ' ' ', + "\n" => '', + + '\n", - ''; if ($return) { return $highlighted; } diff --git a/manual/add-note.php b/manual/add-note.php index 72d931bfa..e05a191da 100644 --- a/manual/add-note.php +++ b/manual/add-note.php @@ -190,11 +190,7 @@ else {
- - -

eval() is the best for all sorts of things

-
-
+ eval() is the best for all sorts of things
@@ -220,11 +216,7 @@ else {
- - -

If eval() is the answer, you're almost certainly asking the wrong question.

-
-
+ If eval() is the answer, you're almost certainly asking the wrong question.
@@ -250,11 +242,7 @@ else {
- - -

egg bacon sausage spam spam baked beans

-
-
+ egg bacon sausage spam spam baked beans
diff --git a/styles/theme-base.css b/styles/theme-base.css index 69866024a..01164945c 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 * {