Skip to content

[JEWEL-1267] Support sized images#3442

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

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

Conversation

@AlexVanGogen
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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 2 times, most recently from b5d15cb to ff52578 Compare March 10, 2026 19:13
@AlexVanGogen AlexVanGogen marked this pull request as ready for review March 25, 2026 18:36
Copy link
Copy Markdown
Collaborator

@DanielSouzaBertoldi DanielSouzaBertoldi left a comment

Choose a reason for hiding this comment

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

No major blocks, this is pretty cool stuff, congrats!

@AlexVanGogen AlexVanGogen force-pushed the alexvangogen/JEWEL-1267-sized-images branch from ff52578 to 27f0b36 Compare April 8, 2026 15:21
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 27f0b36 to cd91003 Compare April 8, 2026 15:28
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