In verbatim text tabs automatically are being replaced by spaces. If you want to show code snipplets that are formatted using tabs, then this behavior may distort the code. I should be possible to turn off this substitution.

Problem Description

I often write pages in my MoinMoin wiki that contain short snipplets of code (bash scripts, some lines of Java, ...). For intending the code usually I use tabs. Unfortunately, MoinMoin automatically replaces tabs by spaces. In particular, this behavior is annoying when I want to display diffs of two files that contain tabs. These diffs then cannot be used by copy and paste for patching files. Additionally, since every browser known to me can display tabs in verbatim environments correctly, there is no urgent need to do the substitution. I think it is a good idea to make this feature configurable.

Patch

I suggest to introduce a new config option called "tabs_expansion_enabled" that by default is set to "True". If set to "False" the above mentioned substitution of tabs by spaces is disabled. To implement this I suggest the following patches for MoinMoin 1.8:

Changes to MoinMoin/config/multiconfig.py:

--- MoinMoin/config/multiconfig.py      2008-10-03 22:30:00.000000000 +0200
+++ MoinMoin/config/multiconfig.py
@@ -889,7 +889,7 @@
     ('edit_locking', 'warn 10', "Editor locking policy: `None`, `'warn <timeout in minutes>'`, or `'lock <timeout in minutes>'`"),
     ('edit_ticketing', True, None),
     ('edit_rows', 20, "Default height of the edit box"),
-
+    ('tabs_expansion_enabled', True, 'if True, replace tabs by spaces.'),
   )),
   # ==========================================================================
   'paths': ('Paths', None, (

Changes to MoinMoin/parser/text_moin_wiki.py:

--- MoinMoin/parser/text_moin_wiki.py   2008-08-31 22:00:00.000000000 +0200
+++ MoinMoin/parser/text_moin_wiki.py
@@ -1428,7 +1428,10 @@
         self.hilite_re = self.formatter.page.hilite_re
 
         # get text and replace TABs
-        rawtext = self.raw.expandtabs()
+        if self.cfg.tabs_expansion_enabled:
+            rawtext = self.raw.expandtabs()
+        else:
+            rawtext = self.raw
 
         # go through the lines
         self.lineno = self.start_line

Discussion

If it is made configurable then may be only for the plain text parser and not for the python parser. Because there tabs are a PEP-8 violation. I have learned myself tabs are always evil for contributors on any language I use. Because often they don't care for patches about that the source was done with tabs. The problem with tabs is that the editor program can handle it always different against to a defined amount of blanks. ReimarBauer/Photo/img.png -- ReimarBauer 2008-07-04 20:10:17


CategoryFeatureRequest

MoinMoin: FeatureRequests/MakeExpansionOfTabsConfigurable (last edited 2008-11-06 15:50:13 by ReimarBauer)