diff --git a/src/formatters/ansi.cr b/src/formatters/ansi.cr index ba8b740..16d9e79 100644 --- a/src/formatters/ansi.cr +++ b/src/formatters/ansi.cr @@ -26,7 +26,7 @@ module Tartrazine }] end colorized = text.colorize - s.color.try { |c| colorized = colorized.fore(c.colorize) } + s.color.try { |col| colorized = colorized.fore(col.colorize) } # Intentionally not setting background color colorized.mode(:bold) if s.bold colorized.mode(:italic) if s.italic diff --git a/src/formatters/html.cr b/src/formatters/html.cr index 3f3510e..e978649 100644 --- a/src/formatters/html.cr +++ b/src/formatters/html.cr @@ -5,8 +5,8 @@ module Tartrazine # Not all of these options are implemented property? standalone : Bool = false + property class_prefix : String = "" - # property class_prefix : String = "" # property with_classes : Bool = true # property tab_width = 8 # property surrounding_pre : Bool = true @@ -76,13 +76,13 @@ module Tartrazine # Given a token type, return the CSS class to use. def get_css_class(token, theme) - return Abbreviations[token] if theme.styles.has_key?(token) + return class_prefix + Abbreviations[token] if theme.styles.has_key?(token) # Themes don't contain information for each specific # token type. However, they may contain information # for a parent style. Worst case, we go to the root # (Background) style. - Abbreviations[theme.style_parents(token).reverse.find { |parent| + class_prefix + Abbreviations[theme.style_parents(token).reverse.find { |parent| theme.styles.has_key?(parent) }] end diff --git a/src/main.cr b/src/main.cr index 9fd7c5d..ab27cfd 100644 --- a/src/main.cr +++ b/src/main.cr @@ -4,4 +4,5 @@ lexer = Tartrazine.lexer("crystal") theme = Tartrazine.theme(ARGV[1]) formatter = Tartrazine::Html.new formatter.standalone = true +formatter.class_prefix = "tartrazine-" puts formatter.format(File.read(ARGV[0]), lexer, theme)