[Tex/LaTex] How to import a text file so that it becomes the body text of the LaTeX document

external filesimport

I want to completely separate formatting and content creation. The articles I will write are all plain prose that requires minimum or zero LaTeX formatting.

Also, the text file doesn't have the one-blank-line gap between paragraphs. They are separated only by one linefeed.

SUMMARY:
Is there a way to import it roughly like:

\begin{document}
  \importtextfile{my_essay.txt}
\end{document}

Can I also tell LaTeX to interpret the single linefeeds as new paragraph?

Best Answer

Sure. TeX inserts (by default) ^^M at the end of each line. So something like

\begingroup
\catcode`\^^M\active
\let ^^M\par%
\input{youressay.txt}%
\endgroup%

should do it, although I didn't test.

Edit: I just remembered the \obeylines macro which does exactly what I wrote above.

\begingroup
\obeylines
\input{youressay.txt}%
\endgroup%