Use IO for output

This commit is contained in:
2024-08-16 17:25:33 -03:00
parent ae03e4612e
commit bb952a44b8
4 changed files with 34 additions and 58 deletions

View File

@@ -4,8 +4,9 @@ module Tartrazine
class Json < Formatter
property name = "json"
def format(text : String, lexer : Lexer, _theme : Theme) : String
lexer.tokenize(text).to_json
def format(text : String, lexer : Lexer, outp : IO) : Nil
tokenizer = Tokenizer.new(lexer, text)
outp << Tartrazine::Lexer.collapse_tokens(tokenizer.to_a).to_json
end
end
end