Cut-and-paste code with tabs instead of spaces is not displayed with indentation.

I'm terrible at this whole regex thing, but my fix was to add a line (line 71) after

$text = preg_replace("/^\n/", '', preg_replace('@</?(br|p)\s*/?>@', '', str_replace('\"', '"', $text)));

new line:

$text = preg_replace('/\t/', '&nbsp;&nbsp;&nbsp;&nbsp;', $text);

CommentFileSizeAuthor
#2 codefilter_tabs_0.patch848 bytessamo
#1 codefilter_tabs.patch581 bytessamo

Comments

samo’s picture

Status: Active » Needs review
StatusFileSize
new581 bytes

patch attached

samo’s picture

StatusFileSize
new848 bytes

sorry, wrong chunk.

johnalbin’s picture

Status: Needs review » Needs work

Blindly replacing tabs with 4 spaces won’t work, since the tabs in the middle of lines use a variable number of spots (1–4 spaces.)

Perhaps it‘s best to just replace the tabs at the beginning of lines.

alexandreracine’s picture

Why not just not replace the tabs?

It does that with the 6.x stable release too.

subscribing.

lokapujya’s picture

Issue summary: View changes
	Tab.
  2 Spaces.
no white space.
cameron tod’s picture

Status: Needs work » Closed (cannot reproduce)

According to lokapujya's comment, it looks as though tabs are preserved. I can't replicate this issue locally, so closing for now.