Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Oct 8, 2025

Fixes the inline image sizing syntax to make the space before = optional when there's no title, but required when a title is present. This provides better clarity in the syntax.

Problem

The image resize parameter required a whitespace before the = sign to work correctly:

<!-- This didn't work -->
![Manage this data view option](../images/manage-this-data-view.png "=50%")

<!-- This worked -->
![Manage this data view option](../images/manage-this-data-view.png " =50%")

This was unintuitive and caused confusion, as documented in #2014 (comment).

Solution

Updated the regex pattern in LinkRegexExtensions.MatchTitleStylingInstructions() from \s\= to (?:^|\s)\=, implementing nuanced behavior:

  • When no title is present: Space before = is optional
  • When a title is present: Space before = is required (for clarity)

What Now Works

![alt](img.png "=50%")              <!-- No title, no space needed ✅ -->
![alt](img.png " =50%")             <!-- No title, with space ✅ -->
![alt](img.png "My Title =50%")    <!-- With title, space required ✅ -->
![alt](img.png "=250x330")         <!-- Pixel sizing ✅ -->
![alt](img.png "=250")             <!-- Width only ✅ -->

What Does Not Work

![alt](img.png "My Title=50%")     <!-- With title, no space ❌ -->

When a title is present, the space before = is required to clearly separate the title from the sizing parameters.

Changes

  • Code: Updated regex pattern in DiagnosticLinkInlineParser.cs and added .TrimEnd() for proper title extraction
  • Tests: Added comprehensive test cases covering the syntax variations (removed test for title without space as it's no longer supported)
  • Documentation: Updated docs/syntax/images.md to clarify when space is required vs optional

This change maintains backwards compatibility for all previously working syntax while preventing the ambiguous "My Title=50%" format.

Fixes #2016

Original prompt

This section details on the original issue you should resolve

<issue_title>inline image resize parameter requires a space before the parameter</issue_title>
<issue_description>This: ![Manage this data view option](../images/manage-this-data-view.png " =50%")
correctly resizes the image

This: ![Manage this data view option](../images/manage-this-data-view.png "=50%")
doesn't

Discussed in #2014 (comment)</issue_description>

<agent_instructions>You can take a look at https://docs-v3-preview.elastic.dev/elastic/docs-builder/tree/main/syntax/images.md how it should work.

Also make it lenient, so it doesn't matter if there is a trailing or preceeding space or not</agent_instructions>

Comments on the Issue (you are @copilot in this section)

Fixes #2016

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@Copilot Copilot AI changed the title [WIP] Fix inline image resize parameter for proper rendering Fix inline image resize parameter to work without space before = Oct 8, 2025
@Copilot Copilot AI requested a review from reakaleek October 8, 2025 07:46
Copilot finished work on behalf of reakaleek October 8, 2025 07:46
@reakaleek
Copy link
Member

@copilot would it be possible to require a space if there is a title and a space not required if there is no title

Copy link
Contributor Author

Copilot AI commented Oct 8, 2025

@copilot would it be possible to require a space if there is a title and a space not required if there is no title

Yes! Updated the regex to require a space before = when a title is present, while making it optional when there's no title. This provides better clarity in the syntax.

Now works:

  • ![alt](img.png "=50%") - no title, no space needed ✅
  • ![alt](img.png "My Title =50%") - with title, space required ✅

Does not work:

  • ![alt](img.png "My Title=50%") - with title, no space ❌

Changes in commit {commit_hash}.

@Copilot Copilot AI changed the title Fix inline image resize parameter to work without space before = Fix inline image resize parameter to require space before = when title present Oct 8, 2025
Copilot finished work on behalf of reakaleek October 8, 2025 07:56
Copy link

github-actions bot commented Oct 8, 2025

🔍 Preview links for changed docs

@reakaleek reakaleek marked this pull request as ready for review October 8, 2025 09:30
@reakaleek reakaleek requested review from a team as code owners October 8, 2025 09:30
@reakaleek reakaleek requested a review from cotti October 8, 2025 09:30
@reakaleek reakaleek added the fix label Oct 8, 2025
Copy link
Contributor

@florent-leborgne florent-leborgne left a comment

Choose a reason for hiding this comment

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

🐈

@reakaleek
Copy link
Member

@cotti or @Mpdreamz can we get a review here? 🙇

Thanks

@reakaleek reakaleek merged commit 1371ac9 into main Oct 9, 2025
23 checks passed
@reakaleek reakaleek deleted the copilot/fix-inline-image-resize-parameter branch October 9, 2025 16:21
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.

inline image resize parameter requires a space before the parameter
4 participants