Debian Codegraph @

texmf-dist/doc/generic/eoldef/eoldef-doc.tex

raw
1 \documentclass[11pt]{article}
2
3 \usepackage{geometry}
4
5 \usepackage{xcolor}
6
7 \usepackage{mlmodern}
8
9 \usepackage{enumitem}
10 \setlist[itemize]{align=parleft,left=0pt..30pt}
11
12 \parindent=0pt
13 \parskip=\medskipamount
14
15 \usepackage[hidelinks]{hyperref}
16
17 \protected\def\link{\futurelet\tempa\linkA}
18 \def\linkA{\ifx[\tempa \expandafter\linkB \else \expandafter\linkC \fi}
19 \long\def\linkB[#1]#2{\href{#2}{\ttul{#1}}}
20 \long\def\linkC#1{\href{#1}{\ttul{#1}}}
21 \protected\long\def\email#1{\href{mailto:#1}{\ttul{#1}}}
22
23 \protected\long\def\ttul#1{%
24 \leavevmode
25 \setbox0=\hbox{\ttfamily #1}%
26 \lower2.25pt\rlap{\leaders\hrule height.625px\hskip\wd0}%
27 \pdfliteral{q 1 G 2 Tr 1.7 w 1 j 1 J}%
28 \rlap{\copy0}%
29 \pdfliteral{Q}%
30 \box0
31 }
32
33 \usepackage{eoldef}
34
35 \title{The \texttt{eoldef} Package, version 1.1}
36 \author{plante}
37
38 \begin{document}
39
40 \maketitle
41
42 The \texttt{eoldef} package provides the \verb|\eoldef| and \verb|\eolgdef| commands that define macros whose arguments are delimited by the end of a source code line. They are analogues to \verb|\def| and \verb|\gdef| respectively.
43
44 \subsection*{Usage}
45
46 Usage:
47 \verb|\eol|%
48 {\color{gray}\verb|[|}\verb|g|{\color{gray}\verb|]|}%
49 \verb|def|%
50 $\,\langle\textit{control sequence}\rangle\,$%
51 $\,\langle\textit{parameter text}\rangle\,$%
52 \verb|{|%
53 $\,\langle\textit{replacement text}\rangle\,$%
54 \verb|}|.
55
56 This defines $\langle\textit{control sequence}\rangle$ to essentially have parameter text $\langle\textit{parameter text}\rangle\,$\verb|^^M|, where \verb|^^M| is the end-of-line marker.
57
58 As is the case for all category code-changing macros, commands defined by \verb|\eoldef| or \verb|\eolgdef| may not be used normally as part of another command's argument or replacement text.
59 However, an alternate syntax is provided in cases where category codes are frozen: the contents of the whole line may be given as a single braced argument, eg.\ \verb|\command{|$\ldots$\verb|}|.
60
61 If it happens that the command is to be used with the usual syntax but the contents of the line starts with a braced group, simply insert a space between it and the command to disable the alternate syntax detection, eg.\ \verb*|\command {|$\ldots$\verb|}|$\ldots$
62
63 This package may be loaded by \verb|\input{eoldef}| (plain \TeX\ and other formats) or \verb|\usepackage{eoldef}| (\LaTeX). It is line-ending independent.
64
65 \newpage
66 \subsection*{Samples}
67
68 \begin{itemize}
69
70 \item Markdown-like syntax for chapter titles:
71 \[\halign{&#\hfil\crcr
72 \verb|\catcode`-=\active \eoldef-#1{\chapter{#1}}|\cr
73 \verb|- Chapter Title|\cr
74 }\]
75
76 \item The following are equivalent:
77 \[\halign{&#\hfil\crcr
78 \verb|\eoldef\command#1{|$\ldots$\verb|}|\cr
79 \verb|\command abc def|\cr
80 \verb|\command{abc def}|\cr
81 }\]
82
83 \item \verb|#1| is \verb|abc| in the first application and \verb|{abc} def| in the second.
84 \[\halign{&#\hfil\crcr
85 \verb|\command{abc} def|\cr
86 \verb|\command {abc} def|\cr
87 }\]
88
89 \item More complex parameter texts may also be used:
90 \[\halign{&#\hfil\crcr
91 \verb|\eoldef\command#1:#2{|$\ldots$\verb|}|\cr
92 \verb|\command abc:def|\cr
93 }\]
94 (\verb|#1| is \verb|abc| while \verb|#2| is \verb|def|.)
95
96
97
98
99 \end{itemize}
100
101
102 \subsection*{License}
103
104 This package is copyright \copyright\ 2025 plante, and
105 released under the \LaTeX\ Project Public License (\textsc{lppl}) 1.3c.
106
107 \subsection*{Repository}
108
109 The upstream repository of this package may be found at
110 \[ \link{https://github.com/plante3/eoldef/tree/main}. \]
111
112 \end{document}