Project

General

Profile

Actions

Defect #28793

open

Redmine replaces tabs with spaces in code blocks

Added by Anton Shepelev almost 6 years ago. Updated over 3 years ago.

Status:
Confirmed
Priority:
Normal
Assignee:
-
Category:
Text formatting
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Affected version:

Description

Regardless of whether I use Markdown or Textile, Redmine always replaces tabs with spaces in code blocks, which makes the code read-only, i.e. one cannot copy and paste it into their program, so I have to attach source files to issues or send them in separate e-mails.

The underlying Markdown and Textile text is correct but is rendered into HTML wrong.

Code blocks should present code as it is written: spaces should be spaces and tabs should be tabs.

My Redmine environment:

Environment:
  Redmine version                3.4.4.stable
  Ruby version                   2.3.3-p222 (2016-11-21) [i386-mingw32]
  Rails version                  4.2.8
  Environment                    production
  Database adapter               Mysql2
SCM:
  Subversion                     1.8.16
  Filesystem                     
Redmine plugins:
  no plugin installed


Related issues

Has duplicate Redmine - Defect #33707: Highlighted code with 'diff' format converts tabs to spaces, which breaks IDEsClosed

Actions
Actions #1

Updated by Go MAEDA over 3 years ago

  • Has duplicate Defect #33707: Highlighted code with 'diff' format converts tabs to spaces, which breaks IDEs added
Actions #2

Updated by Go MAEDA over 3 years ago

  • Status changed from New to Confirmed
Actions #3

Updated by Go MAEDA over 3 years ago

The behavior of Textile formatter can be changed with the following patch, but I think it is not easy to change the behavior of Markdown formatter because is done in Redcarpet gem.

diff --git a/lib/redmine/wiki_formatting/textile/redcloth3.rb b/lib/redmine/wiki_formatting/textile/redcloth3.rb
index 92c6e29d0..374e3c046 100644
--- a/lib/redmine/wiki_formatting/textile/redcloth3.rb
+++ b/lib/redmine/wiki_formatting/textile/redcloth3.rb
@@ -1017,7 +1017,6 @@ class RedCloth3 < String
         # normalize line breaks
         text.gsub!( /\r\n/, "\n" )
         text.gsub!( /\r/, "\n" )
-        text.gsub!( /\t/, '    ' )
         text.gsub!( /^ +$/, '' )
         text.gsub!( /\n{3,}/, "\n\n" )
         text.gsub!( /"$/, "\" " )
Actions #4

Updated by Anton Shepelev over 3 years ago

Go MAEDA:

The behavior of Textile formatter can be changed with the following patch, but I think it is not easy to change the behavior of Markdown formatter because is done in [Redcarpet gem](https://github.com/vmg/redcarpet).

One solution would be to fix it in Markdown using your patch and create an issue with the Redcarpet project. Transparent code formatting is the more sensible behavior. If they want to keep the spaces for aesthetical reasons, then preserving tabs should be an option, whereas inconsistent behavior between formatters shall be shunned like the plague.

Actions

Also available in: Atom PDF