I’m working on a Node.js application and need to append newline characters to a file in a way that is valid and recognized by various text editors and tools(Specific for .bib files).
I tried to add n after each field. This is one case.
const data = 'This is some text that I want to append with a new line';
const newline = 'n';
res.setHeader('Content-Type', 'text/x-bibtex;charset=utf-8');
res.setHeader('Content-Disposition', `attachment;filename=${filename}`);
res.send(data);
However, when I open the file in a text editor, the newline character doesn’t seem to be recognized, and everything appears on a single line.
2
Answers
I was doing some sort of
So I just add '/n/ after replace method :
You can use the built in os module.
Its valid and recognized by various text editors and tools, you need to use the appropriate newline sequence based on the operating system’s conventions