プロジェクト

全般

プロフィール

Vote #79317

未完了

Redmine replaces tabs with spaces in code blocks

Admin Redmine さんが約2年前に追加. 約2年前に更新.

ステータス:
Confirmed
優先度:
通常
担当者:
-
カテゴリ:
Text formatting_26
対象バージョン:
-
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
26
version_id:
0
issue_org_id:
28793
author_id:
351555
assigned_to_id:
0
comments:
4
status_id:
9
tracker_id:
1
plus1:
0
affected_version:
closed_on:
affected_version_id:
134
ステータス-->[Confirmed]

説明

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

journals

--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
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.

<pre><code class="diff">
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!( /"$/, "\" " )
</code></pre>
--------------------------------------------------------------------------------
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.
--------------------------------------------------------------------------------


related_issues

duplicates,Closed,33707,Highlighted code with 'diff' format converts tabs to spaces, which breaks IDEs

Admin Redmine さんが約2年前に更新

  • カテゴリText formatting_26 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0