@@ -72,6 +72,9 @@ import androidx.compose.ui.text.font.FontFamily
7272import androidx.compose.ui.unit.dp
7373import kotlinx.coroutines.flow.conflate
7474import kotlinx.coroutines.delay
75+import com.mikepenz.markdown.annotator.AnnotatorSettings
76+import com.mikepenz.markdown.annotator.DefaultAnnotatorSettings
77+import com.mikepenz.markdown.annotator.buildMarkdownAnnotatedString
7578import com.mikepenz.markdown.compose.LocalMarkdownAnnotator
7679import com.mikepenz.markdown.compose.LocalMarkdownColors
7780import com.mikepenz.markdown.compose.LocalMarkdownTypography
@@ -80,7 +83,7 @@ import com.mikepenz.markdown.compose.components.markdownComponents
8083import com.mikepenz.markdown.compose.elements.MarkdownText as LibraryMarkdownText
8184import com.mikepenz.markdown.m3.Markdown
8285import com.mikepenz.markdown.model.DefaultMarkdownAnnotator
83−import com.mikepenz.markdown.utils.buildMarkdownAnnotatedString
86+import com.mikepenz.markdown.model.DefaultMarkdownAnnotatorConfig
8487import org.intellij.markdown.MarkdownElementTypes
8588import org.intellij.markdown.ast.ASTNode
8689import org.intellij.markdown.ast.getTextInNode
@@ -217,7 +220,7 @@ private fun MarkdownBody(
217220 // rather than extracted to a helper to keep this file under detekt's TooManyFunctions threshold.
218221 val inlineCodeAnnotator = remember(baseAnnotator, inlineCodeTypography, inlineCodeColors) {
219222 val codeStyle = inlineCodeTypography.inlineCode.copy(
220− color = inlineCodeColors.inlineCodeText,
223+ color = inlineCodeTypography.inlineCode.color,
221224 background = inlineCodeColors.inlineCodeBackground,
222225 ).toSpanStyle()
223226 DefaultMarkdownAnnotator(
@@ -247,6 +250,7 @@ private fun MarkdownBody(
247250 baseAnnotator.annotate?.invoke(this, content, node) ?: false
248251 }
249252 },
253+ config = DefaultMarkdownAnnotatorConfig(),
250254 )
251255 }
252256 // Compose the inline-code tagger with the search-highlight wrapper when a query is active.
@@ -271,6 +275,7 @@ private fun MarkdownBody(
271275 }
272276 handled
273277 },
278+ config = DefaultMarkdownAnnotatorConfig(),
274279 )
275280 }
276281 } else {
@@ -317,12 +322,12 @@ private fun MarkdownBody(
317322 // interrupting on every token; the reader hears the reply grow in measured chunks.
318323 CompositionLocalProvider(
319324 LocalUriHandler provides safeUriHandler,
320− LocalMarkdownAnnotator provides effectiveAnnotator,
321325 ) {
322326 Markdown(
323327 content = renderedContent,
324328 modifier = modifier.semantics { liveRegion = LiveRegionMode.Polite },
325329 components = components,
330+ annotator = effectiveAnnotator,
326331 )
327332 }
328333 // A blinking caret at the end of a streaming reply gives a "live" typewriter feel.
@@ -336,12 +341,12 @@ private fun MarkdownBody(
336341 content = markdown,
337342 modifier = modifier.semantics { liveRegion = LiveRegionMode.Polite },
338343 components = components,
344+ annotator = effectiveAnnotator,
339345 )
340346 }
341347 }
342348 CompositionLocalProvider(
343349 LocalUriHandler provides safeUriHandler,
344− LocalMarkdownAnnotator provides effectiveAnnotator,
345350 ) {
346351 content()
347352 }
@@ -465,12 +470,20 @@ private fun ParagraphWithInlineCodeCopy(model: MarkdownComponentModel) {
465470 val context = LocalContext.current
466471 val haptics = LocalHapticFeedback.current
467472 val style = model.typography.paragraph
468− // buildMarkdownAnnotatedString is @Composable (it reads LocalMarkdownAnnotator to run the
469− // inline-code tagger installed in MarkdownBody), so the annotated string can't be built in
470− // a `remember` block. The library's own MarkdownParagraph does the same.
473+ val typography = LocalMarkdownTypography.current
474+ val annotator = LocalMarkdownAnnotator.current
475+ // buildMarkdownAnnotatedString needs an explicit AnnotatorSettings in 0.43+ (the old
476+ // overload that read LocalMarkdownAnnotator internally was removed). Build one from the
477+ // current composition locals so the inline-code tagger installed in MarkdownBody still
478+ // runs. The library's own MarkdownParagraph does the same.
479+ val settings = DefaultAnnotatorSettings(
480+ linkTextSpanStyle = typography.textLink,
481+ codeSpanStyle = typography.inlineCode.toSpanStyle(),
482+ annotator = annotator,
483+ )
471484 val styledText = buildAnnotatedString {
472485 pushStyle(style.toSpanStyle())
473− buildMarkdownAnnotatedString(model.content, model.node)
486+ buildMarkdownAnnotatedString(model.content, model.node, settings)
474487 pop()
475488 }
476489 // Capture the layout result so a long-press position can be mapped to a character offset,
@@ -478,7 +491,7 @@ private fun ParagraphWithInlineCodeCopy(model: MarkdownComponentModel) {
478491 var layoutResult by remember { mutableStateOf<TextLayoutResult?>(null) }
479492 LibraryMarkdownText(
480493 content = styledText,
481− style = style,
494+ node = model.node,
482495 modifier = Modifier.pointerInput(styledText) {
483496 detectTapGestures(
484497 onLongPress = { pos ->
@@ -493,7 +506,8 @@ private fun ParagraphWithInlineCodeCopy(model: MarkdownComponentModel) {
493506 },
494507 )
495508 },
496− onTextLayout = { layoutResult = it },
509+ style = style,
510+ onTextLayout = { result, _ -> layoutResult = result },
497511 )
498512}
499513