pycontribs / pycontribs/ansi2html

The library can not render some escape codes about positions.

Open
#100 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Python
Stars
425
Forks
85
Avg merge
7h 49m
Merged PRs (30d)
12

Description

Hi.

I have a tiny test.

The next code puts a text in the bottom of terminal with urwid:

import urwid

def exit_on_q(key):
    if key in ('q', 'Q'):
        raise urwid.ExitMainLoop()


txt = urwid.Text(u"Hello World")
fill = urwid.Filler(txt, 'bottom')
loop = urwid.MainLoop(fill, unhandled_input=exit_on_q)

loop.run()

And it shows in term:

output_in_terminal

And the code to get the output in other python file is:

import os
import fcntl
import subprocess

p = subprocess.Popen(['python3', '/tmp/test00.py'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)

fd = p.stdout.fileno()  
fl = fcntl.fcntl(fd, fcntl.F_GETFL)  
fcntl.fcntl(fd, fcntl.F_SETFL, fl | os.O_NONBLOCK)
fd = p.stderr.fileno()  
fl = fcntl.fcntl(fd, fcntl.F_GETFL)  
fcntl.fcntl(fd, fcntl.F_SETFL, fl | os.O_NONBLOCK)
a = p.stdout.read()

from ansi2html import Ansi2HTMLConverter
conv = Ansi2HTMLConverter()
with open('/tmp/caca.html', 'w') as f: 
    f.write(conv.convert(a.decode('utf8')))
a.decode('utf8')

And the output is:

output_as_html

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the provided urwid and ansi2html reproducer, focusing on Ansi2HTMLConverter.convert and how terminal position escape codes are handled. Compare the terminal output with the generated HTML and add a regression test showing the expected positioning behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
web-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.