diff --git a/__tests__/ExpensiMark-Markdown-test.js b/__tests__/ExpensiMark-Markdown-test.js
index 8361c2c2..c17d126d 100644
--- a/__tests__/ExpensiMark-Markdown-test.js
+++ b/__tests__/ExpensiMark-Markdown-test.js
@@ -513,13 +513,20 @@ test('Test heading1 markdown when # is in the middle of the line', () => {
test('Test html string to heading1 markdown', () => {
const testString = '
This is a heading1
';
- const resultString = '\n# This is a heading1\n';
+ const resultString = '# This is a heading1';
expect(parser.htmlToMarkdown(testString)).toBe(resultString);
});
test('Test html to heading1 markdown when there are other tags inside h1 tag', () => {
const testString = 'This is a heading1
';
- const resultString = '\n# This is a *heading1*\n';
+ const resultString = '# This is a *heading1*';
+ expect(parser.htmlToMarkdown(testString)).toBe(resultString);
+});
+
+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';
expect(parser.htmlToMarkdown(testString)).toBe(resultString);
});
@@ -531,6 +538,29 @@ test('Test html to heading1 markdown when h1 tags are in the middle of the line'
expect(parser.htmlToMarkdown(testString)).toBe(resultString);
});
+test('Test html to heading1 markdown when h1 tag is in the end of the line', () => {
+ const testString = 'this line has an h1 in the end of the lineheading1
';
+ const resultString = 'this line has an h1 in the end of the line'
+ + '\n# heading1';
+ expect(parser.htmlToMarkdown(testString)).toBe(resultString);
+});
+
+test('Test html to heading1 markdown when there are 2 h1 tags in the line', () => {
+ const testString = 'this is the first heading1heading1
this is the second heading1heading1
';
+ const resultString = 'this is the first heading1'
+ + '\n# heading1'
+ + '\nthis is the second heading1'
+ + '\n# heading1';
+ expect(parser.htmlToMarkdown(testString)).toBe(resultString);
+});
+
+test('Test html to heading1 markdown when there are adjacent h1 tags in the line', () => {
+ const testString = 'heading1
heading2
';
+ const resultString = '# heading1'
+ + '\n# heading2';
+ expect(parser.htmlToMarkdown(testString)).toBe(resultString);
+});
+
test('Test link with multiline text do not loses markdown', () => {
const testString = 'multiline\ntext';
const resultString = '[multiline\ntext](https://google.com/)';
diff --git a/lib/ExpensiMark.js b/lib/ExpensiMark.js
index bac4b81c..c3decc65 100644
--- a/lib/ExpensiMark.js
+++ b/lib/ExpensiMark.js
@@ -230,7 +230,7 @@ export default class ExpensiMark {
{
name: 'heading1',
regex: /\s*<(h1)(?:"[^"]*"|'[^']*'|[^'">])*>(.*?)<\/\1>(?![^<]*(<\/pre>|<\/code>))\s*/gi,
- replacement: '\n# $2\n',
+ replacement: '[block]# $2[block]',
},
{
name: 'listItem',