fix: Bug in high-level API for png formatter

This commit is contained in:
Roberto Alsina 2024-09-21 21:07:44 -03:00
parent 3bf8172b89
commit 8b34a1659d

View File

@ -1,16 +1,20 @@
require "../formatter" require "../formatter"
require "compress/gzip"
require "digest/sha1"
require "stumpy_png" require "stumpy_png"
require "stumpy_utils" require "stumpy_utils"
require "compress/gzip"
module Tartrazine module Tartrazine
def self.to_png(text : String, language : String, def self.to_png(text : String, language : String,
theme : String = "default-dark", theme : String = "default-dark",
line_numbers : Bool = false) : String line_numbers : Bool = false) : String
buf = IO::Memory.new
Tartrazine::Png.new( Tartrazine::Png.new(
theme: Tartrazine.theme(theme), theme: Tartrazine.theme(theme),
line_numbers: line_numbers line_numbers: line_numbers
).format(text, Tartrazine.lexer(name: language)) ).format(text, Tartrazine.lexer(name: language), buf)
buf.to_s
end end
class FontFiles class FontFiles