package ansifmt
A simple, lightweight library for ANSI styling
Install
dune-project
Dependency
Authors
Maintainers
Sources
ansifmt-1.0.0-pre2.tbz
sha256=2587f45a2854a760140e98bdf131c1aae9aa2f2f44b474c0e11ed521dab5e3cf
sha512=95ae665b49c19f42b3d39a48ea34c9cf08b8ca004e8ebe439287b3fac8ad7a99e8ff5259eb236a8da9ca2a2dd7f3ad77202f246fb76ebc9a3de02c7127dff877
doc/CHANGES.html
1.0.0
1.0.0 is a complete rewrite of ansifmt.
At this stage, ansifmt has been fully rewritten. It now includes a test suite. This version is entirely incompatible with ansifmt 0.3.0 and older. Notably, some of its features were purposefully lost in this rewrite. Users should expect a new library on top of this one to replace them in the future.
Changes
ansifmt
is now split in two modules:Ansi
, which provides APIs for escape sequences (inAnsi
), attributes as a low-level representation (inAnsi.Attribute
) and terminal-compatible colors (inAnsi.Color
), andFmt
, which provides a pretty-printable string API built on top ofAnsi
.- The
Color
API has been simplified. Colors can now be constructed using built-in integers ; they will be normalized-on-demand.Advanced
is now calledBasic
.Minimal
has been dropped as it is already covered byBasic
, assuming that modern terminal emulators support 8-bit colors. - The
Styling
API (now calledAnsi
) has been tremendously simplified and is now based on a choice type instead of a record type. parse_hex
is nowof_hex_repr
.- Luminance calculation now linearizes properly the color.
Features
- A new
Fmt
API is available, which allows to construct strings with specific parts stylized usingAnsi
. This includes a convenient function,Fmt.print
, to print in the terminal, stripping escape sequences when the output channel is not a TTY (by default -- this is configurable). - Color parsing now supports deserialization of strings of the form
rgb(r, g, b)
. Ansi
,Attributes
,Color
andFmt
objects are serializable.Ansi
objects are now deserializable.
Removed
- The
Formatting
API has been fully dropped. We estimate thatansifmt
is not the right place to put this in. Instead, we are working on another library, built on top ofansifmt
, that will provide these features in an improved manner. - The
IO
API has been removed followingFormatting
.
Performance
No benchmark has been done, so this should be taken with a grain of salt, but it is likely that the new version exhibits better performance, due to simplification of implementation and lightening of the library overall.
0.3.0
Features
- Add
Custom
token type variant which takes a styling, for tokens without particular semantics. - Add
Formatting.Element
that supersedesFormatting.Tree
. - Add
Formatting.Interfaces.TO_ELEMENT
interface which establishes the contract to convert to a formatting element that is used by formatting and printing utilitary functions such asformat
andIO.print_formatted
. - Expose the
Int8
module that is used byColor
. - Add
Token.number
to easily construct a number literal token.
Removed
- Remove
Formatting.Tree
,Formatting.TOKENIZABLE
and its associated functions. UseFormatting.Element
instead. - Remove the
Prelude
module. It has merged with the coreAnsifmt
module. - Remove
print_formatted
alias from the prelude. The function can still be found asIO.print_formatted
. - Remove
make_styling
alias from the prelude. The function can still be found asStyling.create
.
Internal
- Renamed
Utils
toInternal
. Formatting
is now a directory instead of a file containing all its submodules.- Added
List.intersperse
andList.singleton
(used inFormatting.Element
). - Added
Bool.tautology
(used inFormatting.Element
).
0.2.0
Features
- Add color functions
luminance
andbest_for_contrast
. (by @chshersh in #5) - Add styling functions
fg
,bg
,bold
,dim
,italic
,underlined
. (by @chshersh in #6) - Add styling composition with
&
. (by @chshersh in #6) - Add function
make_rgb_hex
to parse hexadecimal codes into RGB colors. (by @chshersh in #7)
Breaking Changes
Color.t
andColor.Ground.t
are now polymorphic variants. (by @chshersh in #5)
Removed
Util.parenthesize_if
which is deemed unuseful and is kind of a duplicate ofTree.parenthesize_if
inFormatting
.
0.1.3
Fixes
- Fixed a bug where unwanted
m
characters would appear in the output before every colored token
0.1.2
Fixes
- Moved
Formatting.tokenize
andFormatting.format
to a dedicatedFormatting.Util
submodule - it is common for users who wish to implementTOKENIZABLE
toopen Formatting
, andFormatting.tokenize
would then shadow the user's own function, making it cumbersome if the latter was recursive. This does not affect theAnsifmt
prelude -format
stays available.
0.1.1
Features
- Added
print_formatted
and theIO
submodule.
0.1.0
First pre-release.
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>
On This Page