dart-lang / markdown

A Dart markdown library
https://pub.dev/packages/markdown
BSD 3-Clause "New" or "Revised" License
455 stars 200 forks source link

Unused references are rendered, which they probably shouldn't be #546

Open isoos opened 1 year ago

isoos commented 1 year ago

reproduce markdown:

The [`Characters`][Characters] class exposes a string

Example:

```dart
{}

`dart run markdown --extension-set GitHubWeb` renders an extra content at the end:

[ByteBuffer]: https://api.dart.dev/stable/2.0.0/dart-typed_data/ByteBuffer-class.html "ByteBuffer class" [Characters]: https://pub.dev/documentation/characters/latest/characters/Characters-class.html "Characters class"



Removing the unused `ByteBuffer` reference line fixes the rendering.
srawlins commented 1 year ago

This is because there is a tab character between the link destination and the quoted link title. But the spec says:

A link reference definition consists of a link label, optionally preceded by up to three spaces of indentation, followed by a colon (:), optional spaces or tabs (including up to one line ending), a link destination, optional spaces or tabs (including up to one line ending), and an optional link title, which if it is present must be separated from the link destination by spaces or tabs.

So I think we have a bug. Glancing at the impl, it may be that this line does not include $tab:

https://github.com/dart-lang/markdown/blob/bd6ae8d741327e24319f3e036d57107f91229843/lib/src/link_parser.dart#L203