fixed parsing of title-less links

This commit is contained in:
Yessiest 2025-03-10 03:00:23 +04:00
parent 74edbf603e
commit 01d88135dc
1 changed files with 8 additions and 7 deletions

View File

@ -79,11 +79,12 @@ module PointBlank
[process_destination(result[0].gsub(/\\(?=[><])/, '')[1..-2]),
text.delete_prefix(result[0]).lstrip]
elsif (result = text.match(/\A\S+/)) &&
!result[0].start_with?('<') &&
result &&
balanced?(result[0])
[process_destination(result[0]),
text.delete_prefix(result[0]).lstrip]
(lnk = result[0]) &&
!lnk.start_with?('<') &&
(lnk = (ix = find_balanced_end(lnk)) ? lnk[..ix - 1] : lnk) &&
balanced?(lnk)
[process_destination(lnk),
text.delete_prefix(lnk).lstrip]
else
[nil, text]
end
@ -125,7 +126,7 @@ module PointBlank
destination, remaining = read_destination(remaining[1..])
return [nil, text] unless destination
title, remaining = read_title(remaining)
title, remaining = read_title(remaining.lstrip)
properties[:uri] = destination
properties[:title] = title
close_bracket = true
@ -164,7 +165,7 @@ module PointBlank
bracketcount += 1
elsif part == ')'
bracketcount -= 1
return index if bracketcount.zero?
return index if bracketcount <= 0
end
index += part.length
end