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
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion imgui_markdown.h
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,7 @@ namespace ImGui
TextBlock text;
TextBlock url;
bool isImage = false;
int num_square_brackets_open = 0;
int num_brackets_open = 0;
};

Expand Down Expand Up @@ -602,14 +603,23 @@ namespace ImGui
{
link.state = Link::HAS_SQUARE_BRACKET_OPEN;
link.text.start = i + 1;
link.num_square_brackets_open = 1;
if( i > 0 && markdown_[i - 1] == '!' )
{
link.isImage = true;
}
}
break;
case Link::HAS_SQUARE_BRACKET_OPEN:
if( c == ']' )
if( c == '[' )
{
++link.num_square_brackets_open;
}
else if( c == ']' )
{
--link.num_square_brackets_open;
}
if( link.num_square_brackets_open == 0 )
{
link.state = Link::HAS_SQUARE_BRACKETS;
link.text.stop = i;
Expand Down