Skip to content

Conversation

@mikepenz
Copy link
Owner

@mikepenz mikepenz commented Jan 6, 2026

Description

Fix markdown display within []

Fixes # (issue)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no API changes)
  • Build configuration change
  • Other (please describe):

Copilot AI review requested due to automatic review settings January 6, 2026 09:35
@mikepenz mikepenz added the fix label Jan 6, 2026
Copy link
Contributor

Copilot AI left a 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 appendMarkdownReference function 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.

Comment on lines +187 to +189
val linkText = node.findChildOfType(MarkdownElementTypes.LINK_TEXT)
if (linkText != null) {
buildMarkdownAnnotatedString(content, linkText, annotatorSettings)
Copy link

Copilot AI Jan 6, 2026

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.

Suggested change
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)

Copilot uses AI. Check for mistakes.
Comment on lines +186 to +191
// 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)
Copy link

Copilot AI Jan 6, 2026

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.

Copilot uses AI. Check for mistakes.
@mikepenz mikepenz merged commit 0aa45e0 into develop Jan 6, 2026
9 checks passed
@mikepenz mikepenz deleted the fix/488 branch January 6, 2026 10:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants