% eoldef.tex, version 1.0 % Copyright (C) 2025 plante % This file is relased under the LaTeX Project Public License (LPPL) 1.3c. % eoldef: define commands which absorb the whole source line as arguments. % Usage: \eoldef { } % defines a control sequence that is delimited by the end-of-line in addition to % the specified parameter text. This enables less verbose markdown-like syntax. % For instance, \eoldef\test#1:#2{} and % \test abc:def % will give #1 = abc, #2 = def. % \eoldef is the \global variant to \eoldef. % Like \verb|...|, \eoldef'd commands may generally not be used as part of % another command's argument as it changes catcodes. % However, if you must use it in environments where catcodes are frozen, you % may follow the command with a braced argument, eg. \test{#1:#2} using the % previous example. % This package may be used in plain TeX or LaTeX by \input{eoldef}. \ifdefined\eoldef \expandafter\endinput \fi \protected\def\eoldef#1#2#{% \protected\edef#1{% \noexpand\eolarg \csname eoldef@\string#1\endcsname }% \long \expandafter\def \csname eoldef@\string#1\endcsname#2\@nil } \protected\def\eolgdef#1#2#{% \protected\xdef#1{% \noexpand\eolarg \csname eoldef@\string#1\endcsname }% \long \expandafter\gdef \csname eoldef@\string#1\endcsname#2\@nil } \protected\def\eolarg#1{% \let\eolarg@command= #1% \ifnum \iffalse{\fi `}=\z@ \fi \futurelet\eolarg@temp\eolargA } \def\eolargA{% \ifcat\bgroup \noexpand\eolarg@temp \expandafter\eolargB \else \expandafter\eolargC \fi } \def\eolargB#1{% \ifnum`{=\z@ }\fi \eolarg@command#1\@nil } \def\eolargC{% \begingroup \endlinechar=`\^^M \catcode`\^^M=12 \eolargD } \begingroup \lccode`+=`\^^M \lowercase{ \endgroup \def\eolargD#1+{% \endgroup \ifnum`{=\z@ }\fi \eolarg@command#1\@nil } }