Fix heading auto-link hijacking nested link labels (#668)

This commit is contained in:
dualfroz committed 2026-09-04 03:24:13 +02:00
1 parent 10ebd55fd4
commit cf9456728c
4 files changed
+74

No files matched your search

@@ -136,6 +136,21 @@ public class LinkReferenceDefinition : LeafBlock
/// </remarks>
public CreateLinkInlineDelegate? CreateLinkInline { get; set; }
/// <summary>
/// Gets a value indicating whether this reference definition is allowed to resolve into a link when its
/// label is nested inside another link or image bracket that is still open (and may still become a valid
/// link/image once fully parsed).
/// </summary>
/// <remarks>
/// This is <c>true</c> for regular, user-authored reference definitions so that CommonMark's "links cannot
/// contain links" resolution order is preserved. Implicitly generated reference definitions (e.g. the
/// automatic heading anchors created by the auto-identifier extension) override this to <c>false</c> so
/// they don't silently hijack a bracket pair that is part of a larger, still-open link label, such as
/// <c>[Some text [HeadingText]](https://example.com)</c> (see
/// https://github.com/xoofx/markdig/issues/668).
/// </remarks>
internal virtual bool AllowResolutionInsideOpenLink => true;
/// <summary>
/// Tries to the parse the specified text into a definition.
/// </summary>