-
-
Notifications
You must be signed in to change notification settings - Fork 61
Fix markdown display within []
#493
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes a bug where markdown formatting (such as bold **text**) inside square brackets was not being rendered correctly when there was no corresponding reference definition. The fix changes the behavior to recursively process the markdown content within brackets rather than treating it as plain text.
Key changes:
- Modified
appendMarkdownReferencefunction to recursively parse markdown within unresolved reference links - Changed from rendering unresolved references as plain text to processing their individual components (LINK_TEXT and LINK_LABEL)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| val linkText = node.findChildOfType(MarkdownElementTypes.LINK_TEXT) | ||
| if (linkText != null) { | ||
| buildMarkdownAnnotatedString(content, linkText, annotatorSettings) |
Copilot
AI
Jan 6, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable shadowing: The variable name linkText is already used in this function scope (line 167). Consider using a different name like linkTextNode to avoid confusion and improve code clarity. The shadowed variable has type List<ASTNode>? while this new variable has type ASTNode?, which makes the distinction even more important.
| val linkText = node.findChildOfType(MarkdownElementTypes.LINK_TEXT) | |
| if (linkText != null) { | |
| buildMarkdownAnnotatedString(content, linkText, annotatorSettings) | |
| val linkTextNode = node.findChildOfType(MarkdownElementTypes.LINK_TEXT) | |
| if (linkTextNode != null) { | |
| buildMarkdownAnnotatedString(content, linkTextNode, annotatorSettings) |
| // if no reference is found, reference links are rendered as their individual components | ||
| val linkText = node.findChildOfType(MarkdownElementTypes.LINK_TEXT) | ||
| if (linkText != null) { | ||
| buildMarkdownAnnotatedString(content, linkText, annotatorSettings) | ||
| } | ||
| buildMarkdownAnnotatedString(content, labelNode, annotatorSettings) |
Copilot
AI
Jan 6, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new behavior for rendering markdown inside brackets when no reference is found lacks test coverage. Consider adding a test case in sample/android/src/screenshotTest/kotlin/com/mikepenz/markdown/ui/m3/LinkTests.kt (and the m2 equivalent) that includes examples like [**bold text**] or [*italic*] to verify the fix works as intended and prevent future regressions.
Description
Fix markdown display within
[]Fixes # (issue)
Type of change
Please delete options that are not relevant.