API changes to make it nicer

These are incompatible, tho.

* Theme is now a property of the formatter instead
  of passing it arounf
* get_style_defs is now style_defs
This commit is contained in:
2024-08-13 10:57:02 -03:00
parent 88f5674917
commit 2e87762f1b
4 changed files with 47 additions and 22 deletions

View File

@ -9,12 +9,15 @@ module Tartrazine
# This is the base class for all formatters.
abstract class Formatter
property name : String = ""
property theme : Theme = Tartrazine.theme("default-dark")
def format(text : String, lexer : Lexer, theme : Theme) : String
# Format the text using the given lexer.
def format(text : String, lexer : Lexer) : String
raise Exception.new("Not implemented")
end
def get_style_defs(theme : Theme) : String
# Return the styles, if the formatter supports it.
def style_defs : String
raise Exception.new("Not implemented")
end
end