typelevel / Laika

Site and E-book Generator and Customizable Text Markup Transformer for sbt, Scala and Scala.js
https://typelevel.org/Laika/
Apache License 2.0
408 stars 44 forks source link

tweak MarkupFormat API to encourage public declarations for top-level parsers #525

Closed jenshalm closed 11 months ago

jenshalm commented 11 months ago

To better support binary compatibility the parser implementations for markup formats (Markdown and reStructuredText) have been made private.

However, ideally there should be a convenient place for parser authors to at least make the top-level parsers available for other users in case they want to freely compose them for other purposes.

This is encouraged by changing MarkupFormat.spanParsers/blockParsers from a simple Seq to MarkupParsers[E]. The trait has only one abstract property (all: Seq[Block/SpanParserBuilder]), but can be used to add properties for individual parsers.

For example, the bullet list parser for Markdown can now be simply accessed via Markdown.blockParsers.bulletList. This convention is not possible when the property is a simple Seq.