File tree Expand file tree Collapse file tree
lua/markview/renderers/markdown Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -631,7 +631,12 @@ local code = lpeg.C( at_valid * lpeg.P("`")^1 * code_content^1 * lpeg.P("`")^1 )
631631
632632local hyperlink_content = lpeg .P (" \\ ]" ) + ( 1 - lpeg .P (" ]" ) );
633633local hyperlink_no_src = lpeg .C ( lpeg .P (" [" ) * hyperlink_content ^ 0 * lpeg .P (" ]" ) ) / md_str .hyperlink_no_src ;
634- local src_content = lpeg .P (" \\ )" ) + ( 1 - lpeg .S (" ) \t " ) );
634+ -- Supports balanced parentheses in URLs per CommonMark spec §6.7:
635+ -- https://spec.commonmark.org/0.31.2/#link-destination
636+ local src_content = lpeg .P {
637+ " src" ;
638+ src = lpeg .P (" \\ )" ) + (lpeg .P (" (" ) * lpeg .V (" src" )^ 0 * lpeg .P (" )" )) + ( 1 - lpeg .S (" ) \t " ) );
639+ };
635640local hyperlink_src = lpeg .C ( lpeg .P (" [" ) * hyperlink_content ^ 0 * lpeg .P (" ](" ) * src_content ^ 0 * lpeg .P (" )" ) ) / md_str .hyperlink_src ;
636641local hyperlink = hyperlink_src + hyperlink_no_src ;
637642
You can’t perform that action at this time.
0 commit comments