package ansifmt
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>
On This Page
A simple, lightweight library for ANSI styling
Install
dune-project
Dependency
Authors
Maintainers
Sources
ansifmt-2.0.0.tbz
sha256=7bd5aff4eb547ca9bbc50cda6fa71af016673fbed0b0913b6c7bf5fce4688459
sha512=1042f4d0ae6d02ab90c1034d839f7b6d30980983b6192cb6c4c18dce030312693a82edbc37e5fa70acf4d1713f0875c3e7e2b5ff12fcac5c64737465c5e72def
doc/CHANGES.html
2.0.0
Changes
Fmthas been rewritten from scratch to use my own library calledrich-string. As such, a lot of tests have been dropped as they already exist upstream. The interface is mostly the same, besides the type itself and a few parameters that got renamed.Fmt.print'sendingparameter now takes aFmt.t optioninstead of astring option.
Features
AnsiandColornow implement their own dedicated equality. No need to use the built-in polymorphic equality anymore.
Removed
Fmt's serialization feature is now dependent onrich-string. Since the latter does not provide it yet, serialization was dropped for now.Fmt.showwas also removed. On top of not being provided byrich-stringand being the identity function, it was not all that useful.
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
ansifmtis 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
ColorAPI has been simplified. Colors can now be constructed using built-in integers ; they will be normalized-on-demand.Advancedis now calledBasic.Minimalhas been dropped as it is already covered byBasic, assuming that modern terminal emulators support 8-bit colors. - The
StylingAPI (now calledAnsi) has been tremendously simplified and is now based on a choice type instead of a record type. parse_hexis nowof_hex_repr.- Luminance calculation now linearizes properly the color.
Features
- A new
FmtAPI 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,ColorandFmtobjects are serializable.Ansiobjects are now deserializable.
Removed
- The
FormattingAPI has been fully dropped. We estimate thatansifmtis 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
IOAPI 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
Customtoken type variant which takes a styling, for tokens without particular semantics. - Add
Formatting.Elementthat supersedesFormatting.Tree. - Add
Formatting.Interfaces.TO_ELEMENTinterface which establishes the contract to convert to a formatting element that is used by formatting and printing utilitary functions such asformatandIO.print_formatted. - Expose the
Int8module that is used byColor. - Add
Token.numberto easily construct a number literal token.
Removed
- Remove
Formatting.Tree,Formatting.TOKENIZABLEand its associated functions. UseFormatting.Elementinstead. - Remove the
Preludemodule. It has merged with the coreAnsifmtmodule. - Remove
print_formattedalias from the prelude. The function can still be found asIO.print_formatted. - Remove
make_stylingalias from the prelude. The function can still be found asStyling.create.
Internal
- Renamed
UtilstoInternal. Formattingis now a directory instead of a file containing all its submodules.- Added
List.intersperseandList.singleton(used inFormatting.Element). - Added
Bool.tautology(used inFormatting.Element).
0.2.0
Features
- Add color functions
luminanceandbest_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_hexto parse hexadecimal codes into RGB colors. (by @chshersh in #7)
Breaking Changes
Color.tandColor.Ground.tare now polymorphic variants. (by @chshersh in #5)
Removed
Util.parenthesize_ifwhich is deemed unuseful and is kind of a duplicate ofTree.parenthesize_ifinFormatting.
0.1.3
Fixes
- Fixed a bug where unwanted
mcharacters would appear in the output before every colored token
0.1.2
Fixes
- Moved
Formatting.tokenizeandFormatting.formatto a dedicatedFormatting.Utilsubmodule - it is common for users who wish to implementTOKENIZABLEtoopen Formatting, andFormatting.tokenizewould then shadow the user's own function, making it cumbersome if the latter was recursive. This does not affect theAnsifmtprelude -formatstays available.
0.1.1
Features
- Added
print_formattedand theIOsubmodule.
0.1.0
First pre-release.
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>
On This Page