fix(markdown): properly handle square brackets that are not links
This commit is contained in:
parent
c3ee177b4c
commit
028e331cb6
3 changed files with 4 additions and 3 deletions
|
@ -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">Google</a>`
|
||||||
| `[__Google__](https://google.com)` | [_Google_](https://google.com) | `<a href="https://google.com"><i>Google</i></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`
|
| `[empty link]` | [empty link] | `[empty link]`
|
||||||
| `[User](tg://user?id=1234567)` | N/A | N/A
|
| `[User](tg://user?id=1234567)` | N/A | N/A
|
||||||
|
|
||||||
### Nested and overlapping entities
|
### Nested and overlapping entities
|
||||||
|
|
|
@ -102,7 +102,8 @@ export class MarkdownMessageEntityParser implements IMessageEntityParser {
|
||||||
|
|
||||||
if (text[pos + 1] !== '(') {
|
if (text[pos + 1] !== '(') {
|
||||||
// [link text]
|
// [link text]
|
||||||
// ignore this
|
// ignore this, and add opening [
|
||||||
|
result = `${result.substr(0, ent.offset)}[${result.substr(ent.offset)}]`
|
||||||
pos += 1
|
pos += 1
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
|
@ -587,7 +587,7 @@ describe('MarkdownMessageEntityParser', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should ignore empty urls', () => {
|
it('should ignore empty urls', () => {
|
||||||
test('[link]() [link]', [], 'link link')
|
test('[link]() [link]', [], 'link [link]')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should ignore unclosed tags', () => {
|
it('should ignore unclosed tags', () => {
|
||||||
|
|
Loading…
Reference in a new issue