Skip to content

Commit

Permalink
Fixed a bug where unwanted m characters would appear in the output …
Browse files Browse the repository at this point in the history
…before every colored token
  • Loading branch information
qexat committed Jan 5, 2025
1 parent ea2f673 commit 37457b2
Showing 4 changed files with 11 additions and 6 deletions.
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 0.1.3

## Fixes

- Fixed a bug where unwanted `m` characters would appear in the output before every colored token

# 0.1.2

## Fixes
2 changes: 1 addition & 1 deletion ansifmt.opam
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file is generated by dune, edit dune-project instead
opam-version: "2.0"
version: "0.1.2"
version: "0.1.3"
synopsis: "A simple, lightweight library for ANSI formatting"
description:
"A simple, lightweight library for ANSI formatting with powerful features such as a tokenization-based system for pretty-printing code in the terminal."
2 changes: 1 addition & 1 deletion dune-project
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@

(name ansifmt)

(version 0.1.2)
(version 0.1.3)

(generate_opam_files true)

7 changes: 3 additions & 4 deletions lib/Color.ml
Original file line number Diff line number Diff line change
@@ -266,12 +266,11 @@ let make_rgb_exn (red : int) (green : int) (blue : int) : t =
embedded in a string based on the [color]. *)
let to_ansi ~(ground : Ground.t) : t -> string = function
| Minimal { color; bright } ->
Printf.sprintf "%d%dm" (Ground.to_int ~bright ground) (Minimal.to_int color)
| Advanced color ->
Printf.sprintf "%d8;5;%dm" (Ground.to_int ground) (Int8.to_int color)
Printf.sprintf "%d%d" (Ground.to_int ~bright ground) (Minimal.to_int color)
| Advanced color -> Printf.sprintf "%d8;5;%d" (Ground.to_int ground) (Int8.to_int color)
| Rgb (r, g, b) ->
Printf.sprintf
"%d8;2;%d;%d;%dm"
"%d8;2;%d;%d;%d"
(Ground.to_int ground)
(Int8.to_int r)
(Int8.to_int g)

0 comments on commit 37457b2

Please sign in to comment.