tabs do not receive proper indentation

samo - May 26, 2005 - 18:44
Project:Code Filter
Version:6.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:patch (code needs work)
Description

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);

#1

samo - August 11, 2005 - 20:45
Status:active» patch (code needs review)

patch attached

AttachmentSize
codefilter_tabs.patch581 bytes

#2

samo - August 11, 2005 - 20:46

sorry, wrong chunk.

AttachmentSize
codefilter_tabs_0.patch848 bytes

#3

JohnAlbin - August 17, 2007 - 21:49
Status:patch (code needs review)» patch (code 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.

 
 

Drupal is a registered trademark of Dries Buytaert.