-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Description
Is there an existing issue for this?
- I have searched the existing issues
- I have read the guide to filing a bug
Use case
I tried to add my own custom block element using a blockSyntaxes: const [NoteSyntax()], declaration in the Markdown widget. My NoteSyntax creates an Element('note', children) which then eventually gets passed to the visitor that creates widgets.
I tried to add my own builder using builders: {'note': NoteBuilder()}, in the Markdown widget, but this is never called because MarkdownBuilder.visitElementBefore uses a private function _isBlockTag to determine whether the provided Element is a block element by comparing its tag to a hardcoded list of tags.
Therefore, it incorrectly thinks my Element is an inline element and crashes 1 because _addParentInlineIfNeeded wants add an inline element that requires a tag but the parent of my block node is the document which has no tag.
Proposal
I'd suggest to dispatch the isBlock call to the element itself – or let me extend that list.
Footnotes
-
See line 632 of
builder.dart,style: styleSheet.styles[tag!],. ↩