aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWaylan Limberg <waylan@gmail.com>2010-07-07 11:57:12 -0400
committerWaylan Limberg <waylan@gmail.com>2010-07-07 11:57:12 -0400
commit93fac97c0974c00e3c5ff8d277ad216e343792e0 (patch)
tree2e226417b968126028d7506e80684129d4be3c21
parent9b1de64b9e4a049f3fd5c9efc343f0e37f7ce457 (diff)
downloadmarkdown-93fac97c0974c00e3c5ff8d277ad216e343792e0.tar.gz
markdown-93fac97c0974c00e3c5ff8d277ad216e343792e0.tar.bz2
markdown-93fac97c0974c00e3c5ff8d277ad216e343792e0.zip
Fixed tab_length on codehilite extension to match new implementation of default configs.
-rw-r--r--markdown/extensions/codehilite.py16
1 files changed, 5 insertions, 11 deletions
diff --git a/markdown/extensions/codehilite.py b/markdown/extensions/codehilite.py
index 9c6cbd4..e74493c 100644
--- a/markdown/extensions/codehilite.py
+++ b/markdown/extensions/codehilite.py
@@ -22,14 +22,6 @@ Dependencies:
import markdown
-# --------------- CONSTANTS YOU MIGHT WANT TO MODIFY -----------------
-
-try:
- TAB_LENGTH = markdown.TAB_LENGTH
-except AttributeError:
- TAB_LENGTH = 4
-
-
# ------------------ The Main CodeHilite Class ----------------------
class CodeHilite:
"""
@@ -54,13 +46,14 @@ class CodeHilite:
"""
def __init__(self, src=None, linenos=False, css_class="codehilite",
- lang=None, style='default', noclasses=False):
+ lang=None, style='default', noclasses=False, tab_length=4):
self.src = src
self.lang = lang
self.linenos = linenos
self.css_class = css_class
self.style = style
self.noclasses = noclasses
+ self.tab_length = tab_length
def hilite(self):
"""
@@ -117,7 +110,7 @@ class CodeHilite:
def _number(self, txt):
""" Use <ol> for line numbering """
# Fix Whitespace
- txt = txt.replace('\t', ' '*TAB_LENGTH)
+ txt = txt.replace('\t', ' '*self.tab_length)
txt = txt.replace(" "*4, "&nbsp; &nbsp; ")
txt = txt.replace(" "*3, "&nbsp; &nbsp;")
txt = txt.replace(" "*2, "&nbsp; ")
@@ -194,7 +187,8 @@ class HiliteTreeprocessor(markdown.treeprocessors.Treeprocessor):
linenos=self.config['force_linenos'][0],
css_class=self.config['css_class'][0],
style=self.config['pygments_style'][0],
- noclasses=self.config['noclasses'][0])
+ noclasses=self.config['noclasses'][0],
+ tab_length=self.markdown.tab_length)
placeholder = self.markdown.htmlStash.store(code.hilite(),
safe=True)
# Clear codeblock in etree instance