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

Support square brackets in link text #23

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jasmaa
Copy link

@jasmaa jasmaa commented May 15, 2022

Add support for nested square brackets in link text.

ex.

[alice [at] example dot com](https://example.com) previously parsed as:

TEXT: alice [at
LINK: https://example.com

This will now parse as:

TEXT: alice [at] example dot com
LINK: https://example.com

@juliettef
Copy link
Member

Thanks for submitting this PR. We've done further testing using markdownlivepreview.com and redditpreview.com, and realised that neither the current imgui_markdown nor your suggested fix completely match the expected markdown behaviour. See the test below.

If you would like to amend your PR so it passes the test we will review it. Otherwise we will keep the current code so we don't break people's implementation.

Test square brackets in link text

Input

01. [link](https://www.github.com)  
02. [lin[]k](https://www.github.com)
03. [li[n]k](https://www.github.com)  
04. [lin][k](https://www.github.com)  
05. [lin[k](https://www.github.com)  
06. [lin[][k](https://www.github.com) 
07. [lin]k](https://www.github.com)  
08. [lin]]k](https://www.github.com)  
09. [li[n]]k](https://www.github.com)  
10. [link (https://www.github.com)  
11. [lin]k (https://www.github.com)

Expected Output - using markdownlivepreview.com:

1.  link
2.  lin[]k
3.  li[n]k
4.  [lin]k
5.  [link
6.  [lin[]k
7.  [lin]k](https://www.github.com)
8.  [lin]]k](https://www.github.com)
9.  [li[n]]k](https://www.github.com)
10. [link (https://www.github.com)
11. [lin]k (https://www.github.com/)

Actual - current imgu_markdown:

1.  link - P
2.  lin[
3.  li[n
4.  lin
5.  lin[k
6.  lin
7.  lin
8.  lin
9.  [li[n
10. [link (https://www.github.com/) - P
11. lin

Actual - this PR:

1.  link - P
2.  lin[]k - P
3.  li[n]k - P
4.  lin
5.  [lin[k](https://www.github.com)  
6.  [lin[][k](https://www.github.com) 
7.  lin
8.  lin
9.  li[n]
10. [link (https://www.github.com) - P
11. lin  

@juliettef juliettef self-requested a review April 2, 2023 17:59
@juliettef juliettef added the bug Something isn't working label Apr 2, 2023
Copy link
Member

@juliettef juliettef left a comment

Choose a reason for hiding this comment

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants