diff --git a/lib/unsafe.js b/lib/unsafe.js index bc0a452..185f91a 100644 --- a/lib/unsafe.js +++ b/lib/unsafe.js @@ -96,8 +96,7 @@ export const unsafe = [ // Caret is not used in markdown for constructs. // An underscore can start emphasis, strong, or a thematic break. {atBreak: true, character: '_'}, - {before: '[^A-Za-z]', character: '_', inConstruct: 'phrasing'}, - {character: '_', after: '[^A-Za-z]', inConstruct: 'phrasing'}, + {character: '_', inConstruct: 'phrasing'}, // A grave accent can start code (fenced or text), or it can break out of // a grave accent code fence. {atBreak: true, character: '`'}, diff --git a/test/index.js b/test/index.js index 82272bb..d40b904 100644 --- a/test/index.js +++ b/test/index.js @@ -3585,5 +3585,81 @@ test('roundtrip', (t) => { 'should roundtrip encoded spaces and tabs where needed' ) + doc = `Separate paragraphs: + +a * is this emphasis? * + +a ** is this emphasis? ** + +a *** is this emphasis? *** + +a *\\* is this emphasis? *\\* + +a \\** is this emphasis? \\** + +a **\\* is this emphasis? **\\* + +a *\\** is this emphasis? *\\** + +One paragraph: + +a * is this emphasis? * +a ** is this emphasis? ** +a *** is this emphasis? *** +a *\\* is this emphasis? *\\* +a \\** is this emphasis? \\** +a **\\* is this emphasis? **\\* +a *\\** is this emphasis? *\\**` + tree = from(doc) + + t.deepEqual( + removePosition(tree, true), + removePosition(from(to(tree)), true), + 'should roundtrip asterisks (tree)' + ) + + doc = `Separate paragraphs: + +a _ is this emphasis? _ + +a __ is this emphasis? __ + +a ___ is this emphasis? ___ + +a _\\_ is this emphasis? _\\_ + +a \\__ is this emphasis? \\__ + +a __\\_ is this emphasis? __\\_ + +a _\\__ is this emphasis? _\\__ + +One paragraph: + +a _ is this emphasis? _ +a __ is this emphasis? __ +a ___ is this emphasis? ___ +a _\\_ is this emphasis? _\\_ +a \\__ is this emphasis? \\__ +a __\\_ is this emphasis? __\\_ +a _\\__ is this emphasis? _\\__` + tree = from(doc) + + t.deepEqual( + removePosition(tree, true), + removePosition(from(to(tree)), true), + 'should roundtrip underscores (tree)' + ) + + doc = to(from(`(____`)) + + t.equal(doc, to(from(doc)), 'should roundtrip attention-like plain text') + + doc = to( + from('Once activated, a service worker ______, then transitions to idle…') + ) + + t.equal(doc, to(from(doc)), 'should roundtrip faux “fill in the blank” spans') + t.end() })