Skip to content

Markdown viewer: support <picture>/<source> for theme-aware images #13736

Open

Description

@fbartho

Pre-submit Checks

Describe the solution you'd like?

Warp's Markdown Viewer should render <picture>/<source media="(prefers-color-scheme: …)"> blocks, swapping between the light- and dark-mode image variant based on the current theme, falling back to the <img> inside <picture> when no <source> matches. This is the standard pattern for README badges and logos that need to stay legible in both light and dark rendering contexts.

Expected behavior: renders a single image that swaps between the light-mode and dark-mode <source> asset based on the active theme, falling back to the <img> if no source matches.

Is your feature request related to a problem? Please describe.

Any README with a logo or badge that needs to look right against both a light and dark background uses this pattern — it's effectively the only portable way to do theme-aware images in Markdown/HTML.

Concretely, today in Warp's Markdown Viewer (verified on this build):

Screenshot demonstrating picture/source rendering as raw code

The whole <picture> block, including the fallback <img>, renders as literal text — the fallback img is not implemented yet, see: #13721

Additional context

Test case:

# `<picture>`/`<source>` (light/dark variants)

Should render: a single image that swaps automatically between a light-mode and dark-mode asset based on the current theme. Currently: expect the raw tags to render as literal text, or — if the fallback `<img>` is what survives — a single static image with no theme-reactive swapping.

<picture>
  <source media="(prefers-color-scheme: dark)" srcset="https://placehold.co/400x200/111827/FFFFFF/png?text=Dark+Mode">
  <source media="(prefers-color-scheme: light)" srcset="https://placehold.co/400x200/FFFFFF/111827/png?text=Light+Mode">
  <img src="https://placehold.co/400x200/FFFFFF/111827/png?text=Fallback" alt="Theme-aware logo">
</picture>

Code pointers. As far as I can tell, this needs both parser work and image-model work, not just a new tag handler:

Related:

Operating system (OS)

macOS

How important is this feature to you?

3

Warp Internal (ignore) - linear-label:39cc6478-1249-4ee7-950b-c428edfeecd1

No response

Activity

  1. added
    enhancement
    on Jul 14, 2026
  2. warp-for-oss commented on Jul 14, 2026

    @warp-for-oss
    Contributor

    @fbartho

    Here's what I found while triaging this issue:

    Thanks — this looks like a real Markdown Viewer feature gap. The provided <picture>/<source> test case is specific enough to route as a theme-aware image rendering enhancement, and it appears related to but distinct from the broader raw-HTML subset work in #13652.

    Maintainer details

    I concluded that markdown Viewer currently lacks support for theme-aware <picture>/<source> image selection and falls back to rendering that raw HTML pattern as text..

    Triage summary

    This is an actionable Markdown Viewer feature request for theme-aware raw-HTML images: <picture> with <source media="(prefers-color-scheme: ...)" srcset=...> should render as one image selected from the active theme, with the nested <img> as fallback.

    Evidence

    • The issue provides a minimal Markdown repro using light/dark <source> entries plus a fallback <img>.
    • Current Markdown parsing supports Markdown image syntax (![alt](src)) as FormattedTextLine::Image, but raw HTML blocks in Markdown documents are not parsed into image blocks.
    • The HTML parser used for pasted HTML handles a limited subset of tags and does not special-case picture, source, srcset, or img into FormattedImage.
    • The editor model currently represents images as a single source (FormattedImage.source, BufferBlockItem::Image.source, and BlockItem::Image.asset_source), so implementing this fully likely needs both parser support and a theme-aware candidate-selection model.

    Likely code areas

    • crates/markdown_parser/src/markdown_parser.rs for Markdown document parsing and block image parsing.
    • crates/markdown_parser/src/html_parser.rs if raw HTML support is shared with pasted HTML or extended for HTML image tags.
    • crates/editor/src/content/core.rs, crates/editor/src/content/text.rs, and crates/editor/src/content/edit.rs for converting parsed images into editor block items and layout tasks.
    • crates/editor/src/render/model/mod.rs and crates/editor/src/render/element/image.rs for image block layout/rendering, currently based on one resolved AssetSource.

    Duplicate check

    No duplicate label recommended. #13652 is a recently closed broader raw-HTML-subset request that this issue explicitly says was split out, while open related issues such as raw <img> sizing, raw tables, anchors, HTML preview, and SVG/image viewer support cover adjacent but distinct capabilities.

    This is my automated analysis and may be incorrect. A maintainer will verify the details.

    Powered by Oz

  3. added
    area:editor-notebooks
    repro:high
    triaged
    on Jul 14, 2026
  4. added
    ready-to-spec
    on Jul 17, 2026
  5. warp-for-oss commented on Jul 17, 2026

    @warp-for-oss
    Contributor

    This issue has been labeled ready-to-spec and is open for contributions in the form of a product or technical spec. If you'd like to draft one, feel free to open a pull request with the spec under specs/. You can also comment @oz-agent on this issue to have the bot draft the spec automatically.

  6. bnavetta commented on Jul 17, 2026

    @bnavetta
    Contributor

    I think this is reasonable to support, but would need further specification - for example, the approach for parsing media queries in the <source> elements. We're unlikely to support the full set of media queries/attributes, so I'd like to be explicit about what's in-scope.

  7. removed their assignment
    on Jul 17, 2026
  8. fbartho commented on Jul 17, 2026

    @fbartho
    ContributorAuthor

    Spec development Blocked by #13721 as the picture spec would incorporate the img spec/feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:editor-notebooksenhancementready-to-specrepro:hightriagedwarp:auto-triage-review

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions