From 336f0ef2314c8642b9168d63271609159cc4f8e8 Mon Sep 17 00:00:00 2001 From: Jay Lalakiya Date: Fri, 15 Sep 2023 08:55:34 +0530 Subject: [PATCH 1/2] Modify regex in textToMarkdown functionality --- lib/ExpensiMark.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ExpensiMark.js b/lib/ExpensiMark.js index 70c63dd2..cbe4aa20 100644 --- a/lib/ExpensiMark.js +++ b/lib/ExpensiMark.js @@ -282,7 +282,7 @@ export default class ExpensiMark { }, { name: 'heading1', - regex: /[^\S\r\n]*<(h1)(?:"[^"]*"|'[^']*'|[^'">])*>(.*?)<\/\1>(?![^<]*(<\/pre>|<\/code>))[^\S\r\n]*/gi, + regex: /[^\S\r\n]*<(h1)(?:"[^"]*"|'[^']*'|[^'">])*>(.*?)<\/\1>(?![^<]*(<\/pre>|<\/code>))/gi, replacement: '

# $2

', }, { From 2248cfb29bd22089d86492e259fd7d33afeb46a6 Mon Sep 17 00:00:00 2001 From: Jay Lalakiya Date: Fri, 15 Sep 2023 09:24:43 +0530 Subject: [PATCH 2/2] Change unit tests --- __tests__/ExpensiMark-Markdown-test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/__tests__/ExpensiMark-Markdown-test.js b/__tests__/ExpensiMark-Markdown-test.js index 8e0b834f..56624cec 100644 --- a/__tests__/ExpensiMark-Markdown-test.js +++ b/__tests__/ExpensiMark-Markdown-test.js @@ -554,7 +554,7 @@ test('Test html to heading1 markdown when there are other tags inside h1 tag', ( test('Test html to heading1 markdown when h1 tag is in the beginning of the line', () => { const testString = '

heading1

in the beginning of the line'; const resultString = '# heading1\n' - + 'in the beginning of the line'; + + ' in the beginning of the line'; expect(parser.htmlToMarkdown(testString)).toBe(resultString); }); @@ -562,7 +562,7 @@ test('Test html to heading1 markdown when h1 tags are in the middle of the line' const testString = 'this line has a

heading1

in the middle of the line'; const resultString = 'this line has a\n' + '# heading1\n' - + 'in the middle of the line'; + + ' in the middle of the line'; expect(parser.htmlToMarkdown(testString)).toBe(resultString); });