Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9196529
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:52:12+00:00 2026-06-17T21:52:12+00:00

from pygments.lexers import RstLexer from pygments.formatters import TerminalFormatter from pygments import highlight output =

  • 0
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:

example

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T21:52:13+00:00Added an answer on June 17, 2026 at 9:52 pm

    That’s less‘s fault, not Python’s. Run less with the -R switch:

    -R or --RAW-CONTROL-CHARS

    Like -r, but only ANSI “color” escape sequences are output in “raw” form. Unlike -r,
    the screen appearance is maintained correctly in most cases. ANSI “color” escape sequences are sequences of the form:

    ESC [ ... m
    

    where the “…” is zero or more color specification characters For the purpose of keeping track of
    screen appearance, ANSI color escape sequences are assumed to not move the cursor. You can make less
    think that characters other than “m” can end ANSI color escape sequences by setting the environment
    variable LESSANSIENDCHARS to the list of characters which can end a color escape sequence. And you can
    make less think that characters other than the standard ones may appear between the ESC and the m by
    setting the environment variable LESSANSIMIDCHARS to the list of characters which can appear.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is my code: from google.appengine.ext import db import pygments from pygments import highlight
from fabric.api import sudo, put, run def install(): run('source /home/user/.virtualenvs/demo/bin/activate') run('pip install requests') if
From this context: import itertools lines = itertools.cycle(open('filename')) I'm wondering how I can implement
from win32com.client import Dispatch winhttp = Dispatch('winhttp.winhttprequest.5.1') print winhttp.Option(6) #True winhttp.Option(6) = False #SyntaxError
I need to highlight source code in LaTeX. The package listings seems to be
I'm trying to highlight a bunch of words - so I've written a pygments
from Tkinter import * master = Tk() listbox = Listbox(master) listbox.pack() listbox.insert(END, a list
from PySide.QtCore import * from PySide.QtGui import * import sys import stackwid class Dialog(QDialog,stackwid.Ui_Dialog):
I tried installing django-utils from source code from github and using pip. The installation
From my website, I have a button which calls a method and then generates

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.