Skip to content

0.3.0: Better nested bold/italics parsing

Choose a tag to compare

@ariabuckles ariabuckles released this 03 Sep 03:11
· 144 commits to master since this release

Make rules at the same order compete with each other

This solves the em/strong interaction problem in a more general way,
allowing us to have, in general, rules that have the same tokens, and
have their precedence resolved by match quality (here longest match),
instead of requiring a forced precedence between them.

This change adds one new method to the rule API: quality.

If present, quality must be a function that returns a number, indicating
the quality of the match/capture. This is used by bold/italics/u to
decide between which rule should capture a string that matches multiple
rules. If multuple rules are at the same order and have quality
functions, whichever rule's quality function returns the higher number
will win the match. If there are also rules at the same order without a
quality function, they will only win the match if none of the rule with
quality functions match.