Skip to content

Commit 29ea947

Browse files
SkylerSeaclaude
andcommitted
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) <noreply@anthropic.com>
1 parent 5996fba commit 29ea947

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

Sources/MarkdownToAttributedString/AttributedStringVisitor.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,13 @@ struct AttributedStringVisitor: MarkupVisitor {
306306
}
307307

308308

309+
// Satisfies the single-parameter MarkupVisitor protocol requirement so that
310+
// protocol dispatch (e.g. markup.accept(&self)) resolves to this type's
311+
// implementation rather than the default provided by the protocol extension.
312+
mutating func visitListItem(_ listItem: ListItem) {
313+
visitListItem(listItem, orderedIndex: nil)
314+
}
315+
309316
// orderedIndex is non-nil when part of an ordered list
310317
mutating func visitListItem(_ listItem: ListItem, orderedIndex: Int? = nil) {
311318
guard optionsSupportEl(.listItem) else {

0 commit comments

Comments
 (0)