formatter = ansilexer.HtmlAnsiFormatter()
else:
formatter = HtmlFormatter(nowrap=True)
- highlighted = highlight(code, lexer, formatter)
+
+ highlighted = highlight(code, lexer, formatter).rstrip()
# Strip whitespace around if inline code, strip only trailing
# whitespace if a block
- highlighted = highlighted.rstrip()
if not code_block: highlighted = highlighted.lstrip()
out.parsed += '<{0} class="{1}{2}">{3}</{0}>'.format(
'pre' if code_block else 'code',
f = filters_pre.get(lexer.name)
if f: code = f(code)
- parsed = highlight(code, lexer, formatter).rstrip()
- if not is_block: parsed.lstrip()
+ highlighted = highlight(code, lexer, formatter).rstrip()
+ # Strip whitespace around if inline code, strip only trailing whitespace if
+ # a block
+ if not is_block: highlighted = highlighted.lstrip()
global filters_post
# First apply local post filters, if any
for filter in filters:
f = filters_post.get((lexer.name, filter))
- if f: parsed = f(parsed)
+ if f: highlighted = f(highlighted)
# Then a global post filter, if any
f = filters_post.get(lexer.name)
- if f: parsed = f(parsed)
+ if f: highlighted = f(highlighted)
- return class_, parsed
+ return class_, highlighted
class Code(Directive):
required_arguments = 1