BBCode to ANSI conversion routine for Godot 4.0
MIT License
This can be used for colored console printing.
Not functional on Windows 10 and later yet, as Godot doesn't enable virtual terminal processing yet.
Note: Some of these features will only work in certain terminals. This is especially the case for italic and strikethrough where terminal support can be spotty.
[b]
, [i]
, [u]
, [s]
).[code]
tag (doesn't change font, but appears as "faint" in supported terminals).[center]
/[right]
alignment (doesn't take terminal width into account emulated using tab characters).[indent]
tag (emulated using 4 spaces).[color]
(text color) and [bgcolor]
(background color, used for highlighting text).
red
, green
, blue
are supported.[fgcolor]
(redacted text) emulation using the same color as foreground and background.[url]
(unnamed URLs only). This works by stripping the tag and letting the terminal recognize URLs as-is.
[url=...]
is not supported as terminal support for it isn't widespread enough as of April 2022.For tags other than [color]
, [bgcolor]
and [fgcolor]
, tags can be contained within each other and formatting will be preserved as done in RichTextLabel.
For color tags, it's possible to get the same visual appearance without nesting tags (but it may be less convenient to script on your end).
Copyright 2022 Hugo Locurcio and contributors
Unless otherwise specified, files in this repository are licensed under the MIT license. See LICENSE.md for more information.