Skip to content

Commit

Permalink
Prevent new line addition when codefence wrapped in strike through
Browse files Browse the repository at this point in the history
  • Loading branch information
spcheema committed Sep 6, 2023
1 parent e63d06e commit df2393d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
21 changes: 21 additions & 0 deletions __tests__/ExpensiMark-HTML-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1225,3 +1225,24 @@ test('Test link with code fence inside the alias text part', () => {
+ '[test <pre>code</pre> test](<a href="https://google.com" target="_blank" rel="noreferrer noopener">google.com</a>)';
expect(parser.replace(testString)).toBe(resultString);
});



test('Test codefence inside strike through', () => {
let testString = '```some text```';
let htmlString = parser.replace(testString)
let output = parser.htmlToMarkdown(htmlString)


console.log('htmlString', htmlString, 'output', output)
expect(output).toBe('```\nsome text\n```')


// codefence inside strike through
testString = '~```some text```~';

htmlString = parser.replace(testString)
output = parser.htmlToMarkdown(htmlString)
console.log('htmlString', htmlString, 'output', output)
expect(output).toBe('~```\nsome text\n```~\n')
});
10 changes: 10 additions & 0 deletions lib/ExpensiMark.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,11 @@ export default class ExpensiMark {
regex: /<\/h1><br\s*[/]?>/gi,
replacement: '</h1>',
},
{
name: 'replacedePreDelBr',
regex: /<\/pre><\/del><br \/>/gi,
replacement: '</pre></del>',
},
];

/**
Expand All @@ -250,6 +255,11 @@ export default class ExpensiMark {
regex: /<\/pre>(.)/gi,
replacement: '</pre><br />$1',
},
{
name: 'replacePreBrDel',
regex: /<\/pre><br \/><\/del>/gi,
replacement: '</pre></del><br />',
},
{
name: 'exclude',
regex: new RegExp(
Expand Down

0 comments on commit df2393d

Please sign in to comment.