diff --git a/lib/unsafe.js b/lib/unsafe.js index c5c5d4a..bd979aa 100644 --- a/lib/unsafe.js +++ b/lib/unsafe.js @@ -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: '='}, diff --git a/test/index.js b/test/index.js index e47facd..b0e3183 100644 --- a/test/index.js +++ b/test/index.js @@ -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 () {