2
0
mirror of https://github.com/tenrok/BBob.git synced 2026-06-05 16:42:27 +03:00

fix: bug with lost closing tag (#186)

* fix: closing tag bug

* chore: add changeset thin-crabs-wonder.md

* chore: remove debug code

* chore: add more tests
This commit is contained in:
Nikolay Kost
2023-08-28 15:26:27 +03:00
committed by GitHub
parent 867c1b0710
commit 603c3ead0f
10 changed files with 185 additions and 694 deletions
+56
View File
@@ -361,6 +361,62 @@ describe('Parser', () => {
]);
});
test('parse with lost closing tag in middle', () => {
const str = `[quote]some[/quote][color=red]test[/color]
[quote]xxxsdfasdf
sdfasdfasdf
[url=xxx]xxx[/url]`
expectOutput(
parse(str),
[
{ tag: 'quote', attrs: {}, content: ['some'] },
{ tag: 'color', attrs: { red: 'red' }, content: ['test'] },
'\n',
'[quote]',
'xxxsdfasdf',
'\n',
'sdfasdfasdf',
'\n',
'\n',
{ tag: 'url', attrs: { xxx: 'xxx' }, content: ['xxx'] }
]
)
})
test('parse with lost closing tag on start', () => {
const str = `[quote]xxxsdfasdf[quote]some[/quote][color=red]test[/color]sdfasdfasdf[url=xxx]xxx[/url]`
expectOutput(
parse(str),
[
'[quote]',
'xxxsdfasdf',
{ tag: 'quote', attrs: {}, content: ['some'] },
{ tag: 'color', attrs: { red: 'red' }, content: ['test'] },
'sdfasdfasdf',
{ tag: 'url', attrs: { xxx: 'xxx' }, content: ['xxx'] }
]
)
})
test('parse with lost closing tag on end', () => {
const str = `[quote]some[/quote][color=red]test[/color]sdfasdfasdf[url=xxx]xxx[/url][quote]xxxsdfasdf`
expectOutput(
parse(str),
[
{ tag: 'quote', attrs: {}, content: ['some'] },
{ tag: 'color', attrs: { red: 'red' }, content: ['test'] },
'sdfasdfasdf',
{ tag: 'url', attrs: { xxx: 'xxx' }, content: ['xxx'] },
'[quote]',
'xxxsdfasdf',
]
)
})
describe('html', () => {
const parseHTML = input => parse(input, { openTag: '<', closeTag: '>' });