Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V13 Fixes #17646 where bold markdown does not work in a property description #17806

Merged
merged 1 commit into from
Dec 13, 2024

Conversation

danlister
Copy link
Member

Fixed an issue where bold markdown would not work inside a property description #17646

Prerequisites

  • I have added steps to test this contribution in the description below

Description

  • Add a property description to a new or existing property which contains ** around a couple of different words.
  • Save the document type.
  • Go to Content and view an instance of that Document Type
  • View the lovely formatted property description. Previously the style would break. This fix now renders the wrapped markdown words using ** in bold.

Screenshot 2024-12-12 at 13 48 39

@nul800sebastiaan
Copy link
Member

I asked GitHub CoPilot to explain this fix and it helps for my understanding, so I'll add the answer I got

The highlighted selection changes the regular expression used to match text for bold and italic formatting in Markdown. Specifically, it modifies the pattern to be non-greedy by using .+? instead of .*. This ensures that the shortest possible match is found, which helps in correctly formatting texts that have multiple bold or italic segments.

Original code:

.replace(/\*\*(.*)\*\*/gim, '<b>$1</b>')
.replace(/\*(.*)\*/gim, '<i>$1</i>')

Updated code:

.replace(/\*\*(.+?)\*\*/gim, '<b>$1</b>')
.replace(/\*(.+?)\*/gim, '<i>$1</i>')

The change from .* to .+? improves the accuracy of the Markdown formatting.

Copy link
Contributor

@iOvergaard iOvergaard left a comment

Choose a reason for hiding this comment

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

LGTM!

@iOvergaard iOvergaard merged commit 4ef5064 into umbraco:v13/contrib Dec 13, 2024
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants