Overhaul link and emphasis resolution (dart-lang/markdown#345)
* Overhaul link and emphasis resolution
Resolution of complex link and emphasis text follows very specific rules which
were incompatible with the currenty TagState stack. The new algorithms follow
the process outlined in the [CommonMark
spec](https://spec.commonmark.org/0.29/#an-algorithm-for-parsing-nested-emphasis-and-links).
The crux of the issue which required such an overhaul is that the current
TagState stack did not include any ability to wait to parse a tag's inner text
until it was known that a tag could be closed at the current position, then
parse that inner text, then close the tag. This unfortunately requires a
breaking change for downstream packages which subclass TagSyntax.
* BREAKING: TagSyntax constructor no longer takes an `end` parameter. TagSyntax
no longer implements `onMatchEnd`. Instead, TagSyntax implements a method
called 'close' which creates and returns a Node, if a Node can be created and
closed at the current position. If the TagSyntax instance cannot create a
Node at the current position, the method should return `null`. Some TagSyntax
subclasses will unconditionally create a tag in `close`, while others may be
unable to, such as LinkSyntax, if an inline or reference link could not be
resolved.
* Loosely, the stack of TagStates is replaced with a stack of Delimiters and a
tree of parsed HTML nodes.
* Emphasis and strong emphasis, link and image open delimiters are handled with
the "look for link or image" and "process emphasis" algorithms.
* We combine adjacent text in a more intentional way, and likely more efficient
manner.
* The _DelimiterRun class is replaced with three classes: abstract Delimiter
and subclasses SimpleDelimiter, and DelimiterRun.
These changes result in no new spec failures. Emphasis compliance rises from
96% to 99%. Link compliance rises from 90% to 93%. Total CommonMark compliance
rises from 93% to 94%. Total GFM compliance rises from 92% to 93%.
* documentation and simplification
* Fix test
* revert gitignore
* bump to 4.0.0-dev
14 files changed
tree: 6da27aef23a092681ee2f30a1b32d8d6f3fb792c
- pkgs/