syntax hiliting if available

This commit is contained in:
Elan Ruusamäe 2012-06-20 00:13:07 +02:00
parent 026dad0959
commit a8123bee1a
2 changed files with 15 additions and 1 deletions

View file

@ -20,6 +20,10 @@ print code.colorize("abc", 1 + 1)
# fourth line # fourth line
}}} }}}
{{{#!cplusplus
foo = new something(1, "soo\nice")
}}}
{{{ {{{
plain plain
multiline block multiline block

View file

@ -194,7 +194,17 @@ class Formatter(FormatterBase):
return apply(FormatterBase.image, (self,), attrs) + '</img>' return apply(FormatterBase.image, (self,), attrs) + '</img>'
def code_area(self, on, code_id, code_type='code', show=0, start=-1, step=-1): def code_area(self, on, code_id, code_type='code', show=0, start=-1, step=-1):
return ('<code>', '</code>')[not on] syntax = ''
# switch for Python: http://simonwillison.net/2004/may/7/switch/
try:
syntax = {
'ColorizedPython': 'python',
'ColorizedCPlusPlus': 'cpp',
}[code_type]
except KeyError:
pass
return ('<code %s>' % syntax , '</code>')[not on]
def code_line(self, on): def code_line(self, on):
return ('', '\n')[on] return ('', '\n')[on]