Download & Extend

tabs do not receive proper indentation

Project:Code Filter
Version:6.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:needs work

Issue Summary

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

Comments

#1

Status:active» needs review

patch attached

AttachmentSize
codefilter_tabs.patch 581 bytes

#2

sorry, wrong chunk.

AttachmentSize
codefilter_tabs_0.patch 848 bytes

#3

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.

#4

Why not just not replace the tabs?

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

subscribing.