denco / vscode-confluence-markup

Visual Studio Code extension for Confluence® markup
MIT License
25 stars 10 forks source link

Can't use [ and ] in string #24

Closed jonasboecquaert closed 3 years ago

jonasboecquaert commented 3 years ago

Hi,

I noticed that it is not possible to use symbols [ and ] in a single string without the string in between the symbols being converted into a link. Normally it should be possible to add a \ before the ] symbol to make sure, confluence doesn't recognize the string as a link, but this is not possible with the extension.

image

I have taken a look at the codebase and found the regex expression used for this operation. I believe that by adding a negative lookbehind and checking if a \ precedes the ] symbol, it should be possible to ignore that ] symbol completely. The regex in question can be found at line 97 in this file . The update I propose is the following..

# OLD
let re = /\[([^|]*)?\|?([^|]*)\]/g

# NEW
let re = /\[([^|]*)?\|?([^|]*)(?<!\\)\]/g

It should also be easy to add a new regex to check for \], and replace those with ]. A regex for this replacement can be/\\\]\g which would be able to find all \] matches.

If you would like a pull request with these changes, let me know :)

denco commented 3 years ago

Hi,

thx, for the quick fix and!

Did you know, how it's solved in original confluence/jira? (screenshot would be awesome).

will solve the issue soon!

jonasboecquaert commented 3 years ago

No I'm sorry, I have no idea :/