Skip to content

Commit

Permalink
Realized that changes to code highlighting regex had broken its funct…
Browse files Browse the repository at this point in the history
…ioning in comments, so changed how it was detecting newlines. (Now using '\r?\n')

Also made the start of syntax highlighting block more flexible, allowing for more (or less) whitespace without breaking.
  • Loading branch information
lethain committed Jul 8, 2008
1 parent cd8413e commit c6ef191
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion markdown/mdx_code.py
Expand Up @@ -16,13 +16,17 @@ def extendMarkdown(self, md, md_global):
md.textPreprocessors.insert(0, preprocessor)


CODE_BLOCK_REGEX = re.compile(r"^(?P<spaces>[ ]*)@@ (?P<syntax>[a-zA-Z0-9_+-]+)[ ]?(?P<linenos>[a-zA-Z]*)$(?P<code>.*?)@@$", re.DOTALL | re.MULTILINE)
CODE_BLOCK_REGEX = re.compile(r"\r?\n(?P<spaces>[ ]*)@@[ ]*(?P<syntax>[a-zA-Z0-9_+-]+)[ ]*(?P<linenos>[a-zA-Z]*)[ ]*\r?\n(?P<code>.*?)@@[ ]*\r?\n", re.DOTALL | re.MULTILINE)

class CodeBlockPreprocessor :
def run (self, text):
print "searching for matches"
print text
print len(text)
while 1:
m = CODE_BLOCK_REGEX.search(text)
if not m: break;
print m
spaces = len(m.group('spaces'))
lexer = get_lexer_by_name(m.group('syntax'))
linenos = m.group('linenos')
Expand Down

0 comments on commit c6ef191

Please sign in to comment.