Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/unsafe.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ export const unsafe = [
inConstruct: 'phrasing',
notInConstruct: fullPhrasingSpans
},
{
character: '<',
before: '(?:[ \t\r\n]|$)',
inConstruct: 'phrasing',
notInConstruct: fullPhrasingSpans
},
{character: '<', inConstruct: 'destinationLiteral'},
// An equals to can start setext heading underlines.
{atBreak: true, character: '='},
Expand Down
20 changes: 20 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3932,6 +3932,26 @@ test('escape', async function (t) {
)
})

await t.test(
'should escape what would otherwise be html (2)',
async function () {
assert.equal(
to({type: 'paragraph', children: [{type: 'text', value: '<1%'}]}),
'\\<1%\n'
)
}
)

await t.test(
'dont escape a less-than sign that cant be a tag open',
async function () {
assert.equal(
to({type: 'paragraph', children: [{type: 'text', value: 'm<1%'}]}),
'm<1%\n'
)
}
)

await t.test(
'should escape what would otherwise be code (text)',
async function () {
Expand Down