From b43501da98548ac831ead7c6eaa16e2fa10c5524 Mon Sep 17 00:00:00 2001 From: Roberto Alsina Date: Wed, 7 Aug 2024 20:47:02 -0300 Subject: [PATCH] Nicer ansi rendering --- src/actions.cr | 1 + src/formatter.cr | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/actions.cr b/src/actions.cr index 95cddcd..f35f225 100644 --- a/src/actions.cr +++ b/src/actions.cr @@ -4,6 +4,7 @@ require "./formatter" require "./rules" require "./styles" require "./tartrazine" + # These are Lexer actions. When a rule matches, it will # perform a list of actions. These actions can emit tokens # or change the state machine. diff --git a/src/formatter.cr b/src/formatter.cr index d772f77..2cb168c 100644 --- a/src/formatter.cr +++ b/src/formatter.cr @@ -44,7 +44,12 @@ module Tartrazine theme.styles.has_key?(parent) }] end - text.colorize(*rgb(s.color)).back(*rgb(s.background)).to_s + colorized = text.colorize(*rgb(s.color)) + # Intentionally not setting background color + colorized.mode(:bold) if s.bold + colorized.mode(:italic) if s.italic + colorized.mode(:underline) if s.underline + colorized.to_s end def rgb(c : String?)