fix(markdown): properly handle square brackets that are not links

This commit is contained in:
teidesu 2021-06-23 17:08:23 +03:00
parent c3ee177b4c
commit 028e331cb6
3 changed files with 4 additions and 3 deletions

View file

@ -95,7 +95,7 @@ where `1234567` is the ID of the user you want to mention
| `[Google](https://google.com)` | [Google](https://google.com) | `<a href="https://google.com">Google</a>`
| `[__Google__](https://google.com)` | [_Google_](https://google.com) | `<a href="https://google.com"><i>Google</i></a>`
| `[empty link]()` | empty link | `empty link`
| `[empty link]` | empty link | `empty link`
| `[empty link]` | [empty link] | `[empty link]`
| `[User](tg://user?id=1234567)` | N/A | N/A
### Nested and overlapping entities

View file

@ -102,7 +102,8 @@ export class MarkdownMessageEntityParser implements IMessageEntityParser {
if (text[pos + 1] !== '(') {
// [link text]
// ignore this
// ignore this, and add opening [
result = `${result.substr(0, ent.offset)}[${result.substr(ent.offset)}]`
pos += 1
continue
}

View file

@ -587,7 +587,7 @@ describe('MarkdownMessageEntityParser', () => {
})
it('should ignore empty urls', () => {
test('[link]() [link]', [], 'link link')
test('[link]() [link]', [], 'link [link]')
})
it('should ignore unclosed tags', () => {