markdown-confluence / markdown-confluence

Publish your Markdown Files to Confluence

Home Page:https://markdown-confluence.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Callout transformation not handling additional Markdown syntax correctly

AdamCoulterOz opened this issue · comments

Describe the bug
The transformation of callouts to Confluence-specific syntax is not working correctly when the callout includes additional Markdown syntax, such as links or bold text.

To Reproduce
Steps to reproduce the behavior:

  1. Transform the following Markdown with a link:

    > [!info] Refer to the [Official Documentation](https://example.com)
    

    The resulting info panel text is:

    [!info] Refer to the <a href="https://example.com">Official Documentation</a>
    

    The expected info panel text is:

    Refer to the <a href="https://example.com">Official Documentation</a>
    
  2. Transform the following Markdown with bold text:

    > [!info] **This is important**
    

    The resulting info panel text is:

    [!info] <bold>This is important</bold>
    

    The expected info panel text is:

    <bold>This is important</bold>
    

Expected behavior
The transformation should correctly replace the custom syntax with the corresponding Confluence-specific syntax, even when the callout includes additional Markdown syntax.

Additional context
The issue seems to be related to the regular expression used to match the custom syntax and the way the custom syntax is replaced in the content of the blockquote. The current implementation might not correctly handle cases where the custom syntax is followed by additional Markdown syntax.

The relevant code is located here:

const panelRegex =
/\[!(?<calloutType>.*)](?<collapseType>[+-])*[ \t]*(?<title>.*)*/;

Possible Solution
There seems to be a bug or two in the regular expression used to match the custom syntax. Here is a fixed version:

/\[!(?<calloutType>.*?)\](?<collapseType>[+-])?[ \t]*(?<title>.*)/