mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 01:36:22 +00:00
Fix escape codeblock (#2230)
* updated package-lock * added fix and test for escape html in code block * fixed markdown preview render bug * updated comment in escape function * improved escape function * Delete package-lock.json
This commit is contained in:
committed by
Junyoung Choi (Sai)
parent
7330cdaf1c
commit
f0df787bbe
@@ -33,13 +33,38 @@ test('escapeHtmlCharacters should NOT skip code block if that option is NOT enab
|
||||
t.is(actual, expected)
|
||||
})
|
||||
|
||||
test('escapeHtmlCharacters should NOT escape & character if it\'s a part of an escaped character', t => {
|
||||
test("escapeHtmlCharacters should NOT escape & character if it's a part of an escaped character", t => {
|
||||
const input = 'Do not escape & or " but do escape &'
|
||||
const expected = 'Do not escape & or " but do escape &'
|
||||
const actual = escapeHtmlCharacters(input)
|
||||
t.is(actual, expected)
|
||||
})
|
||||
|
||||
test('escapeHtmlCharacters should skip char if in code block', t => {
|
||||
const input = `
|
||||
\`\`\`
|
||||
<dontescapeme>
|
||||
\`\`\`
|
||||
das<das>dasd
|
||||
dasdasdasd
|
||||
\`\`\`
|
||||
<dontescapeme>
|
||||
\`\`\`
|
||||
`
|
||||
const expected = `
|
||||
\`\`\`
|
||||
<dontescapeme>
|
||||
\`\`\`
|
||||
das<das>dasd
|
||||
dasdasdasd
|
||||
\`\`\`
|
||||
<dontescapeme>
|
||||
\`\`\`
|
||||
`
|
||||
const actual = escapeHtmlCharacters(input, { detectCodeBlock: true })
|
||||
t.is(actual, expected)
|
||||
})
|
||||
|
||||
test('escapeHtmlCharacters should return the correct result', t => {
|
||||
const input = '& < > " \''
|
||||
const expected = '& < > " ''
|
||||
|
||||
Reference in New Issue
Block a user