Skip to content

[controversial] Breaking API proposal #1352

@jonasfj

Description

@jonasfj

In dart-archive/markdown#585 I and later @srawlins sort of agreed that exposing *Syntax objects is probably a bad idea. We could document that, so consumers don't have to come to the same realization, or we could change the public API.

This is a controversial proposal, feel free to shoot it down and close the issue.
It's certainly possible that some users might be hard to migrate.

Proposed public API

  • Export a List<Node> markdown(String text, {options...}) function
    • Options consist of booleans and Resolver.
    • Options can only enable/disable features.
    • Users cannot inject a custom parser or custom syntax into the mix.
  • Mark everything with @Deprecated('Use the markdown() function')
    • Except Node, Element, Text and Resolver.
    • Add an extension RenderHtml on List<Node> { String renderHtml(options...) {...} }

Next major version break

  • Stop exporting all the deprecated things
  • Annotate Node with sealed class
  • Annotate Text and Element with final class

This would prevent users from trying to make custom *Syntax classes, reorder Syntax classes, and get all sorts of weird behavior.

It would also allow us to refactor the implementation and add new features without breaking existing users.
Maybe, we keep all the internals as they are, but exposing them to the public seems a bit scary.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions