enkisoftware / imgui_markdown

Markdown for Dear ImGui
zlib License
1.03k stars 69 forks source link

Support square brackets in link text #23

Open jasmaa opened 2 years ago

jasmaa commented 2 years ago

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 commented 1 year ago

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