Code Monkey home page Code Monkey logo

ansitoimg's People

Contributors

daniel-at-github avatar fredhappyface avatar haochenx avatar ilyagr avatar imgbotapp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ansitoimg's Issues

Bug: Improper parsing of ansi codes

Bug

  • I have read the comment above and have completed each step
  • I have filled out the system info
  • I have described the bug, filled in the expected outcome and the actual
    outcome including screenshots where appropriate

System info

  • OS: Windows 11 build 25115
  • Browser: N/A
  • Version: 2022

Describe the bug

Parsing the following test results in ValueError: invalid literal for int() with base 10: '3;96'

\x1b[34m╭─\x1b[0m\x1b[34m────────────────────────────────────────────────────────────────────── \x1b[0m\x1b[1;34m<\x1b[0m\x1b[1;95mclass\x1b[0m\x1b[39m \x1b[0m\x1b[32m'jarvis.config.JarvisConfig'\x1b[0m\x1b[1;34m>\x1b[0m\x1b[34m ──────────────────────────────────────────────────────────────────────\x1b[0m\x1b[34m─╮\x1b[0m
\x1b[34m│\x1b[0m \x1b[3;96mclass \x1b[0m\x1b[1;31mJarvisConfig\x1b[0m\x1b[1m(\x1b[0m*args: list, **kwargs: dict\x1b[1m)\x1b[0m:
                                                                                         \x1b[34m│\x1b[0m
\x1b[34m│\x1b[0m
                                                   \x1b[34m│\x1b[0m
\x1b[34m│\x1b[0m  \x1b[3;33mOPTIONAL\x1b[0m = \x1b[1m{\x1b[0m\x1b[32m'sync'\x1b[0m: \x1b[3;91mFalse\x1b[0m, \x1b[32m'log_level'\x1b[0m: \x1b[32m'WARNING'\x1b[0m, \x1b[32m'cogs'\x1b[0m: \x1b[3;35mNone\x1b[0m, \x1b[32m'events'\x1b[0m: \x1b[3;92mTrue\x1b[0m, \x1b[32m'gitlab_token'\x1b[0m: \x1b[3;35mNone\x1b[0m, \x1b[32m'max_messages'\x1b[0m: \x1b[1;36m1000\x1b[0m, \x1b[32m'twitter'\x1b[0m: \x1b[3;35mNone\x1b[0m, \x1b[32m'reddit'\x1b[0m: \x1b[3;35mNone\x1b[0m, \x1b[32m'rook_token'\x1b[0m: \x1b[3;35mNone\x1b[0m\x1b[1m}\x1b[0m \x1b[34m│\x1b[0m
\x1b[34m│\x1b[0m  \x1b[3;33mREQUIRED\x1b[0m = \x1b[1m(\x1b[0m\x1b[32m'token'\x1b[0m, \x1b[32m'mongo'\x1b[0m, \x1b[32m'urls'\x1b[0m, \x1b[32m'redis'\x1b[0m\x1b[1m)\x1b[0m                                                                                                                                    \x1b[34m│\x1b[0m
\x1b[34m│\x1b[0m \x1b[3;33mfrom_yaml\x1b[0m = \x1b[3;96mdef \x1b[0m\x1b[1;31mfrom_yaml\x1b[0m\x1b[1m(\x1b[0mfilepath: Union\x1b[1m[\x1b[0mpathlib.Path, str\x1b[1m]\x1b[0m = \x1b[1;35mWindowsPath\x1b[0m\x1b[1m(\x1b[0m\x1b[32m'config.yaml'\x1b[0m\x1b[1m)\x1b[0m\x1b[1m)\x1b[0m -> \x1b[32m'Config'\x1b[0m: \x1b[2mLoad the yaml config file.\x1b[0m                                                 \x1b[34m│\x1b[0m
\x1b[34m│\x1b[0m      \x1b[3;33minit\x1b[0m = \x1b[3;96mdef \x1b[0m\x1b[1;31minit\x1b[0m\x1b[1m(\x1b[0mself, **kwargs: dict\x1b[1m)\x1b[0m -> \x1b[3;35mNone\x1b[0m: \x1b[2mInitialize the object.\x1b[0m                                                                                                         \x1b[34m│\x1b[0m
\x1b[34m│\x1b[0m    \x1b[3;33mreload\x1b[0m = \x1b[3;96mdef \x1b[0m\x1b[1;31mreload\x1b[0m\x1b[1m(\x1b[0m\x1b[1m)\x1b[0m -> bool: \x1b[2mReload the config.\x1b[0m                                                                                                                               \x1b[34m│\x1b[0m
\x1b[34m╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\x1b[0m

The error occurs in ansitoimg.utils on line 81. I think this is due to incomplete parsing of ansi modifiers like bold, italic, etc., or at least improper checking for these

Expected outcome

A proper render of the text, similar to the following:
image

Actual outcome

The aforementioned error

Feature: an option to not include the terminal titlebar

As I was thinking more about #10, I realized that I'd prefer to not spend any space
in the README on the titlebar of the terminal (and thus not have any title).

This is similar to how your own demo in https://github.com/FHPythonUtils/AnsiToImg/blob/master/README.md#example-output currently has titles removed.

Describe the solution you'd like

I would like the option to set title=None in the API and a --no-title option in the CLI
that removes the titlebar entirely.

Alternative

It's likely possible to crop the image like suggested in #7 (comment), but I'd like a solution that doesn't depend on knowing the exact image size.

Miss a real example in README

Think it's a good idea to add a real example into README, how to use it.
Something like this:

pipx install ansitoimg
ls --color=always /etc | ansitoimg ls.svg
git diff --color=always | ansitoimg diff.svg

Feature: custom width from the CLI

Feature

  • I have read the comment above and have completed each step
  • I have filled in each heading below

Have the ability to choose width size from the CLI tool.

Describe the solution you'd like

Now that #4 is fixed thanks to fd1666e, it should be easy to replace the --wide option that just make the fixed width move from 49 to 89 pixel with --width <size> where we would be able to provide a custom width.

--wide, -w Use a 'wide' virtual terminal (89 chars vs 49)

Feature: choose custom title text

Feature

  • I have read the comment above and have completed each step
  • I have filled in each heading below

  • Be able to remove the titlebar watermark (AnsiToImg (courtesy of Rich))
  • Choose custom titlebar text

Describe the solution you'd like

add a --titlebar <text> option that override the hardcoded watermark

2023.2 version fails with `poetry`.

I get:

$ poetry add ansitoimg@latest
$ poetry install
$ poetry run -- ansitoimg
Traceback (most recent call last):
  File "/home/ilyagr/.cache/pypoetry/virtualenvs/jj-docs-ZVbGoaMc-py3.11/bin/ansitoimg", line 5, in <module>
    from ansitoimg import cli
  File "/home/ilyagr/.cache/pypoetry/virtualenvs/jj-docs-ZVbGoaMc-py3.11/lib/python3.11/site-packages/ansitoimg/__init__.py", line 10, in <module>
    from ansitoimg.render import (
  File "/home/ilyagr/.cache/pypoetry/virtualenvs/jj-docs-ZVbGoaMc-py3.11/lib/python3.11/site-packages/ansitoimg/render.py", line 15, in <module>
    from ansitoimg.utils import TEXT_HEIGHT, TEXT_WIDTH, TITLE, WIDTH_DEFAULT, _resolveWidth
ImportError: cannot import name '_resolveWidth' from 'ansitoimg.utils' (/home/ilyagr/.cache/pypoetry/virtualenvs/jj-docs-ZVbGoaMc-py3.11/lib/python3.11/site-packages/ansitoimg/utils.py)

I don't get such problems if I poetry add [email protected].

OS: Linux dragon 5.15.124-20253-g52415d073cb4 #1 SMP PREEMPT Mon Aug 21 18:50:56 PDT 2023 x86_64 GNU/Linux

Python:

$ poetry run -- python --version
Python 3.11.4
$ poetry --version
Poetry (version 1.5.1)

Feature: Custom title with the CLI

#7 seems to have addressed this for the library invocation of ansitoimg, but could you also add a --title version to the CLI?

I may send a PR for this soon, if you are interested.

A more minor suggestion: the default title made me think your name is Rich. I didn't make the connection to the Rich library. Perhaps something like "colors powered by Rich" or "powered by Rich for Python" or "powered by rich" (with backticks) would be better.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.