Defect #11359

Wiki diff doesn't keep spaces

Added by Kouhei Sutou over 6 years ago. Updated 1 day ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Jean-Philippe Lang% Done:

0%

Category:Wiki
Target version:4.1.0
Resolution:Fixed Affected version:2.0.3

Description

Wiki diff page generates the following HTML:

<div class="text-diff">
...
<br />         sleep 10 
<br />       end 
...
</div>

From: http://www.redmine.org/projects/redmine/wiki/HowTo_run_Redmine_as_a_Windows_service_%28win32-service_+_taskill_approach%29/diff?version=3&version_from=2&commit=View+differences

And here is div.text-diff style:

.text-diff {
padding: 1em;
background-color:#f6f6f6;
color:#505050;
border: 1px solid #e4e4e4;
}

From: source:tags/2.0.3/public/stylesheets/application.css#L777

Spaces in Wiki page are ignored because the HTML doesn't use <pre> tag and the CSS also doesn't use white-space: pre.

0001-Don-t-ignore-spaces-in-diff-11359.patch Magnifier (1.33 KB) Kouhei Sutou, 2012-07-10 12:05

11359-before@2x.png (15.7 KB) Go MAEDA, 2017-09-17 08:00

11359-after@2x.png (15.6 KB) Go MAEDA, 2017-09-17 08:00

without-pre-wrap@2x.png (25.5 KB) Go MAEDA, 2018-09-22 09:37

with-pre-wrap@2x.png (43.4 KB) Go MAEDA, 2018-09-22 09:37

Associated revisions

Revision 17742
Added by Jean-Philippe Lang 1 day ago

Use pre tags for wiki diff (#11359).

Patch by Kouhei Sutou.

Revision 17743
Added by Jean-Philippe Lang 1 day ago

Adds white-space: pre-wrap; to diff output (#11359).

Patch by Go MAEDA.

History

#1 Updated by Kouhei Sutou over 6 years ago

Here is a patch that removes simple_format_without_paragraph and surrounds @diff.to_html with <pre class="text-diff"> instead of <div class="text-diff">.

#2 Updated by Go MAEDA over 1 year ago

Before:

After:

#3 Updated by Go MAEDA 3 months ago

I think it would be better to add white-space: pre-wrap; to text-diff class.

diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css
index c680fac92..e5224dca5 100644
--- a/public/stylesheets/application.css
+++ b/public/stylesheets/application.css
@@ -1073,6 +1073,7 @@ button.tab-left.disabled, button.tab-right.disabled {
   background-color:#f6f6f6;
   color:#505050;
   border: 1px solid #e4e4e4;
+  white-space: pre-wrap;
 }

 /***** Wiki *****/

Please see the following screenshots. Without white-space: pre-wrap;, you cannot see the whole content of long lines.

Without pre-wrap:

With pre-wrap:

#4 Updated by Jean-Philippe Lang 1 day ago

  • Status changed from New to Closed
  • Assignee set to Jean-Philippe Lang
  • Resolution set to Fixed

Committed, thanks.

Also available in: Atom PDF