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:
@@ -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: '>' });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user