from pygments.lexers import RstLexer
from pygments.formatters import TerminalFormatter
from pygments import highlight
output = highlight(source, RstLexer(), TerminalFormatter())
p = subprocess.Popen('less', stdin=subprocess.PIPE)
p.stdin.write(output)
p.stdin.close()
p.wait()
When I just print output – everything is ok, but piping breaks highlighting…
Any ideas?
example:

That’s
less‘s fault, not Python’s. Runlesswith the-Rswitch: