From 29ea9471381a92eb371d3e4ec14f855b024fa1f1 Mon Sep 17 00:00:00 2001 From: Skyler Date: Wed, 8 Apr 2026 16:34:20 -0400 Subject: [PATCH] Fix visitListItem not being called by MarkupVisitor protocol dispatch The existing `visitListItem(_:orderedIndex:)` method has a second defaulted parameter, which means it does not satisfy the `MarkupVisitor` protocol requirement `visitListItem(_:)`. Swift resolves the protocol dispatch to the default extension implementation (which calls `defaultVisit`) instead of this type's method, so list item prefixes (bullets, numbers) are never inserted and newlines between items are lost. Add a one-parameter overload that matches the protocol signature and delegates to the two-parameter version. Co-Authored-By: Claude Opus 4.6 (1M context) --- .../AttributedStringVisitor.swift | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Sources/MarkdownToAttributedString/AttributedStringVisitor.swift b/Sources/MarkdownToAttributedString/AttributedStringVisitor.swift index 5993bc9..2b9773f 100644 --- a/Sources/MarkdownToAttributedString/AttributedStringVisitor.swift +++ b/Sources/MarkdownToAttributedString/AttributedStringVisitor.swift @@ -306,6 +306,13 @@ struct AttributedStringVisitor: MarkupVisitor { } + // Satisfies the single-parameter MarkupVisitor protocol requirement so that + // protocol dispatch (e.g. markup.accept(&self)) resolves to this type's + // implementation rather than the default provided by the protocol extension. + mutating func visitListItem(_ listItem: ListItem) { + visitListItem(listItem, orderedIndex: nil) + } + // orderedIndex is non-nil when part of an ordered list mutating func visitListItem(_ listItem: ListItem, orderedIndex: Int? = nil) { guard optionsSupportEl(.listItem) else {