diff --git a/__tests__/ExpensiMark-Markdown-test.js b/__tests__/ExpensiMark-Markdown-test.js
index 69b5cd36..e6b4a12c 100644
--- a/__tests__/ExpensiMark-Markdown-test.js
+++ b/__tests__/ExpensiMark-Markdown-test.js
@@ -59,8 +59,8 @@ test('Test HTML string with seperate closing tags (
) to markdown ', ()
});
test('Test HTML string with attributes', () => {
- const testString = 'This is a . None of these strings.';
- const resultString = '_This is_ a test. None of *these strings*.';
+ const testString = 'This is a . None of these strings.';
+ const resultString = '_This is_\n a test. None of *these strings*.';
expect(parser.htmlToMarkdown(testString)).toBe(resultString);
});
diff --git a/lib/ExpensiMark.js b/lib/ExpensiMark.js
index de494a1f..b660cfd2 100644
--- a/lib/ExpensiMark.js
+++ b/lib/ExpensiMark.js
@@ -174,7 +174,9 @@ export default class ExpensiMark {
// Replaces open and closing
tags with a single
pre: inputString => inputString.replace(' ', ' ').replace('
', ' '),
- regex: / \n?/gi,
+
+ // Include the immediately followed newline as ` \n` should be equal to one \n.
+ regex: / ])*>(?![^<]*(<\/pre>|<\/code>))\n?/gi,
replacement: '\n'
},
{