Skip to content

fix(android): keep the inline code style inside headings and list items - #938

Merged
jnowakow merged 3 commits into
software-mansion:mainfrom
jo-a-n:fix/android-heading-inline-code
Oct 12, 2026
Merged

jnowakow merged 3 commits into
software-mansion:mainfrom
jo-a-n:fix/android-heading-inline-code

Conversation

@jo-a-n

@jo-a-n jo-a-n commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

What/Why

Fixes #937. On Android, inline code inside a heading or a list item renders in the block's font and size instead of the code style. HeadingRenderer and ListItemRenderer set their spans after the children at default priority, so Android applies them after CodeSpan and overwrites it.

  • Headings: HeadingSpan now has top priority, as SPAN_FLAGS_CONTAINER_BACKGROUND gives blockquotes.
  • List items: a new SPAN_FLAGS_LIST_ITEM gives list spans a priority just above the default. Top priority would not work, because list spans draw a leading margin and a blockquote would then draw its bar after a list's.
  • Task toggles: a checkbox tap re-sets the task span with its original flags, so it keeps that priority.

The heading and list changes go into both react-native-enriched-markdown and the standalone enriched-markdown-android. The standalone toggle already keeps the span's flags.

Testing

We ship these changes as a patch on 1.0.2, whose renderer files match main. On a Pixel 8 emulator (Android 17), inline code renders in the code font in an h4, a bullet, a nested bullet, a numbered item, a task item, a list inside a quote and a quote inside a list. Bullets, numbers, checkboxes and quote bars sit where they did before.

We also ran this repo's example app and Android E2E suite (see the checklist). We have not run the standalone package or the checkbox-toggle change (our app turns task toggling off).

PR Checklist

  • Code compiles and runs on iOS: not applicable, Android-only change.
  • Code compiles and runs on Android
  • Updated documentation/README if applicable: not applicable, no API change.
  • Ran example app to verify changes
  • E2E tests are passing: 70 passed
  • Required E2E tests have been added (if applicable): the two list_code_block_*_combo_display baselines need regenerating in your environment. Screenshots from our machine would carry its rendering differences.

jo-a-n added 2 commits October 6, 2026 18:54
- Set HeadingSpan at top span priority, so Android applies it before the inline spans inside the heading and CodeSpan's font, size and color win
- Apply the same change to the standalone enriched-markdown-android renderer
- Add SPAN_FLAGS_LIST_ITEM, a span priority just above the default and below SPAN_FLAGS_CONTAINER_BACKGROUND
- Set list item spans with it, so Android applies them before the inline spans inside the item, while a blockquote still draws its leading margin before a list's
- Apply the same change to the standalone enriched-markdown-android renderer
@jo-a-n jo-a-n changed the title fix(android): keep the inline code style inside headings fix(android): keep the inline code style inside headings and list items Oct 6, 2026
- Re-set the toggled TaskListSpan with the old span's flags instead of SPAN_FLAGS_EXCLUSIVE_EXCLUSIVE, so it keeps SPAN_FLAGS_LIST_ITEM's priority after a checkbox tap

@jnowakow jnowakow left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good, I've found one little thing that could be improved. Thanks for opening the PR!

start,
end,
SPAN_FLAGS_EXCLUSIVE_EXCLUSIVE,
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE or Spanned.SPAN_PRIORITY,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have SPAN_FLAGS_CONTAINER_BACKGROUND constant that is equal to Spanned.SPAN_EXCLUSIVE_EXCLUSIVE or Spanned.SPAN_PRIORITY. Could you rename it something more generic like SPAN_FLAGS_EXCULSIVE_EXCLUSIVE_PRIORITY and reuse it here?

start,
end,
SPAN_FLAGS_EXCLUSIVE_EXCLUSIVE,
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE or Spanned.SPAN_PRIORITY,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

@jnowakow

Copy link
Copy Markdown
Collaborator

I'm merging the PR and I'll open follow-up to fix the nitpicks. @jo-a-n , thanks for contributing!

@jnowakow
jnowakow merged commit 5cc5f96 into software-mansion:main Oct 12, 2026
14 checks passed
jnowakow added a commit that referenced this pull request Oct 12, 2026
#938 gives list item spans a priority above the default, so token spans
set inside a list item apply after it and keep their color without being
re-set.
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.

[Android] Inline code inside a heading renders in the heading font, not the code font

2 participants