The problem is that \obeylines macro is not working while it's inside \def
Compare:
\long\def\linesaver#1{\obeylines#1}
\linesaver{
Test1
Test2
}
VS
{
\obeylines
Test3
Test4
Test5
}
First does not saving newlines, but second does. Why?
Disregard targets i'm trying to reach - consider i'm just trying to understand how exactly tex works under the hood.
\obeylineshas no effect when used in the argument to another command, because it works by changing category codes. – egreg Nov 23 '15 at 21:46\obeylinesmacro changes catcodes and you must read the text from file after these catcodes are changed. And don't forget to return the catcode setting back. For example you can put the whole processing into a group. Your intend can be implemented by\def\linesaver{\bgroup\obeylines\linesaverA}\def\linesaverA#1{#1\egroup}. – wipet Nov 24 '15 at 12:39