Skip to content

Fix visitListItem not being called by MarkupVisitor protocol dispatch#4

Open
SkylerSea wants to merge 1 commit intomadebywindmill:mainfrom
SkylerSea:fix/visitListItem-protocol-dispatch
Open

Fix visitListItem not being called by MarkupVisitor protocol dispatch#4
SkylerSea wants to merge 1 commit intomadebywindmill:mainfrom
SkylerSea:fix/visitListItem-protocol-dispatch

Conversation

@SkylerSea
Copy link
Copy Markdown

Summary

  • visitListItem(_:orderedIndex:) has a second defaulted parameter which prevents it from satisfying the MarkupVisitor protocol requirement visitListItem(_:). Swift resolves protocol dispatch (markup.accept(&self)) to the default extension implementation (which calls defaultVisit), so list item prefixes (bullets/numbers) are never inserted and newlines between items are lost.
  • Adds a one-parameter overload that matches the protocol signature and delegates to the two-parameter version.

Repro

let result = AttributedStringFormatter.format(markdown: "- Item one\n- Item two")
print(result.string) // "Item oneItem two\n" — no bullets, items concatenated

After fix

print(result.string) // "\t• Item one\n\t• Item two\n"

All existing tests pass (they were previously crashing/failing on list-related assertions).

🤖 Generated with Claude Code

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant