Skip to content

Commit

Permalink
fix: Can strike-through pre code block.
Browse files Browse the repository at this point in the history
Signed-off-by: Krishna Gupta <belivethatkg@gmail.com>
  • Loading branch information
Krishna2323 committed Oct 11, 2023
1 parent 009c2ab commit c7a1da9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions __tests__/ExpensiMark-HTML-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,9 @@ test('Test code fencing with ExpensiMark syntax outside', () => {

codeFenceExample = '_Test1 ```code``` Test2_';
expect(parser.replace(codeFenceExample)).toBe('_Test1 <pre>code</pre> Test2_');

codeFenceExample = '~Test1 ```code``` Test2~';
expect(parser.replace(codeFenceExample)).toBe('~Test1 <pre>code</pre> Test2~');
});

test('Test code fencing with additional backticks inside', () => {
Expand Down
2 changes: 1 addition & 1 deletion lib/ExpensiMark.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ export default class ExpensiMark {
{
name: 'strikethrough',
regex: /\B~((?![\s~])[\s\S]*?[^\s~])~\B(?![^<]*(<\/pre>|<\/code>|<\/a>))/g,
replacement: (match, g1) => (this.containsNonPairTag(g1) ? match : `<del>${g1}</del>`),
replacement: (match, g1) => (g1.includes('<pre>') || this.containsNonPairTag(g1) ? match : `<del>${g1}</del>`),
},
{
name: 'newline',
Expand Down

0 comments on commit c7a1da9

Please sign in to comment.