diff --git a/__tests__/ExpensiMark-HTML-test.js b/__tests__/ExpensiMark-HTML-test.js index a98e35aa..b37c5b5c 100644 --- a/__tests__/ExpensiMark-HTML-test.js +++ b/__tests__/ExpensiMark-HTML-test.js @@ -1225,3 +1225,11 @@ test('Test link with code fence inside the alias text part', () => { + '[test
code
test](google.com)'; expect(parser.replace(testString)).toBe(resultString); }); + +test('Test strikethrough with multiple tilde characters', () => { + let testString = '~~~hello~~~'; + expect(parser.replace(testString)).toBe('~~hello~~'); + + testString = '~~~~'; + expect(parser.replace(testString)).toBe('~~~~'); +}); diff --git a/lib/ExpensiMark.js b/lib/ExpensiMark.js index 0c34246f..7769f8b2 100644 --- a/lib/ExpensiMark.js +++ b/lib/ExpensiMark.js @@ -210,7 +210,7 @@ export default class ExpensiMark { }, { name: 'strikethrough', - regex: /\B~((?=\S)((~~(?!~)|[^\s~]|\s(?!~))+?))~\B(?![^<]*(<\/pre>|<\/code>|<\/a>))/g, + regex: /\B~((?=\S)(([^\s~]|\s(?!~))+?))~\B(?![^<]*(<\/pre>|<\/code>|<\/a>))/g, replacement: (match, g1) => (this.containsNonPairTag(g1) ? match : `${g1}`), }, {