Debian Codegraph @

texmf-dist/source/latex/hardwrap/hardwrap.dtx

raw
1 % \iffalse
2 %
3 %<*internal>
4 \begingroup
5 %</internal>
6 %<*batchfile>
7 \input docstrip.tex
8 \keepsilent
9 \preamble
10 ____________________________
11 The HARDWRAP package
12 (C) 2010-2011 Will Robertson
13 (C) 2010 Kevin Godby
14 License information appended
15
16 \endpreamble
17 \postamble
18
19 Copyright (C) 2010 by Will Robertson <[email protected]>
20 Copyright (C) 2010 by Kevin Godby <[email protected]>
21
22 Distributable under the LaTeX Project Public License,
23 version 1.3c or higher (your choice). The latest version of
24 this license is at: http://www.latex-project.org/lppl.txt
25
26 This work is "maintained" (as per LPPL maintenance status)
27 by Will Robertson.
28
29 This work consists of the file hardwrap.dtx
30 and the derived files hardwrap.sty,
31 hardwrap.ins, and
32 hardwrap.pdf.
33
34 \endpostamble
35 \askforoverwritefalse
36 \generate{\file{hardwrap.sty}{\from{hardwrap.dtx}{package}}}
37 %</batchfile>
38 %<batchfile>\endbatchfile
39 %<*internal>
40 \generate{\file{hardwrap.ins}{\from{hardwrap.dtx}{batchfile}}}
41 \generate{\file{hardwrap.tests}{\from{hardwrap.dtx}{tests}}}
42 \generate{\file{hardwrap-test.tex}{\from{hardwrap.dtx}{testsuite,tests}}}
43 \def\tmpa{plain}
44 \ifx\tmpa\fmtname\endgroup\expandafter\bye\fi
45 \endgroup
46 %</internal>
47 %
48 % \begin{macrocode}
49 %<*driver>
50 \ProvidesFile{hardwrap.dtx}
51 %</driver>
52 %<package>\ProvidesPackage{hardwrap}
53 %<*package>
54 [2011/02/12 v0.2 Hard wrap messages]
55 %</package>
56 % \end{macrocode}
57 %
58 %<*driver>
59 \documentclass{ltxdoc}
60 \makeatletter
61 \renewcommand\meta@font@select{\rmfamily\itshape}
62
63 \usepackage[osf,sc]{mathpazo}
64 \usepackage{inconsolata}
65 \usepackage[scaled=0.83]{berasans}
66 \usepackage[T1]{fontenc}
67 \usepackage{textcomp}
68 \usepackage[final]{microtype}
69 \linespread{1.1}
70 \frenchspacing
71
72 \usepackage{geometry}
73 \geometry{b5paper}
74
75 \usepackage{qstest,hologo}
76
77 %%%%%
78 % See http://groups.google.com.au/group/comp.text.tex/msg/7588fd83dd9ce0ea
79
80 \usepackage{calc,framed}
81
82 \expandafter\newif\csname ifcontframe\endcsname
83
84 \newcommand*{\Fr@meSetup}{%
85 \global\contframefalse
86 \def\FrameCommand##1{%
87 \vbox{\FrameTitle{\Fr@meCurrent}\hbox{##1}}
88 \global\let\Fr@meCurrent\Fr@meNext
89 \ifcontframe
90 \global\let\Fr@meNext \macrotitlecont
91 \fi
92 \global\contframetrue}%
93 \global\let\Fr@meCurrent\macrotitle
94 \global\let\Fr@meNext\macrotitle}
95
96 \newcommand*{\FrameTitle}[1]{%
97 \nobreak \vskip -0.7\FrameSep
98 \rlap{\frametitle{#1}}\nobreak\nointerlineskip
99 \vskip 0.7\FrameSep}
100
101 \newcommand*{\frametitle}[1]{%
102 \parbox{\linewidth}{\footnotesize\strut#1}%
103 }%
104
105 \newenvironment{macroframe}{%
106 \Fr@meSetup
107 \MakeFramed{%
108 \advance\hsize-\width
109 \FrameRestore}}%
110 {\global\contframefalse
111 \endMakeFramed
112 }
113
114 \def\macrotitlecont{\macrotitleshort\space(\textit{cont.})}
115
116 \protected\def\framelabel#1{\texttt{\color{niceblue}#1}}
117
118 \def\macrotitle{}
119 \renewenvironment{macro}[1]{%
120 \@for\@ii:={{},#1}\do{%
121 \ifx\macrotitle\@empty
122 \let\macrotitle\@nil
123 \else\ifx\macrotitle\@nil
124 \edef\macrotitle{\framelabel{\detokenize\expandafter{\@ii}\unskip}}%
125 \edef\macrotitleone{\framelabel{\detokenize\expandafter{\@ii}\unskip}}%
126 \let \macrotitleshort \macrotitleone
127 \else
128 \edef\macrotitle{\macrotitle, \framelabel{\detokenize\expandafter{\@ii}\unskip}}%
129 \edef\macrotitleshort{\macrotitleone, etc.}%
130 \fi\fi
131 }
132 \begin{macroframe}
133 \noindent\ignorespaces
134 }{%
135 \end{macroframe}
136 }
137
138 \usepackage{titlesec}
139 \titleformat{\part}{\Large}{Part \thepart}{1em}{\scshape}
140 \titleformat{\section}{\smallskip\color{niceblue}}{\S\thesection}{1em}{}
141
142 \renewcommand\contentsname{}
143
144 \usepackage{tocloft,varwidth}
145 \setcounter{tocdepth}{1}
146 \def\tocwidthA{0.45}
147 \def\tocwidthB{0.5}
148 \renewcommand\cftpartfont{\scshape}
149 \renewcommand\cftsecfont{\small}
150 \renewcommand\cftsecpagefont{\small}
151 \renewcommand\cftpartpagefont{\normalsize}
152 \setlength\cftbeforepartskip{4pt}
153 \setlength\cftbeforesecskip{0pt}
154 \renewcommand\cftpartleader{}
155 \renewcommand\cftsecleader{}
156 \renewcommand\cftpartafterpnum{\cftparfillskip}
157 \renewcommand\cftsecafterpnum{\cftparfillskip}
158 \renewcommand\@cftmaketoctitle{\bigskip}
159
160 \newcommand\pretoc{{%
161 \addtocontents{toc}{%
162 \protect\noindent\protect\begin{varwidth}[t]{\tocwidthA\linewidth}%
163 }%
164 }}
165 \newcommand\splittoc{%
166 {\addtocontents{toc}{\protect\end{varwidth}\protect\hfill}}%
167 {\addtocontents{toc}{\protect\begin{varwidth}[t]{\protect\tocwidthB\protect\linewidth}}}%
168 }
169 \newcommand\posttoc{{\addtocontents{toc}{\protect\end{varwidth}\protect\par}}}
170
171 \usepackage{xcolor,hardwrap,lipsum,booktabs,fancyvrb,hypdoc}
172 \fvset{gobble=2}
173 \hypersetup{%
174 linktocpage,
175 linkcolor=niceblue,
176 anchorcolor=niceblue,
177 urlcolor=niceblue,
178 pdfauthor={Will Robertson and Kevin Godby}
179 }
180
181 % A few shorthand macros to ensure consistency
182 \newcommand{\email}[1]{$\langle$\href{mailto:#1}{#1}$\rangle$}
183 \usepackage{xspace}
184 \newcommand{\hairsp}{\kern1pt}% hair space
185 \let\latintext\relax% or \emph for italics
186 \newcommand*{\latinphrase}[1]{\latintext{#1}\@ifnextchar.{}{.\xspace}}
187 \newcommand*{\ie}{\latinphrase{i.\hairsp e\@}}% TODO search for and add comma if not found
188 \newcommand*{\eg}{\latinphrase{e.\hairsp g\@}}% TODO search for and add comma if not found
189 \newcommand*{\etc}{\latinphrase{etc}}
190 \newcommand*{\etal}{\latinphrase{et\,al}}
191
192 \newcommand*{\secref}[1]{\hyperref[#1]{section~}\ref{#1}}
193
194 % Hang the code line numbers in the margin
195 \def\macro@code{%
196 \topsep \MacrocodeTopsep
197 \@beginparpenalty \predisplaypenalty
198 \if@inlabel\leavevmode\fi
199 \trivlist \parskip \z@ \item[]%
200 \macro@font
201 \leftskip\@totalleftmargin% \advance\leftskip-\MacroIndent
202 \rightskip\z@ \parindent\z@ \parfillskip\@flushglue
203 \blank@linefalse \def\par{\ifblank@line
204 \leavevmode\fi
205 \blank@linetrue\@@par
206 \penalty\interlinepenalty}
207 \obeylines
208 \let\do\do@noligs \verbatim@nolig@list
209 \let\do\@makeother \dospecials
210 \global\@newlistfalse
211 \global\@minipagefalse
212 \ifcodeline@index
213 \everypar{\global\advance\c@CodelineNo\@ne
214 \llap{\theCodelineNo\ \hskip\@totalleftmargin}%
215 \check@module}%
216 \else \everypar{\check@module}%
217 \fi
218 \init@crossref}
219
220 \definecolor{niceblue}{rgb}{0.1,0.3,0.9}
221 \def\theCodelineNo{\textcolor{niceblue}{\sffamily\tiny\arabic{CodelineNo}}}
222 \newcommand*\pkg[1]{\textsf{#1}}
223 \newcommand*{\earg}[1]{{\ttfamily\char`\{}\texttt{#1}{\ttfamily\char`\}}}
224 \begin{document}
225 \DocInput{\jobname.dtx}
226 \end{document}
227 %</driver>
228 %
229 % \fi
230 %
231 % \errorcontextlines=999
232 % \makeatletter
233 %
234 % \GetFileInfo{\jobname.dtx}
235 %
236 % \title{The \pkg{\jobname} package}
237 % \author{Will Robertson\\ \normalsize\email{[email protected]} \and Kevin Godby\\\normalsize \email{[email protected]}}
238 % \date{\filedate \qquad \fileversion}
239 %
240 % \maketitle
241 %
242 % \begin{abstract}
243 % \noindent This package provides facilities for hard-wrapping text to a certain
244 % number of characters per line.
245 % The primary purpose is to make it easier for package authors to write
246 % readable informational messages to the console and log file;
247 % wrappers around \cs{PackageWarning} \etal\ are provided for this.
248 % \end{abstract}
249 %
250 % \tableofcontents
251 % \bigskip
252 %
253 % \pretoc
254 % \part{User documentation}
255 % \section{Introduction}
256 %
257 % The \pkg{\jobname} package provides a macro for word-wrapping text to a
258 % certain number of characters per line. In
259 % addition, helper macros are available for package and document class authors
260 % to use in automatically wrapping informational, warning, and error messages.
261 % This package requires \hologo{eTeX}.
262 %
263 % \section{Wrapping text}
264 %
265 % The main function provided by this package is the \cs{HardWrap} command,
266 % which takes five arguments.
267 % \begin{quote}
268 % \cs{HardWrap} \marg{function} \marg{width} \marg{setup code} \marg{newline} \marg{text}
269 % \end{quote}
270 % This command will wrap \meta{text} to a text block of \meta{width} characters
271 % wide, inserting \meta{newline} at the end of each line and processing the
272 % result with \meta{function}. The \meta{text} is fully expanded before being
273 % hard-wrapped; while doing so, the \meta{setup code} may be used to change
274 % local command definitions.
275 %
276 % Inside \meta{text}, you may use \verb|\\| to force a new line and \verb*|\ | to
277 % insert a space.
278 % A literal \verb|^^J| will also be treated as a forced \meta{newline}.
279 %
280 % Examples will be given in \secref{sec:examples}.
281 %
282 % \section{Wrapping log messages}
283 %
284 % A common use case for the \cs{HardWrap} macro is to format the
285 % informational, warning, and error messages that are printed to the terminal
286 % and log file. In support of this, we've provided a simple interface for
287 % package and document class authors to do this.
288 %
289 % \begin{quote}
290 % \cs{GenerateLogMacros}\earg{package}\oarg{prefix}\marg{package name}\\
291 % \cs{GenerateLogMacros}\earg{class}\texttt{\space \space}\oarg{prefix}\marg{class name}
292 % \end{quote}
293 % If the optional argument \meta{prefix} is not given, it is set equal to \meta{package name}.
294 % These two commands will generate the following macros:
295 %
296 % \begin{quote}
297 % \cs{\meta{prefix}@info}\marg{info}\\
298 % \cs{\meta{prefix}@info@noline}\marg{info}\\
299 % \cs{\meta{prefix}@warning}\marg{warning}\\
300 % \cs{\meta{prefix}@warning@noline}\marg{warning}\\
301 % \cs{\meta{prefix}@error}\marg{error}\marg{help}
302 % \end{quote}
303 %
304 % For instance, calling \cs{GenerateLogMacros}\earg{package}\earg{mypackage}
305 % will create macros called \cs{mypackage@info}, \cs{mypackage@warning}, \etc,
306 % which internally use \cs{PackageInfo}, \cs{PackageWarning}, and so on, to
307 % handle their respective messages.
308 % The arguments for the generated macros are the same as the arguments for
309 % \cs{PackageInfo}\marg{package name}, \cs{PackageWarning}\marg{package name}, \etc. Additionally, info messages may be printed with
310 % \cs{\meta{prefix}@info@noline} in which \LaTeX's
311 % `\texttt{on input line \meta{num}}' suffix is suppressed.
312 %
313 % The \cs{GenerateLogMacros}\earg{class} command instead generates analogous
314 % macros using \cs{ClassInfo}\marg{\rmfamily class name},
315 % \cs{ClassWarning}\marg{\rmfamily class name}, \etc.
316 %
317 % Note that no punctuation is added after messages, unlike standard \LaTeX.
318 % You are free to punctuate your messages as you wish.
319 %
320 % As with the \cs{HardWrap} command,
321 % \verb*|\ | and \verb|\\| are defined locally inside these messages to
322 % mean, respectively, \meta{space} and \meta{newline}.
323 %
324 % Additional redefinitions are stored in the macro \cs{HardWrapSetup}, which may
325 % be altered before executing \cs{GenerateLogMacro} to change the behaviour
326 % of the generated commands. By default, \cs{HardWrapSetup} is defined as
327 % \begin{Verbatim}
328 % \def\HardWrapSetup{%
329 % \def\MessageBreak{\\}%
330 % \def\newline{\\}%
331 % \def\emph##1{\string_##1\string_}%
332 % \def\textit##1{/##1/}%
333 % \def\textbf##1{*##1*}%
334 % }
335 % \end{Verbatim}
336 % The redefinitions for \cs{emph}, \cs{textit}, and \cs{textbf} are examples
337 % of the type of customisation you might like to perform.
338 %
339 % \section{Changing the line lengths}
340 %
341 % While \pkg{\jobname} attempts to determine the maximum line
342 % lengths based on where \TeX\ will wrap its console and log output,
343 % you may wish to override the value found using
344 % \cs{setmaxprintline}\marg{value}.
345 % This macro takes an integer value which is subsequently used by the
346 % commands generated with \cs{GenerateLogMacros} as the
347 % maximum line width allowed in the terminal output and log file. By default
348 % this value is~\texttt{79}.
349 %
350 % \section{Examples}
351 % \label{sec:examples}
352 %
353 % The command
354 % \begin{Verbatim}
355 % \HardWrap{\PackageWarning{foobar}}{50}{\HardWrapSetup}{\MessageBreak}{%
356 % Sed feugiat. Cum sociis natoque...;}
357 % \end{Verbatim}
358 % produces the following in the console output:
359 % \begin{Verbatim}[fontsize=\footnotesize]
360 % Package foobar Warning: Sed feugiat. Cum sociis natoque penatibus et magnis
361 % (foobar) dis parturient montes, nascetur ridiculus mus. Ut
362 % (foobar) pellentesque augue sed urna. Vestibulum diam eros,
363 % (foobar) fringilla et, consectetuer eu, nonummy id, sapien.
364 % (foobar) Nullam at lectus. In sagittis ultrices mauris.
365 % (foobar) Curabitur malesuada erat sit amet massa. Fusce
366 % (foobar) blandit. Aliquam erat volutpat. Aliquam euismod.
367 % (foobar) Aenean vel lectus. Nunc imperdiet justo nec
368 % (foobar) dolor; on input line 102.
369 % \end{Verbatim}
370 % Compare this to the following without the manual wrapping; \TeX\ breaks
371 % lines at 79 characters without keeping words together (\eg, `Vestibulum'
372 % broken between lines two and three):
373 % \begin{Verbatim}[fontsize=\footnotesize]
374 % Package foobar Warning: Sed feugiat. Cum sociis natoque penatibus et magnis dis
375 % parturient montes, nascetur ridiculus mus. Ut pellentesque augue sed urna. Ves
376 % tibulum diam eros, fringilla et, consectetuer eu, nonummy id, sapien. Nullam at
377 % lectus. In sagittis ultrices mauris. Curabitur malesuada erat sit amet massa.
378 % Fusce blandit. Aliquam erat volutpat. Aliquam euismod. Aenean vel lectus. Nunc
379 % imperdiet justo nec dolor; on input line 110.
380 % \end{Verbatim}
381 %
382 % The \cs{HardWrap} macro can also be useful when writing to an external file.
383 % For example, one may use:
384 % \begin{Verbatim}
385 % \newwrite\textfile
386 % \immediate\openout\textfile=\jobname.txt\relax
387 % \HardWrap{\immediate\write\textfile}{50}{\HardWrapSetup}{^^J}{%
388 % Sed feugiat. Cum sociis natoque...;}
389 % \closeout\textfile
390 % \end{Verbatim}
391 % to write the text to a file after being hard-wrapped with carriage returns (\verb|^^J|) after each line.
392 %
393 % \section{Support}
394 %
395 % Development and historical versions are available from GitHub at
396 % \url{http://github.com/wspr/hardwrap/}.
397 %
398 % Please report bugs and feature suggestions to the issue tracker at
399 % \url{http://github.com/wspr/hardwrap/issues}.
400 %
401 % \clearpage
402 % \splittoc
403 % \part{Implementation}
404 %
405 % Read on if you're curious what's behind the curtain.
406 %
407 % \begin{macrocode}
408 %<*package>
409 % \end{macrocode}
410 %
411 % \section{Preliminaries}
412 % \begin{macrocode}
413 \IfFileExists{ifplatform.sty}{%
414 \RequirePackage{ifplatform}
415 }{%
416 \newif\ifwindows
417 \IfFileExists{/dev/null}{\windowsfalse}{\windowstrue}
418 }
419 % \end{macrocode}
420 %
421 % \begin{macrocode}
422 \IfFileExists{pdftexcmds.sty}{%
423 \RequirePackage{pdftexcmds}
424 }{%
425 \def\pdf@shellescape{\pdfshellescape}
426 }
427 % \end{macrocode}
428 %
429 % \begin{macrocode}
430 \RequirePackage{ifxetex}
431 % \end{macrocode}
432 %
433 % \begin{macro}{\hw@charcount,\hw@wordcount}
434 % These counters hold, respectively, the number of characters on the current
435 % line and the number of characters in the current word.
436 % \begin{macrocode}
437 \newcount\hw@charcount
438 \newcount\hw@wordcount
439 % \end{macrocode}
440 % \end{macro}
441 %
442 % \begin{macro}{\hw@currtext,\hw@currline,\hw@currword}
443 % The following are local variables to store the current contents of the wrapped text, line, and word.
444 % \begin{macrocode}
445 \def\hw@currtext{}
446 \def\hw@currline{}
447 \def\hw@currword{}
448 % \end{macrocode}
449 % \end{macro}
450 %
451 % \begin{macro}{\hw@protected@newline}
452 % This macro is called each time a line break is created. It typically holds
453 % \cs{MessageBreak} for log messages, but could be set to \cs{\char`\\} for typeset
454 % text.
455 % \begin{macrocode}
456 \protected\def\hw@protected@newline{}
457 % \end{macrocode}
458 % \end{macro}
459 %
460 % \begin{macro}{\hw@protected@space,\hw@expanding@space}
461 % The \cmd\hw@protected@space\ definition of `space' is designed to be switched for a real space later on using \cmd \hw@expanding@space, which is also inserted into scratch variables as the `real' space char.
462 % \begin{macrocode}
463 \protected\def\hw@protected@space{ }
464 \let\hw@expanding@space\space
465 % \end{macrocode}
466 % \end{macro}
467 %
468 % \begin{macro}{\hw@insert@newline}
469 % This is a placeholder to show where manual newlines are inserted.
470 % (It will never be executed.)
471 % \begin{macrocode}
472 \protected\def\hw@insert@newline{\hw@insert@newline}
473 % \end{macrocode}
474 % \end{macro}
475 %
476 % \begin{macro}{\hw@scanstop}
477 % This is a `quark' from expl3 designed to delimit scanning; it will never be executed, else an infinite loop results.
478 % \begin{macrocode}
479 \protected\def\hw@scanstop{\hw@scanstop}
480 % \end{macrocode}
481 % \end{macro}
482 %
483 % \section{Utility macros}
484 %
485 % \begin{macro}{\hw@strlen,\hw@strlen@of}
486 % A simple string-length macro.
487 % \cs{hw@strlen}\marg{token list} is the number of tokens (or brace groups) of its \meta{token list} argument without expansion.
488 % \begin{macrocode}
489 \def\hw@strlen#1{%
490 \numexpr0\hw@Ncharscan#1\hw@scanstop\relax
491 }
492 \def\hw@Ncharscan#1{%
493 \ifx#1\hw@scanstop
494 \expandafter\@gobble
495 \else
496 \expandafter\@firstofone
497 \fi
498 {+1\hw@Ncharscan}%
499 }
500 % \end{macrocode}
501 % Variant \cs{hw@strlen@of}\meta{macro} is the number of tokens (or brace groups) of the contents of its \meta{macro} argument.
502 % \begin{macrocode}
503 \def\hw@strlen@of#1{%
504 \expandafter\hw@strlen\expandafter{#1}%
505 }
506 % \end{macrocode}
507 % \end{macro}
508 %
509 % \begin{macro}{\hw@maxprintline}
510 % Some code to detect \TeX's \textit{max\_print\_line} value.
511 % This only works for \hologo{pdfTeX} in \TeX{} Live.
512 % \begin{macrocode}
513 \newcount\hw@maxprintline
514 \ifluatex\else
515 \ifxetex\else
516 \ifwindows\else
517 \ifnum\pdf@shellescape>0\relax
518 \hw@maxprintline=\@@input"|kpsewhich -var-value=max_print_line"\relax
519 \fi
520 \fi
521 \fi
522 \fi
523 % \end{macrocode}
524 % In the non-unlikely chance the correct value cannot be determined, the usual default is assumed. This value will rarely, if ever, be different to the default, so assuming this number is very safe.
525 % \begin{macrocode}
526 \ifnum\hw@maxprintline=0\relax
527 \hw@maxprintline=79\relax % default
528 \fi
529 % \end{macrocode}
530 % \end{macro}
531 %
532 % \begin{macro}{\setmaxprintline}
533 % In case the code above borks the \cs{hw@maxprintline} value, the user can set it manually with the \cs{setmaxprintline} macro.
534 % \begin{macrocode}
535 \newcommand*{\setmaxprintline}[1]{%
536 \hw@maxprintline=#1\relax
537 }
538 % \end{macrocode}
539 % \end{macro}
540 %
541 %
542 % \section{Main procedure}
543 %
544 % The idea for hard-wrapping the text is to assume we can fully expand the
545 % argument and then iterate character-by-character over the message inserting
546 % \meta{newline} commands where appropriate. The steps are:
547 % \begin{enumerate}
548 % \item Make local redefinitions for general commands, including special
549 % placeholders for \meta{space} and \meta{newline}.
550 % \item Fully expand the text-to-be-wrapped with appropriate definitions of
551 % \cs{protect} and \cs{noexpand} so the resultant text can be assumed to
552 % completely `safe' to scan over (and continue expanding) but \emph{without}
553 % removing important macro placeholders for \meta{space} and \meta{newline}.
554 % \item Then scan character by character. Whenever a space is found, check the
555 % last word length and either append the word to the current line if it will
556 % fit, or start a new line with a forced line break represented by another
557 % special placeholder macro. Spaces are represented with placeholders so
558 % multiple spaces don't collapse according to \TeX's usual space-handling
559 % rules.
560 % \item Finally process the wrapped text with appropriate meanings for the
561 % placeholder macros.
562 % \end{enumerate}
563 %
564 % \begin{macro}{\HardWrap}
565 % Here's the main command that implements the steps outlined above.
566 % Arguments:
567 % \begin{enumerate}\parskip=0pt\itemsep=0pt
568 % \item \marg{function}
569 % \item \marg{chars to wrap to}
570 % \item \marg{setup}
571 % \item \marg{newline}
572 % \item \marg{text}
573 % \end{enumerate}
574 % This is the macro that does everything.
575 % Note that the \cs{space} is first made `protected' and then restored again.
576 % \begin{macrocode}
577 \newcommand*\HardWrap[5]{%
578 \begingroup
579 \hw@maxprintline=\numexpr#2\relax
580 % \end{macrocode}
581 % Replacements for user commands:
582 % \begin{macrocode}
583 \let\space\hw@protected@space
584 \def\ {\space}%
585 \let\\\hw@insert@newline
586 % \end{macrocode}
587 % To avoid problems with repeated edef with arbitrary csnames:
588 % \begin{macrocode}
589 \let\noexpand\string
590 % \end{macrocode}
591 % Execute the custom setup, and then fully expand the text
592 % to be wrapped, turning \cs{protect}ed macros into strings.
593 % (Fully \cs{protected} macros will still be actual control sequences
594 % at this point.)
595 % \begin{macrocode}
596 \begingroup
597 #3%
598 \let\protect\string
599 \xdef\@tempa{#5}%
600 \endgroup
601 % \end{macrocode}
602 % Now scan over the text token by token, transforming it into an
603 % intermediate representation of fully wrapped text.
604 % Then fully expand this intermediate form into its final form,
605 % ready to be processed by the input function \verb|#1|.
606 % \begin{macrocode}
607 \expandafter\hw@scan\@tempa\hw@scanstop
608 \def\\{\hw@protected@newline}%
609 \def\hw@protected@newline{#4}%
610 \let\space\hw@expanding@space
611 \@temptokena={#1}%
612 \expandafter\the\expandafter\@temptokena\expandafter{\hw@wrappedtext}%
613 \endgroup
614 }
615 % \end{macrocode}
616 % \end{macro}
617 %
618 % \begin{macro}{\hw@scan}
619 % Convenience wrapper for \cs{futurelet}.
620 % \begin{macrocode}
621 \def\hw@scan{%
622 \futurelet\let@token\hw@process
623 }
624 % \end{macrocode}
625 % \end{macro}
626 %
627 % \begin{macro}{\hw@process}
628 % The \cs{hw@process} macro contains the actual word-wrapping algorithm.
629 % The text is scanned token by token. Each token falls into one of five
630 % categories: (1)~the stop token \cs{hw@scanstop}, (2)~a space token,
631 % (3)~a newline insertion, (4)~an opening brace, or (5)~anything else.
632 %
633 % \begin{enumerate}
634 % \item
635 % If we encounter the \cs{hw@scanstop} token, then we've hit the end of the
636 % string. Swallow the stop token and stop processing.
637 % \item
638 % If we find a space, add the word to the current line if it fits, otherwise
639 % insert a line break and put the word on its own line. Continue reading tokens.
640 % \item
641 % If we find an explicit `newline', we process it much as if it were a space and
642 % the current word is the last one that can fit on the line.
643 % To continue, skip the actual token that is the `newline' and then start scanning again.
644 % \item
645 % If we find an opening brace \verb|{|, we read in the entire brace group, and then
646 % re-insert it in the scanner surrounded with brace-strings. I.e., braces are printed
647 % in the output.
648 % \item
649 % If the token doesn't fall into one of the above special cases, we'll just append it to
650 % the current word and continue reading tokens.
651 % \end{enumerate}
652 % \begin{macrocode}
653 \def\hw@process{%
654 \ifx\let@token\hw@scanstop\relax
655 \hw@process@end
656 \let\next\@gobble
657 \else\ifx\let@token\@sptoken
658 \hw@process@space
659 \def\next{\afterassignment\hw@scan\let\@tempa= }%
660 \else\ifx\let@token\hw@insert@newline
661 \hw@process@messagebreak
662 \def\next{\expandafter\hw@scan\@gobble}%
663 \else\ifx\let@token^^J
664 \hw@process@messagebreak
665 \def\next{\expandafter\hw@scan\@gobble}%
666 \else\ifx\let@token\bgroup
667 \def\next{\expandafter\hw@dochar\hw@process@group}%
668 \else
669 \let\next\hw@dochar
670 \fi\fi\fi\fi\fi
671 \next
672 }
673 % \end{macrocode}
674 % \end{macro}
675 %
676 % \begin{macro}{\hw@dochar}
677 % After a letter, the \cs{hw@dochar} macro just appends a token (non-space and non-stop token) to the current word.
678 % \begin{macrocode}
679 \def\hw@dochar#1{%
680 \edef\hw@currword{\hw@currword #1}%
681 \hw@scan
682 }
683 % \end{macrocode}
684 % \end{macro}
685 %
686 % \begin{macro}{\hw@process@space}
687 % \begin{macrocode}
688 \def\hw@process@space{%
689 \hw@wordcount=\hw@strlen@of\hw@currword\relax
690 \ifnum\numexpr(\hw@charcount+\hw@wordcount)\relax<\hw@maxprintline
691 \advance\hw@charcount by \hw@wordcount
692 \ifx\hw@currline\@empty
693 \edef\hw@currline{\hw@currword}%
694 \else
695 \advance\hw@charcount by 1\relax % account for the space character
696 \edef\hw@currline{\hw@currline\hw@expanding@space\hw@currword}%
697 \fi
698 \else
699 \hw@charcount=\hw@wordcount\relax
700 \edef\hw@currtext{\hw@currtext\hw@currline\hw@protected@newline}%
701 \let\hw@currline\hw@currword
702 \fi
703 \let\hw@currword\@empty
704 }
705 % \end{macrocode}
706 % \end{macro}
707 %
708 % \begin{macro}{\hw@process@messagebreak}
709 % \begin{macrocode}
710 \def\hw@process@messagebreak{%
711 \hw@wordcount=\hw@strlen@of\hw@currword\relax
712 \ifnum\numexpr(\hw@charcount+\hw@wordcount)<\hw@maxprintline
713 \edef\hw@currtext{%
714 \hw@currtext
715 \ifx\hw@currline\@empty\else
716 \hw@currline\space
717 \fi
718 \hw@currword\hw@protected@newline
719 }%
720 \hw@charcount=0\relax
721 \let\hw@currline\@empty
722 \else
723 \edef\hw@currtext{\hw@currtext\hw@currline\hw@protected@newline}%
724 \hw@charcount=\hw@wordcount
725 \let\hw@currline\hw@currword
726 \fi
727 \let\hw@currword\@empty
728 }
729 % \end{macrocode}
730 % \end{macro}
731 %
732 % \begin{macro}{\hw@process@end}
733 % The final stage of processing the text. We've just come to the end of the final
734 % word on the final line: add the word to the current line if it fits, otherwise insert a line
735 % break and put the word on its own line.
736 % \begin{macrocode}
737 \def\hw@process@end{%
738 \hw@wordcount=\hw@strlen@of\hw@currword\relax
739 \ifnum\numexpr(\hw@charcount+\hw@wordcount)<\hw@maxprintline
740 \edef\hw@wrappedtext{%
741 \hw@currtext
742 \ifx\hw@currline\@empty\else
743 \hw@currline\space
744 \fi
745 \hw@currword
746 }%
747 \else
748 \edef\hw@wrappedtext{%
749 \hw@currtext\hw@currline\hw@protected@newline\hw@currword
750 }%
751 \fi
752 }
753 % \end{macrocode}
754 % \end{macro}
755 %
756 % \begin{macro}{\hw@process@group}
757 % If a brace group is found, we read it as an argument and then surround it with brace strings
758 % (\ie, braces are printed).
759 % \begin{macrocode}
760 \edef\hw@process@group#1{%
761 \expandafter\@gobble\string\{%
762 #1%
763 \expandafter\@gobble\string\}%
764 }
765 % \end{macrocode}
766 % \end{macro}
767 %
768 % \begin{macro}{\HardWrapSetup}
769 % This is the command to use if you want to `special-case' some meanings to be more appropriate inside message text. When using \cs{GenerateLogMacros}, it is used by default for argument \verb|#3| in \cs{HardWrap}.
770 % \begin{macrocode}
771 \def\HardWrapSetup{%
772 \def\MessageBreak{\\}%
773 \def\newline{\\}%
774 \def\emph##1{\string_##1\string_}%
775 \def\textit##1{/##1/}%
776 \def\textbf##1{*##1*}%
777 }
778 % \end{macrocode}
779 % \end{macro}
780 %
781 % \section{Wrapping log messages}
782 %
783 % \begin{samepage}
784 % \LaTeX{} informational, warning, and error messages are printed in the
785 % format:
786 % \begin{center}
787 % \ttfamily\small
788 % \begin{tabular}{l@{\space}l}
789 % Package \meta{pkgname} Info: & This is an informational message.\\
790 % (\meta{pkgname}) & That spans multiple lines. The\\
791 % (\meta{pkgname}) & \string\MessageBreak\space macro is used to split\\
792 % (\meta{pkgname}) & the text across lines.\\
793 % \leftarrowfill$A$\rightarrowfill & \leftarrowfill$B$\rightarrowfill\\
794 % \multicolumn{2}{c}{\leftarrowfill$\textrm{\textit{max\_print\_line}}$\rightarrowfill}
795 % \end{tabular}
796 % \end{center}
797 % \end{samepage}
798 % The maximum line length ($\textit{max\_print\_line}$) is used by
799 % \TeX{} for all log file and terminal output. It defaults to 79 characters
800 % but may be changed by editing the \texttt{texmf.cnf} file.
801 %
802 % The length of $A$ is the sum of three values:
803 % \begin{enumerate}
804 % \item whether it's a class or package message: add 6 for class messages,
805 % and 8 for package messages;
806 % \item the length of the package name;
807 % \item the type of message: information (add 7), warning (add 10), or error
808 % (add~10).
809 % \end{enumerate}
810 % The length of $B$ is the difference between $\textit{max\_print\_line}$ and
811 % $A$ plus one for the extra space between them.
812 % Note that the length of $B$ for the warning and error text is the same.
813 %
814 % \begin{macro}{\hw@suffix}
815 % This string is used as a suffix to \LaTeX\ warnings and info messages
816 % to push the automatic `on input line \meta{num}' onto the next line.
817 % This makes writing grammatically correct messages somewhat easier.
818 % \begin{macrocode}
819 \newcommand\hw@suffix{^^JThis message occurred}
820 % \end{macrocode}
821 % \end{macro}
822 %
823 % \begin{macro}{\GenerateLogMacros}
824 % Shortcuts are provided for generating logging macros that automatically wrap
825 % the text provided to them. The \cs{GeneratePackageLogMacros} and
826 % \cs{GenerateClassLogMacros} calculate the various lengths of $B$
827 % appropriately.
828 % \begin{macrocode}
829 \newcommand\GenerateLogMacros[1]{%
830 \lowercase{\def\hw@tempa{#1}}%
831 \def\hw@tempb{package}%
832 \ifx\hw@tempa\hw@tempb
833 \expandafter\GeneratePackageLogMacros
834 \else
835 \def\hw@tempb{class}%
836 \ifx\hw@tempa\hw@tempb
837 \expandafter\expandafter\expandafter\GenerateClassLogMacros
838 \else
839 \PackageError{hardwrap}{\MessageBreak
840 \string\GenerateLogMacros\space only accepts "package"
841 \MessageBreak or "class" types%
842 }{%
843 E.g., \detokenize{\GenerateLogMacros{package}[HW]{hardwrap}}%
844 }%
845 \fi
846 \fi
847 }
848 % \end{macrocode}
849 % \end{macro}
850 %
851 % \begin{macro}{\GeneratePackageLogMacros,\GenerateClassLogMacros}
852 % \begin{macrocode}
853 \newcommand{\GeneratePackageLogMacros}[2][]{%
854 \hw@generate@logging@macros{package}{#1}{#2}%
855 {\hw@maxprintline-\hw@strlen{#2}-16}% info length
856 {\hw@maxprintline-\hw@strlen{#2}-19}% warning length
857 }
858 % \end{macrocode}
859 %
860 % \begin{macrocode}
861 \newcommand{\GenerateClassLogMacros}[2][]{%
862 \hw@generate@logging@macros{class}{#1}{#2}%
863 {\hw@maxprintline-\hw@strlen{#2}-14}% info length
864 {\hw@maxprintline-\hw@strlen{#2}-17}% warning length
865 }
866 % \end{macrocode}
867 % \end{macro}
868 %
869 % \begin{macro}{\hw@generate@logging@macros}
870 % And now for the code that generates all the logging macros. Arguments:
871 % \begin{enumerate}\itemsep=0pt\parskip=0pt\parsep=0pt
872 % \item \marg{`package' or `class'}
873 % \item \marg{prefix}
874 % \item \marg{package name}
875 % \item \marg{info message length}
876 % \item \marg{warning message length}
877 % \end{enumerate}
878 % The \meta{info\dots} and \meta{warning message length} values correspond to
879 % the calculation of $B$ as described above.
880 %
881 % First of all, if the \meta{prefix} is not specified then fall back to the \meta{package name}:
882 % \begin{macrocode}
883 \newcommand{\hw@generate@logging@macros}[5]{%
884 \def\@tempa{#2}\ifx\@tempa\@empty
885 \hw@generate@logging@macros@aux{#1}{#3}{#3}{#4}{#5}%
886 \else
887 \hw@generate@logging@macros@aux{#1}{#2}{#3}{#4}{#5}%
888 \fi
889 }
890 % \end{macrocode}
891 % Finally, the main procedure. Info messages first:
892 % \begin{macrocode}
893 \newcommand{\hw@generate@logging@macros@aux}[5]{%
894 \expandafter\edef\csname #2@info\endcsname##1{%
895 \noexpand\HardWrap
896 {\@nameuse{hw@#1@info}{#3}}
897 {\number\numexpr#4\relax}
898 {\unexpanded\expandafter{\HardWrapSetup}}
899 {\noexpand\MessageBreak}
900 {##1}%
901 }%
902 \expandafter\edef\csname #2@info@noline\endcsname##1{%
903 \noexpand\HardWrap
904 {\@nameuse{hw@#1@info@noline}{#3}}
905 {\number\numexpr#4\relax}
906 {\unexpanded\expandafter{\HardWrapSetup}}
907 {\noexpand\MessageBreak}
908 {##1}%
909 }%
910 % \end{macrocode}
911 % Now warnings:
912 % \begin{macrocode}
913 \expandafter\edef\csname #2@warning\endcsname##1{%
914 \noexpand\HardWrap
915 {\@nameuse{hw@#1@warning}{#3}}
916 {\number\numexpr#5\relax}
917 {\unexpanded\expandafter{\HardWrapSetup}}
918 {\noexpand\MessageBreak}
919 {##1}%
920 }%
921 \expandafter\edef\csname #2@warning@noline\endcsname##1{%
922 \noexpand\HardWrap
923 {\@nameuse{hw@#1@warning@noline}{#3}}
924 {\number\numexpr#5\relax}
925 {\unexpanded\expandafter{\HardWrapSetup}}
926 {\noexpand\MessageBreak}
927 {##1}%
928 }%
929 % \end{macrocode}
930 % And finally errors.
931 %
932 % In addition to the \meta{info} and \meta{warning} lengths,
933 % the \cs{PackageError} macro allows for
934 % additional text to be displayed when the user requests it. This text
935 % doesn't have anything prepended to each line, so the length of this text is
936 % the same as $\textit{max\_print\_line}$.
937 % \begin{macrocode}
938 \expandafter\edef\csname #2@error\endcsname##1##2{%
939 \noexpand\HardWrap
940 {\xdef\noexpand\hw@tempa}
941 {\number\numexpr#5\relax}
942 {\unexpanded\expandafter{\HardWrapSetup}}
943 {\MessageBreak}
944 {\MessageBreak ##1}%
945 \noexpand\HardWrap
946 {\xdef\noexpand\hw@tempb}
947 {\the\hw@maxprintline}
948 {\unexpanded\expandafter{\HardWrapSetup}}
949 {\MessageBreak}
950 {\MessageBreak ##2}%
951 \unexpanded{%
952 \@nameuse{hw@#1@error}{#3}{\hw@tempa}{\hw@tempb}%
953 }%
954 }%
955 }
956 % \end{macrocode}
957 % Here are our wrappers for \cs{ClassInfo} \etal, which are
958 % used above to generalise the code a little. Note that these macros are
959 % \cs{protected}, which allows them to be used in an expanding context
960 % without a preceding \cs{noexpand}.
961 % \begin{macrocode}
962 \protected\def\hw@class@info #1#2{\ClassInfo {#1}{#2\hw@suffix}}
963 \protected\def\hw@class@info@noline #1#2{\ClassInfo {#1}{#2\@gobbletwo}}
964 \protected\def\hw@class@warning #1#2{\ClassWarning{#1}{#2\hw@suffix}}
965 \protected\def\hw@class@warning@noline#1#2{\ClassWarning{#1}{#2\@gobbletwo}}
966 \protected\def\hw@class@error #1#2{\ClassError {#1}{#2\@gobble}}
967 % \end{macrocode}
968 % And package messages:
969 % \begin{macrocode}
970 \protected\def\hw@package@info #1#2{\PackageInfo {#1}{#2\hw@suffix}}
971 \protected\def\hw@package@info@noline #1#2{\PackageInfo {#1}{#2\@gobbletwo}}
972 \protected\def\hw@package@warning #1#2{\PackageWarning{#1}{#2\hw@suffix}}
973 \protected\def\hw@package@warning@noline#1#2{\PackageWarning{#1}{#2\@gobbletwo}}
974 \protected\def\hw@package@error #1#2{\PackageError {#1}{#2\@gobble}}
975 % \end{macrocode}
976 % \end{macro}
977 %
978 % \begin{macrocode}
979 %</package>
980 % \end{macrocode}
981 %
982 % \part{Test suite}
983 %
984 % {\catcode`\%=14\input{hardwrap.tests}}
985 %
986 % \begin{macrocode}
987 %<testsuite>\documentclass{article}
988 %<testsuite>\usepackage{hardwrap,qstest}
989 %<testsuite>\begin{document}
990 %<*tests>
991 % \end{macrocode}
992 %
993 % \begin{macrocode}
994 \gdef\LIPSUM{Lorem ipsum dolor sit amet, consectetuer
995 adipiscing elit. Ut purus elit, vestibulum ut, placerat ac,
996 adipiscing vitae, felis. Curabitur dictum gravida mauris. Nam arcu
997 libero, nonummy eget, consectetuer id, vulputate a, magna. Donec
998 vehicula augue eu neque.}
999 % \end{macrocode}
1000 %
1001 % \begin{macrocode}
1002 \begin{qstest}{basics}{}
1003 \HardWrap{\xdef\TMP}{50}{}{NEWLINE}{aaa bbb ccc}
1004 \Expect*{\TMP}{aaa bbb ccc}
1005 \end{qstest}
1006 % \end{macrocode}
1007 %
1008 % \begin{macrocode}
1009 \begin{qstest}{newline}{}
1010 \HardWrap{\xdef\TMP}{50}{}{NEWLINE}{aaa \\ bbb ccc}
1011 \Expect*{\TMP}{aaa NEWLINEbbb ccc}
1012 \end{qstest}
1013 % \end{macrocode}
1014 %
1015 % \begin{macrocode}
1016 \begin{qstest}{noexpand/protect/string}{}
1017 \HardWrap{\xdef\TMP}{100}{}{NEWLINE}{%
1018 \string\section\ and \protect\subsection\
1019 and \noexpand\paragraph\ and the rest}
1020 \Expect*{\TMP}
1021 *{\string\section\space and \string\subsection\space
1022 and \string\paragraph\space and the rest}
1023 \end{qstest}
1024 % \end{macrocode}
1025 %
1026 % \begin{macrocode}
1027 \begin{qstest}{ensure no wayward spaces}{}
1028 \newbox\myboxa
1029 \newbox\myboxb
1030 \setbox\myboxa=\hbox{xx}
1031 \setbox\myboxb=\hbox{x%
1032 \HardWrap{\xdef\TMP}{50}{}{NEWLINE}{\LIPSUM}%
1033 x}
1034 \Expect*{\the\wd\myboxa}*{\the\wd\myboxb}
1035 \end{qstest}
1036 % \end{macrocode}
1037 %
1038 % \begin{macrocode}
1039 \begin{qstest}{deal with explicit newlines}{}
1040 \HardWrap{\xdef\TMP}{50}{}{NEWLINE}{aaa bbb^^Jccc}%
1041 \Expect*{\TMP}
1042 *{aaa bbbNEWLINEccc}
1043 \end{qstest}
1044 % \end{macrocode}
1045 %
1046 % \begin{macrocode}
1047 \begin{qstest}{print braces properly}{}
1048 \begingroup
1049 \escapechar=-1
1050 \xdef\EXPECT{a bb ccc dddd\string\{ eeeeeNEWLINEffffff\string\} ggggg hhhh}
1051 \endgroup
1052 \HardWrap{\xdef\TMP}{20}{}{NEWLINE}{a bb ccc dddd{ eeeee ffffff} ggggg hhhh}%
1053 \Expect*{\TMP}*{\EXPECT}
1054 \end{qstest}
1055 % \end{macrocode}
1056 %
1057 % \begin{macrocode}
1058 \begin{qstest}{print braces properly II}{}
1059 \begingroup
1060 \escapechar=-1
1061 \xdef\EXPECT{a bb ccc dddd\string\{ eeeeeNEWLINEffffff \string\}ggggg hhhh}
1062 \endgroup
1063 \HardWrap{\xdef\TMP}{20}{}{NEWLINE}{a bb ccc dddd{ eeeee ffffff }ggggg hhhh}%
1064 \Expect*{\TMP}*{\EXPECT}
1065 \end{qstest}
1066 % \end{macrocode}
1067 %
1068 % \begin{macrocode}
1069 \begin{qstest}{print braces properly III}{}
1070 \begingroup
1071 \escapechar=-1
1072 \xdef\EXPECT{a bb ccc dddd \string\{eeeeeNEWLINEffffff\string\} ggggg hhhh}
1073 \endgroup
1074 \HardWrap{\xdef\TMP}{20}{}{NEWLINE}{a bb ccc dddd {eeeee ffffff} ggggg hhhh}%
1075 \Expect*{\TMP}*{\EXPECT}
1076 \end{qstest}
1077 % \end{macrocode}
1078 %
1079 % \begin{macrocode}
1080 \begin{qstest}{trailing newline bug}{}
1081 \HardWrap{\xdef\TMP}{20}{}{N}{a\\b\\c\\}%
1082 \Expect*{\TMP}*{aNbNcN}
1083 \end{qstest}
1084 % \end{macrocode}
1085 %
1086 % \GenerateLogMacros{package}[HW]{hardwrap}
1087 % \GenerateLogMacros{class}[HWC]{hardwrap}
1088 % ^^A\HW@error{Please ignore this error!\\ I'm only testing things out.}{(Go away.)}
1089 % \HW@info{\LIPSUM}
1090 % \HWC@info@noline{\LIPSUM}
1091 % \HW@warning{\LIPSUM}
1092 % \HWC@warning@noline{\LIPSUM}
1093 % \HW@warning{Terminal spaces\MessageBreak used to\\ cause an infinite loop! No more }
1094 % \HW@warning{\space Testing\space\space\space spaces.\space}
1095 % \HW@warning{Hello!\MessageBreak This is an example of the hardwrap logging macro. Lets hope that it works properly and wrap our text to just the right length. (These words should reach all the way until the end of TeX's hard-wrapped log file output.) If not, panic!}
1096 %
1097 % \typeout{Note that if we're inserting manual line breaks, we can only reach column 78:}
1098 % \typeout{123456789012345678901234567890123456789012345678901234567890123456789012345678^^J123}
1099 % \typeout{1234567890123456789012345678901234567890123456789012345678901234567890123456789^^J123}
1100 %
1101 % \HW@info{Testing}
1102 %
1103 %
1104 % \HardWrap{\PackageWarning{foobar}}{50}{\HardWrapSetup}{\MessageBreak}{^^A
1105 % Sed feugiat. Cum sociis natoque penatibus et
1106 % magnis dis parturient montes, nascetur ridiculus mus. Ut
1107 % pellentesque augue sed urna. Vestibulum diam eros, fringilla et,
1108 % consectetuer eu, nonummy id, sapien. Nullam at lectus. In sagittis
1109 % ultrices mauris. Curabitur malesuada erat sit amet massa. Fusce
1110 % blandit. Aliquam erat volutpat. Aliquam euismod. Aenean vel lectus.
1111 % Nunc imperdiet justo nec dolor;}
1112 %
1113 % \PackageWarning{foobar}{^^A
1114 % Sed feugiat. Cum sociis natoque penatibus et
1115 % magnis dis parturient montes, nascetur ridiculus mus. Ut
1116 % pellentesque augue sed urna. Vestibulum diam eros, fringilla et,
1117 % consectetuer eu, nonummy id, sapien. Nullam at lectus. In sagittis
1118 % ultrices mauris. Curabitur malesuada erat sit amet massa. Fusce
1119 % blandit. Aliquam erat volutpat. Aliquam euismod. Aenean vel lectus.
1120 % Nunc imperdiet justo nec dolor;}
1121 % \newwrite\textfile
1122 % \immediate\openout\textfile=\jobname.txt\relax
1123 % \HardWrap{\immediate\write\textfile}{50}{\HardWrapSetup}{^^J}{%
1124 % Sed feugiat. Cum sociis natoque penatibus et
1125 % magnis dis parturient montes, nascetur ridiculus mus. Ut
1126 % pellentesque augue sed urna. Vestibulum diam eros, fringilla et,
1127 % consectetuer eu, nonummy id, sapien. Nullam at lectus. In sagittis
1128 % ultrices mauris. Curabitur malesuada erat sit amet massa. Fusce
1129 % blandit. Aliquam erat volutpat. Aliquam euismod. Aenean vel lectus.
1130 % Nunc imperdiet justo nec dolor.}
1131 % \closeout\textfile
1132 %
1133 % \begin{macrocode}
1134 %</tests>
1135 %<testsuite>\end{document}
1136 % \end{macrocode}
1137 %
1138 % \Finale
1139 %
1140 % \posttoc
1141 %
1142 % \typeout{*************************************************************}
1143 % \typeout{*}
1144 % \typeout{* To finish the installation you have to move the following}
1145 % \typeout{* file into a directory searched by TeX:}
1146 % \typeout{*}
1147 % \typeout{* \space\space\space hardwrap.sty}
1148 % \typeout{*}
1149 % \typeout{*************************************************************}
1150 %
1151 \endinput
1152