I recently created a Python library for terminal output. It includes a special color syntax and supports markdown. You can use it by running pip install custerm. When I initially uploaded it, I made a mistake by not linking a GitHub repository or including a README with some basic documentation. However, here’s a brief “list” of things you can do with it:
Input:
from custerm.ansi import Color
from custerm import Terminal
Terminal.print(
'__underline__\n\n- list\n- list\n\n**bold**',
markdown=True
)
Output:
Also supports code blocks.
Input:
from custerm.ansi import Color
from custerm import Terminal
Terminal.print(
'[GREEN]Custerm[/GREEN] [YELLOW]Test Colors[/YELLOW]',
markdown=False
)
as far as markdown goes, this is great! Having used FORE has been a hassle for my students because they don’t recognize they need to reset the color to another color if they change it. This way, they could just close it each line they are done with it, along with a host of other features!
I have not had much experience with installing “unsupported” libraries on replit however. Is there a way to get your library on replit/do I do it like normal?
In the Shell tab, run either poetry add custerm or pip install custerm. poetry is the Replit package manager and should add stuff to your Repl’s config files. pip of course is the Python package manager and also works.
Perfect, thats what I thought. I’ll have to tinker around with it when I get a chance… Honestly should be putting together a slidedeck for my upcoming computer hardware unit, but this seemed more interesting lol
Yes! This automatically resets the colors afterward. This fixes the issue of colors accidentally being used throughout the entire print, even though you didn’t want them. This is why [COLOR]test[/COLOR]. The [/COLOR] signifies the end of the color and also instructs it to reset the colors afterward, so after that syntax, it will automatically print the rest with the colors reset.
I just read it again. Currently, you can use markdown=False, but that disables all rendering. You asked if there’s a way to disable some types while enabling the rest. I can work on this; maybe something like this:
from custerm import Terminal
Terminal.print(
'**allowed**\n\n__disallowed__',
markdown=True,
allowed=['bold'],
disabled=['underline']
)
By default, if allowed and disabled are empty, it will allow all types of markdown.
it would be better, more efficient, and easier to add escape sequences such as ~to escape any char if its escapable and ~~ to escape the tilde. Instead of filtering types bc you could also want to mix-n-match double stars and literal double stars.
\ is already an escape code so itl be confusing to have to say \\\ or use \\ in strings. or if its not an escape code you can do it but why confuse yourself?
Ah, I don’t remember if I uploaded it with this function, but in the ansi color class, I created separate functions for custom colors. However, I might’ve removed them upon release.
Yeah, it had a function that was similar, but it was a bit more detailed and supported some
better colors and styles. However, I just checked, and it looks like I removed it upon release. But, I mean, custerm has special color syntax if you didn’t see: [COLOR]text[/COLOR] (/COLOR signifies the end of the text with the designated color, which, in return, will reset it afterwards). But, I mean, you should still be able to use that function similarly to something like: Terminal.print(f'{rgbCol(255,0,0)}'), while still maintaining the original color syntax. Yeah, it should work perfectly fine.