md2gemini icon indicating copy to clipboard operation
md2gemini copied to clipboard

md2gemini removes trailing newlines/whitespace from output

Open acidus99 opened this issue 2 years ago • 1 comments

md2gemini removes any trailing newlines or whitespace in the source file from its output. The file 3.md below ends with 3 \n characters. But the output of md2gemini has no newlines at the end:

~/bug/$ cat 3.md
# this is a test

Here is a list
* item 1
* item 2


~/bug/$ md2gemini -w 3.md
~/bug/$ cat 3.gmi
# this is a test

Here is a list

* item 1
* item 2~/bug/$ 

Note how the shell prompt is now on the same line as * item2. This specifically is causing problems because I append some text onto the gemtext files that are coming out of md2gemini. Because the newlines are gone, the text is not appending correctly

I imagine this is caused by the Markdown tokenizer/parser.

Ideally, md2gemini should preserve trailing whitespace in a file. However at the very least md2gemini should end its output with a newline

acidus99 avatar Jan 09 '23 15:01 acidus99

Removing the trailing newlines is by design. Hacky design, but still. However it's true that there should also be a newline at the end. I would definitely accept a PR for this.

makew0rld avatar May 20 '23 00:05 makew0rld