This is a breaking change for users who developed renderer overrides, but also reasonably trivial to adjust to.
Reducing the formatter type zoo
0.x versions had a whole range of public types, more or less one for each existing renderer: ASTFormatter, HTMLFormatter, XHTMLFormatter, FOFormatter. However many of these types only differ in their implementation details, not in the public API they offer, so there was an opportunity to unify those.
This PR reduces the public API to two abstract types: Formatter and TagFormatter. The latter is the type to use for everything with angle brackets (which is most formats in Laika), and the former is the more minimal base type for other character output.
Simplified formatter method signatures
Previously the APIs asked you to pass the options and the child elements separately, resulting in render overrides like this:
case (fmt, Emphasized(content, options)) => fmt.element("em", options, content)
This has been simplified to just pass the element container itself and let the formatter pick both options and content from this one instance.
case (fmt, e: Emphasized) => fmt.element("em", e)
In the rare cases where options and content come from different nodes, they can be modified on either side with withContent or withOptions. This makes the most common cases less verbose while making the edge cases slightly more verbose.
This is a breaking change for users who developed renderer overrides, but also reasonably trivial to adjust to.
Reducing the formatter type zoo
0.x versions had a whole range of public types, more or less one for each existing renderer:
ASTFormatter
,HTMLFormatter
,XHTMLFormatter
,FOFormatter
. However many of these types only differ in their implementation details, not in the public API they offer, so there was an opportunity to unify those.This PR reduces the public API to two abstract types:
Formatter
andTagFormatter
. The latter is the type to use for everything with angle brackets (which is most formats in Laika), and the former is the more minimal base type for other character output.Simplified formatter method signatures
Previously the APIs asked you to pass the options and the child elements separately, resulting in render overrides like this:
This has been simplified to just pass the element container itself and let the formatter pick both options and content from this one instance.
In the rare cases where options and content come from different nodes, they can be modified on either side with
withContent
orwithOptions
. This makes the most common cases less verbose while making the edge cases slightly more verbose.