Conversation
Benchmark ResultsComparison of Open to see the benchmark resultsNo benchmark changes above ±5%. Generated by phpbench against commit 1a25389 |
|
Pushed a follow-up commit for the benchmark regression the bot flagged ( The scanner walked the destination one character at a time; it now bulk-skips with Measured locally over three alternating runs against
The large set is back at parity. The small one keeps about +2%, which is the fixed cost of parsing a title and an angle-bracket destination on a 7KB fixture with ten links. Behaviour is unchanged: same 339 tests, and the same output on every CommonMark comparison case in the description. |
Closes part of #37 (point 2). Follows up on this comment confirming the behaviour is specified in CommonMark 0.31.2, §6.3 Links and §6.4 Images.
The
(…)part of an inline link or image was consumed as a single opaque string, so a title ended up insidehref/src, an angle-bracket destination kept its brackets, a destination containing a space still produced a link, and entities were escaped twice.What changes
A new
InlineDestination::scan()reads(destination "title")from the raw content and returnsnullwhen it is malformed. BothLinkRuleandImageRuleuse it:"…",'…',(…)), and rendered as atitleattribute onLinkToken/ImageToken;<…>destinations are unwrapped, which is how a destination containing spaces is written;[x](a b).Balanced parentheses and backslash escapes keep working as they did since #25.
[x](/a "Title")<a href="/a "Title"">x</a><a href="/a" title="Title">x</a>[x](a b)<a href="a b">x</a>[x](a b)[x](</my uri>)<a href="</my uri>">x</a><a href="/my uri">x</a><img src="/a "Title"" alt="alt"><img src="/a" alt="alt" title="Title">[x](/a&b)<a href="/a&amp;b">x</a><a href="/a&b">x</a>ImageSourceWasMissingandImageSourceWasNotClosedstill fire for![alt]and forishref="/my%20uri"there andhref="/my uri"here. That touches every destination with a non-ASCII or reserved character, so it deserves its own PR rather than riding along with the parsing fix. Happy to do it next if you want it.Escaping in the surrounding text.
[x](/a "unclosed)degrades to literal text correctly, but the"is not escaped to"— that is point 3 of #37 and needs the text-token work, not this.composer test(339 tests),lintandanalyseare clean.