[JEWEL-1267] Support sized images#3442
Draft
AlexVanGogen wants to merge 1 commit intoJetBrains:masterfrom
Draft
Conversation
Contributor
Author
|
Created using a skill from here :P (except for images, those had to be added manually) |
e35cc42 to
3544efb
Compare
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. |
3544efb to
b5d15cb
Compare
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.
b5d15cb to
ff52578
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add support for parsing and rendering sized images in Jewel Markdown when image dimensions are provided via HTML
widthandheightattributes 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
DimensionSizesealed interface withPixelsandPercentvalue classes to represent image dimension specificationsInlineMarkdown.Imagewith optionalwidthandheightproperties{width=100 height=50%}— supports unquoted, single-quoted, and double-quoted attribute values, withpxand%suffixesparseHtmlSizeValue()for parsing HTML size attributes (e.g.,"100","100px","50%") intoDimensionSizevalues, with negative percentage values treated as invalidCoil3ImageRendererExtensionImplto 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 usedapi-dump-experimental.txtwith newDimensionSizeAPI entries<img>tag parsingScreenshots
HTML
Percentage and pixel dimensions (50%, 540px/304px)
Mixed dimension combinations (pixel+percentage, percentage+pixel)
Markdown
Original images
Using sized width/height
Release notes
New features
<img>tags withwidthandheightattributes 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)