From 174da7fe687bd3bf2f6874620e708db24160c4d7 Mon Sep 17 00:00:00 2001 From: Jongwook Choi Date: Tue, 14 May 2024 23:34:14 -0400 Subject: [PATCH] docs(gen_help_html.lua): fix broken pre text, and handle linewrap Problem: - Since #28678, pre-formatted text in the online documentation do not render whitespaces correctly: should be pre-like text, but shown like normal paragraph (see #28754). - Code blocks with long lines should not be wrapped (e.g. see |dev-vimpatch-list-management|). Solution: - Use `white-space: pre-wrap`. Compared to `white-space: pre`, this option will make long lines including a very long URL wrapped. This properly fixes #28754 and #28678. - Use horizontal scrollbar for the code blocks that are horizontally too long, instead of wrapping text. This will make the code easy to read while the pre-text block not interfering with the navigation bar. --- scripts/gen_help_html.lua | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/scripts/gen_help_html.lua b/scripts/gen_help_html.lua index d65f3aace2..7432f5ecc4 100644 --- a/scripts/gen_help_html.lua +++ b/scripts/gen_help_html.lua @@ -1093,14 +1093,19 @@ local function gen_css(fname) padding-bottom: 10px; /* Tabs are used for alignment in old docs, so we must match Vim's 8-char expectation. */ tab-size: 8; - white-space: normal; + white-space: pre-wrap; font-size: 16px; font-family: ui-monospace,SFMono-Regular,SF Mono,Menlo,Consolas,Liberation Mono,monospace; word-wrap: break-word; } - .old-help-para pre { + .old-help-para pre, .old-help-para pre:hover { /* Text following
 is already visually separated by the linebreak. */
       margin-bottom: 0;
+      /* Long lines that exceed the textwidth should not be wrapped (no "pre-wrap").
+         Since text may overflow horizontally, we make the contents to be scrollable
+         (only if necessary) to prevent overlapping with the navigation bar at the right. */
+      white-space: pre;
+      overflow-x: auto;
     }
 
     /* TODO: should this rule be deleted? help tags are rendered as  or , not  */