text icon indicating copy to clipboard operation
text copied to clipboard

Newlines are not preserved from markdown but are saved to it

Open juliusknorr opened this issue 2 months ago • 1 comments

I noticed some odd markdown behaviour.

Opening a file that was uploaded manually with this content:

## Test





## test

This results in the newlines being removed and the markdown file being overwritten with:

## Test

## test

However if you add newlines in text they will be written to markdown again.

We keep the newlines in text as long as the editor state is preserved, but the markdown will loose them.

juliusknorr avatar Oct 17 '25 12:10 juliusknorr

Reproduciton test case for markdown.spec.js that currently fails but I guess should pass:

	test('newlines', () => {
		expect(markdownThroughEditor('## Test\n\ntest')).toBe('## Test\n\ntest')
		expect(markdownThroughEditor('## Test\n\n\n\ntest')).toBe('## Test\n\n\n\ntest')
		expect(markdownThroughEditor('\n')).toBe('\n')
		expect(markdownThroughEditor('')).toBe('')
	})

Possibly relevant upstream context: https://github.com/markdown-it/markdown-it/issues/211

juliusknorr avatar Oct 21 '25 08:10 juliusknorr