Skip to content

[JEWEL-1267] Support sized images#3442

Draft
AlexVanGogen wants to merge 1 commit intoJetBrains:masterfrom
AlexVanGogen:alexvangogen/JEWEL-1267-sized-images
Draft

[JEWEL-1267] Support sized images#3442
AlexVanGogen wants to merge 1 commit intoJetBrains:masterfrom
AlexVanGogen:alexvangogen/JEWEL-1267-sized-images

Conversation

@AlexVanGogen
Copy link
Contributor

@AlexVanGogen AlexVanGogen commented Feb 27, 2026

Summary

Add support for parsing and rendering sized images in Jewel Markdown when image dimensions are provided via HTML width and height attributes or native Markdown image attribute blocks ({width=100 height=50%}), including both absolute pixel values and percentage-based dimensions with proportional scaling when only one dimension is specified.

Fixes JEWEL-1267

Changes

  • New DimensionSize sealed interface with Pixels and Percent value classes to represent image dimension specifications
  • Extended InlineMarkdown.Image with optional width and height properties
  • Added parsing of Markdown image attribute blocks: ![alt](url){width=100 height=50%} — supports unquoted, single-quoted, and double-quoted attribute values, with px and % suffixes
  • Added parseHtmlSizeValue() for parsing HTML size attributes (e.g., "100", "100px", "50%") into DimensionSize values, with negative percentage values treated as invalid
  • Refactored Coil3ImageRendererExtensionImpl to compute placeholder sizes based on specified dimensions — when both are given they're used directly, when only one is specified the other scales proportionally, and when none are specified the original image size is used
  • Updated api-dump-experimental.txt with new DimensionSize API entries
  • Added comprehensive unit tests:
    • 10 tests for Markdown image attribute block parsing
    • 12 tests for Compose image rendering with dimensions
    • Extended HTML converter tests for <img> tag parsing

Screenshots

HTML

Percentage and pixel dimensions (50%, 540px/304px)

one

Mixed dimension combinations (pixel+percentage, percentage+pixel)

one-27 at 12 19 37

Markdown

Original images

Screenshot 2026-03-10 at 20 02 46

Using sized width/height

Screenshot 2026-03-10 at 20 03 16

Release notes

New features

  • Added support for sized images in Markdown rendering — HTML <img> tags with width and height attributes and native Markdown image attribute blocks ({width=100 height=50%}) are now parsed and rendered at the specified dimensions, with proportional scaling when only one dimension is provided ([JEWEL-1267] Support sized images #3442)

@AlexVanGogen
Copy link
Contributor Author

Created using a skill from here :P

(except for images, those had to be added manually)

@AlexVanGogen AlexVanGogen force-pushed the alexvangogen/JEWEL-1267-sized-images branch from e35cc42 to 3544efb Compare February 27, 2026 16:59
@AlexVanGogen AlexVanGogen self-assigned this Mar 10, 2026
@AlexVanGogen AlexVanGogen marked this pull request as draft March 10, 2026 10:13
@AlexVanGogen
Copy link
Contributor Author

TIL some preview providers also support given width and height: https://about.gitlab.com/releases/2022/12/22/gitlab-15-7-released/#change-the-dimensions-of-images-in-markdown

Even though GitHub doesn't do it by default, we could do it almost for free (all that's required to add is a simple regex matcher on the text literal appended to the native image). So I'd put this PR on hold until this functionality is supported.

@AlexVanGogen AlexVanGogen force-pushed the alexvangogen/JEWEL-1267-sized-images branch from 3544efb to b5d15cb Compare March 10, 2026 15:59
Added support for parsing and rendering sized images in Jewel Markdown
when image dimensions are provided via HTML `width` and `height` attributes
or adjacent markdown image attribute blocks. Supported values include
unitless pixel sizes, explicit `px` sizes, and percentage-based dimensions;
invalid or negative sizes are ignored, with proportional scaling used when
only one dimension is specified.
@AlexVanGogen AlexVanGogen force-pushed the alexvangogen/JEWEL-1267-sized-images branch from b5d15cb to ff52578 Compare March 10, 2026 19:13
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