From ec47c1b7880fd4f626f8aa8377e576e03d72c24f Mon Sep 17 00:00:00 2001
From: Karl Berry <karl@freefriends.org>
Date: Mon, 25 Oct 2010 23:10:59 +0000
Subject: new latex package parselines (25oct10)

git-svn-id: svn://tug.org/texlive/trunk@20205 c570f23f-e606-0410-a88d-b1316a301751
---
 .../source/latex/parselines/parselines.dtx         | 592 +++++++++++++++++++++
 1 file changed, 592 insertions(+)
 create mode 100644 Master/texmf-dist/source/latex/parselines/parselines.dtx

(limited to 'Master/texmf-dist/source/latex/parselines/parselines.dtx')

diff --git a/Master/texmf-dist/source/latex/parselines/parselines.dtx b/Master/texmf-dist/source/latex/parselines/parselines.dtx
new file mode 100644
index 00000000000..9bc64200590
--- /dev/null
+++ b/Master/texmf-dist/source/latex/parselines/parselines.dtx
@@ -0,0 +1,592 @@
+% \iffalse meta-comment
+% parselines : 2010/10/23 v1.1 - parselines : a simple line parser for TeX]
+%
+% This work may be distributed and/or modified under the
+% conditions of the LaTeX Project Public License, either
+% version 1.3 of this license or (at your option) any later
+% version. The latest version of this license is in
+%    http://www.latex-project.org/lppl.txt
+%
+% This work consists of the main source file parselines.dtx
+% and the derived files
+%    parselines.sty, parselines.pdf, parselines.ins
+%
+% Unpacking:
+%    (a) If parselines.ins is present:
+%           etex parselines.ins
+%    (b) Without parselines.ins:
+%           etex parselines.dtx
+%    (c) If you insist on using LaTeX
+%           latex \let\install=y\input{parselines.dtx}
+%        (quote the arguments according to the demands of your shell)
+%
+% Documentation:
+%           (pdf)latex parselines.dtx
+% Copyright (C) 2010 by Florent Chervet <florent.chervet@free.fr>
+%<*ignore>
+\begingroup
+  \def\x{LaTeX2e}%
+\expandafter\endgroup
+\ifcase 0\ifx\install y1\fi\expandafter
+         \ifx\csname processbatchFile\endcsname\relax\else1\fi
+         \ifx\fmtname\x\else 1\fi\relax
+\else\csname fi\endcsname
+%</ignore>
+%<*install>
+\input docstrip.tex
+\Msg{************************************************************************}
+\Msg{* Installation}
+\Msg{* Package: 2010/10/23 v1.1 - parselines : a simple line parser for TeX}
+\Msg{************************************************************************}
+
+\keepsilent
+\askforoverwritefalse
+
+\let\MetaPrefix\relax
+\preamble
+
+This is a generated file.
+
+parselines : 2010/10/23 v1.1 - parselines : catch file between delimiters or tags
+
+This work may be distributed and/or modified under the
+conditions of the LaTeX Project Public License, either
+version 1.3 of this license or (at your option) any later
+version. The latest version of this license is in
+   http://www.latex-project.org/lppl.txt
+
+This work consists of the main source file parselines.dtx
+and the derived files
+   parselines.sty, parselines.pdf, parselines.ins
+
+parselines : a simple line parser for TeX
+Copyright (C) 2010 by Florent Chervet <florent.chervet@free.fr>
+
+\endpreamble
+\let\MetaPrefix\DoubleperCent
+
+\generate{%
+   \file{parselines.ins}{\from{parselines.dtx}{install}}%
+   \file{parselines.sty}{\from{parselines.dtx}{package}}%
+}
+
+\askforoverwritetrue
+\generate{%
+   \file{parselines.drv}{\from{parselines.dtx}{driver}}%
+}
+
+\obeyspaces
+\Msg{************************************************************************}
+\Msg{*}
+\Msg{* To finish the installation you have to move the following}
+\Msg{* file into a directory searched by TeX:}
+\Msg{*}
+\Msg{*     parselines.sty}
+\Msg{*}
+\Msg{* To produce the documentation run the file `parselines.dtx'}
+\Msg{* through LaTeX.}
+\Msg{*}
+\Msg{* Happy TeXing!}
+\Msg{*}
+\Msg{************************************************************************}
+
+\endbatchfile
+%</install>
+%<*ignore>
+\fi
+%</ignore>
+%<*driver>
+\edef\thisfile{\jobname}
+\def\thisinfo{a simple line parser for TeX (\FC)}
+\def\thisdate{2010/10/23}
+\def\thisversion{1.1}
+\def\CTANbaseurl{http://www.ctan.org/tex-archive/macros/latex}
+\def\CTANdisplay{CTAN:macros/latex}
+\makeatletter\protected\def\CTANhref{\@ifstar\CTANhrefstar\CTANhrefnost}\makeatother
+\newcommand*\CTANhrefstar[3][/contrib/]{\href{\CTANbaseurl#1#2}{#3}}
+\newcommand*\CTANhrefnost[2][/contrib/]{\href{\CTANbaseurl#1#2}{\nolinkurl{\CTANdisplay#1#2}}}
+\let\loadclass\LoadClass
+\def\LoadClass#1{\loadclass[abstracton]{scrartcl}\let\scrmaketitle\maketitle\AtEndOfClass{\let\maketitle\scrmaketitle}}
+\documentclass[a4paper,oneside]{ltxdoc}
+\usepackage[latin1]{inputenc}
+\usepackage[american]{babel}
+\usepackage[T1]{fontenc}
+\usepackage{etex,etoolbox,geometry,lastpage,tocloft,titlesec,graphicx,xspace,tabularx,fancyhdr,color,bbding,embedfile,framed,multirow,txfonts,multirow,makecell,enumitem,arydshln,atveryend,catchfile}
+\usepackage[hyperindex=false,pdfusetitle,colorlinks,pdfpagelabels,pdfencoding=auto]{hyperref}
+\usepackage{interfaces}
+\csname endofdump\endcsname
+\usepackage{holtxdoc}
+\CodelineNumbered
+\usepackage{fancyvrb}
+\usepackage[svgnames]{xcolor}
+\usepackage{parselines}
+\lastlinefit999
+\geometry{top=1.2cm,headheight=1cm,headsep=.3cm,bottom=1.4cm,footskip=.5cm,left=2.5cm,right=1cm}
+\hypersetup{%
+  pdftitle={The parselines package},
+  pdfsubject={a simple line parser for TeX},
+  pdfauthor={Florent CHERVET},
+  colorlinks,linkcolor=reflink,
+  pdfstartview={FitH},
+  hyperindex=true,
+  pdfkeywords={tex, e-tex, latex, package, parselines, line parser,line parsing, lines, parser},
+  bookmarksopen=true,bookmarksopenlevel=2}
+\usepackage{bookmark}
+\embedfile{\thisfile.dtx}
+\begin{document}
+   \DocInput{\thisfile.dtx}
+\end{document}
+%</driver>
+% \fi
+%
+% \CheckSum{0}
+%
+% \CharacterTable
+%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
+%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
+%   Digits        \0\1\2\3\4\5\6\7\8\9
+%   Exclamation   \!     Double quote  \"     Hash (number) \#
+%   Dollar        \$     Percent       \%     Ampersand     \&
+%   Acute accent  \'     Left paren    \(     Right paren   \)
+%   Asterisk      \*     Plus          \+     Comma         \,
+%   Minus         \-     Point         \.     Solidus       \/
+%   Colon         \:     Semicolon     \;     Less than     \<
+%   Equals        \=     Greater than  \>     Question mark \?
+%   Commercial at \@     Left bracket  \[     Backslash     \\
+%   Right bracket \]     Circumflex    \^     Underscore    \_
+%   Grave accent  \`     Left brace    \{     Vertical bar  \|
+%   Right brace   \}     Tilde         \~}
+%
+% \DoNotIndex{\begin,\CodelineIndex,\CodelineNumbered,\def,\DisableCrossrefs,\~,\@ifpackagelater,\z@,\@ne}
+% \DoNotIndex{\DocInput,\documentclass,\EnableCrossrefs,\end,\GetFileInfo}
+% \DoNotIndex{\NeedsTeXFormat,\OnlyDescription,\RecordChanges,\usepackage}
+% \DoNotIndex{\ProvidesClass,\ProvidesPackage,\ProvidesFile,\RequirePackage}
+% \DoNotIndex{\filename,\fileversion,\filedate,\let}
+% \DoNotIndex{\@listctr,\@nameuse,\csname,\else,\endcsname,\expandafter}
+% \DoNotIndex{\gdef,\global,\if,\item,\newcommand,\nobibliography,\newrobustcmd,\renewrobustcmd,\providerobustcmd}
+% \DoNotIndex{\par,\providecommand,\relax,\renewcommand,\renewenvironment}
+% \DoNotIndex{\stepcounter,\usecounter,\nocite,\fi}
+% \DoNotIndex{\@fileswfalse,\@gobble,\@ifstar,\@unexpandable@protect}
+% \DoNotIndex{\AtBeginDocument,\AtEndDocument,\begingroup,\endgroup}
+% \DoNotIndex{\frenchspacing,\MessageBreak,\newif,\PackageWarningNoLine}
+% \DoNotIndex{\protect,\string,\xdef,\ifx,\texttt,\@biblabel,\bibitem}
+% \DoNotIndex{\z@,\wd,\wheremsg,\vrule,\voidb@x,\verb,\bibitem}
+% \DoNotIndex{\FrameCommand,\MakeFramed,\FrameRestore,\hskip,\hfil,\hfill,\hsize,\hspace,\hss,\hbox,\hb@xt@,\endMakeFramed,\escapechar}
+% \DoNotIndex{\do,\date,\if@tempswa,\@tempdima,\@tempboxa,\@tempswatrue,\@tempswafalse,\ifdefined,\ifhmode,\ifmmode,\cr}
+% \DoNotIndex{\box,\author,\advance,\multiply,\Command,\outer,\next,\leavevmode,\kern,\title,\toks@,\trcg@where,\tt}
+% \DoNotIndex{\the,\width,\star,\space,\section,\subsection,\textasteriskcentered,\textwidth}
+% \DoNotIndex{\",\:,\@empty,\@for,\@gtempa,\@latex@error,\@namedef,\@nameuse,\@tempa,\@testopt,\@width,\\,\m@ne,\makeatletter,\makeatother}
+% \DoNotIndex{\maketitle,\parindent,\setbox,\x,\kernel@ifnextchar}
+% \DoNotIndex{\KVS@CommaComma,\KVS@CommaSpace,\KVS@EqualsSpace,\KVS@Equals,\KVS@Global,\KVS@SpaceEquals,\KVS@SpaceComma,\KVS@Comma}
+% \DoNotIndex{\DefineShortVerb,\DeleteShortVerb,\UndefineShortVerb,\MakeShortVerb,\endinput}
+% \makeatletter
+% \newrobustcmd\ClearPage{\@ifstar\clearpage{}}
+% \makeatletter
+% \MakeShortVerb{\+}\DeleteShortVerb{\|}\DefineShortVerb{\|}
+% \catcode`\§ \active   \def§{\@ifnextchar §{\par\nobreak\vskip-2\parskip}{\par\nobreak\vskip-\parskip}}
+% \def\thispackage{\xpackage{{\pkgcolor\thisfile}}\xspace}
+% \def\ThisPackage{\Xpackage{\thisfile}\xspace}
+% \def\Xpackage{\@dblarg\X@package}
+% \def\X@package[#1]#2{\@testopt{\X@@package{#1}{#2}}{}}
+% \def\X@@package#1#2[#3]{\xpackage{#2\footnote{\noindent\xpackage{#2}: \CTANhref{#1}#3}}}
+% \def\Underbrace#1_#2{$\underbrace{\vtop to2ex{}\hbox{#1}}_{\footnotesize\hbox{#2}}$}
+%
+% \parindent\z@\parskip.4\baselineskip\topsep\parskip\partopsep\z@
+% \g@addto@macro\macro@font{\macrocodecolor\let\AltMacroFont\macro@font}
+% \g@addto@macro\@list@extra{\parsep\parskip\topsep\z@\itemsep\z@}
+% \DefineVerbatimEnvironment{VerbLines}{Verbatim}{gobble=1,frame=lines,framesep=6pt,fontfamily=txtt,fontseries=m}
+% \DefineVerbatimEnvironment{VerbLines*}{Verbatim}{gobble=1,frame=lines,framesep=6pt,fontfamily=txtt,fontseries=m,commandchars=$()}
+% \DefineVerbatimEnvironment{Verb}{Verbatim}{gobble=1,fontfamily=txtt,fontseries=m}
+% \DefineVerbatimEnvironment{Verb*}{Verbatim}{gobble=1,fontfamily=txtt,fontseries=m,commandchars=$()}
+% \def\smex{\leavevmode\hb@xt@2em{\hfil$\longrightarrow$\hfil}}
+% \newrobustcmd\verbfont{\usefont{T1}{\ttdefault}{\f@series}{n}}    \let\vb\verbfont
+% \newrobustcmd\vbbf{\usefont{T1}{\ttdefault}bn}
+% \renewrobustcmd\#[1]{{\usefont{T1}{pcr}{bx}{n}\char`\##1}}
+% \newrobustcmd\csred[1]{\textcolor{red}{\cs{#1}}}
+% \renewrobustcmd\cs[2][]{\mbox{\vb#1\expandafter\@gobble\string\\#2}}
+% \newrobustcmd\CSbf[1]{\textbf{\CS{#1}}}
+% \newrobustcmd\csbf[2][]{\textbf{\cs[{#1}]{#2}}}
+% \newrobustcmd\textttbf[1]{\textbf{\texttt{#1}}}
+% \renewrobustcmd*\bf{\bfseries}\newcommand\nnn{\normalfont\mdseries\upshape}\newcommand\nbf{\normalfont\bfseries\upshape}
+% \newrobustcmd*\blue{\color{blue}}\newcommand*\red{\color{dr}}\newcommand*\green{\color{green}}\newcommand\rred{\color{red}}
+% \newrobustcmd\rrbf{\color{red}\bfseries}
+% \newrobustcmd*\FC{{\color{copper}\usefont{T1}{fts}xn FC}}
+% \colorlet{pkgcolor}{teal} \def\pkgcolor{\color{pkgcolor}}
+% \definecolor{copper}{rgb}{0.67,0.33,0.00}  \newcommand\copper{\color{copper}}
+% \definecolor{dg}{rgb}{0.02,0.29,0.00}      \newcommand\dg{\color{dg}}
+% \definecolor{db}{rgb}{0,0,0.502}           \newcommand\db{\color{db}}
+% \definecolor{dr}{rgb}{0.75,0.00,0.00}      \let\dr\red
+% \definecolor{lk}{rgb}{0.2,0.2,0.2}         \newrobustcmd\lk{\color{lk}}
+% \newrobustcmd\bk{\color{black}}\newcommand\md{\mdseries}
+% \newrobustcmd\ie{\emph{ie.}}
+% \newrobustcmd\textt[2][]{\texttt{#1#2}}
+% \newcommand\cellstrut{}\let\cellstrut\bottopstrut
+% \def\M{\@ifstar{\M@i\@firstofone}{\M@i\meta}}
+% \def\M@i#1{\@ifnextchar[^^A]
+%   {\M@square#1}
+%   {\@ifnextchar(^^A)
+%     {\M@paren#1}
+%     {\M@brace#1}}^^A
+% }
+% \def\M@square#1[#2]{\M@Bracket[{#1{#2}}]}
+% \def\M@paren#1(#2){\M@Bracket({#1{#2}})}
+% \def\M@brace#1#2{\M@Bracket\{{#1{#2}}\}}
+% \def\M@Bracket#1#2#3{{\ttfamily#1#2#3}}
+% \newrobustcmd*\thisyear{\begingroup
+%    \def\thisyear##1/##2\@nil{\endgroup
+%       \oldstylenums{##1\ifnum##1=\year\else\,\textendash\,\the\year\fi}%
+%    }\expandafter\thisyear\thisdate\@nil
+% }
+% \renewrobustcmd\declcs[2][]{^^A
+%   \par\addvspace\parskip^^A{.5ex plus 1ex}\noindent
+%   \goodbreak
+%   \noindent
+%   \hspace{-\leftmargini}^^A
+%   \def\*{\unskip\,\texttt{*}}^^A
+%   \begin{tabular}{|l|}^^A
+%     \hline
+%     \expandafter\SpecialUsageIndex\csname #2\endcsname
+%     \raisedhyperdef[8pt]{declcs}{#2}{\cs[{#1}]{#2}}^^A
+% }^^A
+% \renewcommand\enddeclcs{%
+%     \crcr \hline
+%     \end{tabular}%
+%     \nobreak   \par  \nobreak
+%     \noindent
+%     \ignorespacesafterend
+%  }
+%
+% \pagesetup{%
+%  head/rule,
+%  head/left=\footnotesize\color[gray]{.35} The \thispackage package -- \thisinfo,
+%  head/right=\lk\footnotesize\bfseries\thefirstmarks{section},
+%  ^^Afoot/left=\color[gray]{.35}\scriptsize\thispackage\quad[rev.\thisversion]\quad\copyright\oldstylenums{2010}\,\lower.3ex\hbox{\NibRight}\,\FC,
+%  foot/left=\thispackage\,[rev.\thisversion]\,\copyright\,\thisyear\,\lower.4ex\hbox{\pkgcolor\NibRight}\,\FC,%
+%  foot/right=\oldstylenums{\arabic{page}} / \oldstylenums{\pageref{LastPage}}%
+%  }
+% \pagesetup[plain]{%
+%     norules,
+%     foot/right=\oldstylenums{\arabic{page}} / \oldstylenums{\pageref{LastPage}},
+% }
+% \pagestyle{fancy}
+% \sectionformat\section{mark=\marksthe{section}{#1},top-=12pt}
+% \sectionformat\subsection{top-=6pt}
+%
+% \newrobustcmd*\macrocodecolor{\color{macrocode}}\definecolor{macrocode}{rgb}{0.18,0.00,0.45}
+% \newrobustcmd*\IMPLEMENTATION{%
+%     \hypersetup{bookmarksopenlevel=1}
+%     \section{Implementation} \label{sec:implementation}}
+% \renewrobustcmd*\PrintMacroName[1]{%
+%     \setbox0\hbox{\MacroFont \strut \string #1\ }%
+%     \global\labelsep\dimexpr\wd0-3em\relax\global\itemindent\labelsep
+%     \hbox to4em{\box0\hss}}
+%
+% \newcommand\reflinkcolor{\color{reflink}}\definecolor{reflink}{rgb}{0.49,0.00,0.00}
+% \newrobustcmd\stform{\@ifnextchar*{\@stform[]\textasteriskcentered\@gobble}\@stform}
+% \newrobustcmd\@stform[2][\string]{\textttbf{\rred#1#2}\xspace}
+%
+% \makeatother
+%
+% \deffootnote{1em}{0pt}{\rlap{\textsuperscript{\thefootnotemark}}\kern1em}
+%
+% \title{\vspace*{-28pt}\mdseries The {\bfseries\thispackage\footnotemark}\kern.6em package}
+% \author{\tiny\xemail{florent.chervet at free.fr}}
+% \date{\thisdate~--~version \thisversion}
+% \subtitle{\thisinfo}
+% ^^A\subject{\thisinfo}
+% \maketitle
+%
+% \makeatletter\begingroup\let\@thefnmark\@empty\let\@makefntext\@firstofone
+% \footnotetext{\noindent\scriptsize
+% This documentation is produced with the +DocStrip+ utility.
+% \begin{tabbing}
+% \qquad\=\smex\=To get the documentation, \= run (thrice):\quad\= \texttt{pdflatex \thisfile.dtx} \\
+% \qquad\>\>To get the index, \> run:\>\texttt{makeindex -s gind.ist \thisfile.idx} \\
+% \>\smex\>To get the package, \> run:\>        \texttt{etex \thisfile.dtx}
+% \end{tabbing}§
+% The \xext{dtx} file is embedded into this pdf file thank to \xpackage{embedfile} by H. Oberdiek.}
+% \endgroup\makeatother
+%
+% \deffootnote{1em}{0pt}{\rlap{\thefootnotemark.}\kern1em}
+% \vspace*{-26pt}
+% \begin{abstract}\parskip\medskipamount\parindent0pt\noindent\leftskip1cm\rightskip\leftskip\lastlinefit0%
+%
+% \thispackage provides an environment {\vbbf parse lines} which applies a macro
+% to each line of the input between \cs{begin}\M*{{\red parse lines}}\, and\, \cs{end}\M*{{\red parse lines}}.
+%
+% There is also a macro: \cs[\red]{dofilebyline}: its purpose is to expand a user-defined macro \cs{do} with
+% one parameter (the line) on each line of a given text file.
+%
+% This packages requires \eTeX and no other package.
+%
+% \end{abstract}
+%
+% \DeleteShortVerb{\+}\enlargethispage{\baselineskip}
+% \cftbeforesecskip=4pt plus2pt minus2pt
+% \cftbeforesubsecskip=0pt plus2pt minus2pt
+%
+% ^^A\vskip-.8\baselineskip
+% \tocsetup{
+% title/top-=6pt,
+% title=Contents\quad\leaders\vrule height3.4pt depth-3pt\hfill\null\kern0pt\vskip-6pt,
+% bookmark={text=Contents,bold},
+% after=\leavevmode\leaders\vrule height3.4pt depth-3pt\hfill\null,
+% twocolumns}
+% \tableofcontents
+%
+%
+% \hypersetup{bookmarksopenlevel=2}
+%
+%
+% \MakeShortVerb{\+}
+%
+%
+% \section{User interface}
+% \label{userinterface}
+%
+% \bottomtitles=.3\textwidth
+%
+% \subsection[The parse lines environment]{The \textttbf{parse lines} environment}
+%
+% \begin{declcs}{begin}\M{\red parse lines}\M[initialisation]\M{replacement text of a macro with 1 parameter} \\
+% \cs{end}\M{\red parse lines}
+% \end{declcs}
+%
+% Example (with \xpackage{xcolor}) -- inside the environment \cs[\red]{row} expands to the current row number (stored in \cs{count@}):
+%
+% \begin{SaveVerbatim}[commandchars=$(),gobble=1]{myVerb}
+%  ($db(\definecolorseries)){serie}{rgb}{last}{Goldenrod}{DarkSeaGreen}
+%  ($db(\resetcolorseries))[3]{serie}
+%  \begin{($dr$underline(parse lines))}{($dg(\color{serie!!+}``#1''\par))}
+%     This is a nice little package
+%     and I really don't know
+%     What to do with it !
+%     May be tomorrow...
+%  \end{($dr$underline(parse lines))}
+% \end{SaveVerbatim}
+%
+% \setbox1=\vbox{\hsize=.6\linewidth\UseVerbatim{myVerb}}
+%
+% \setbox0=\vbox{%
+%  \definecolorseries{serie}{rgb}{last}{Goldenrod}{DarkSeaGreen}
+%  \resetcolorseries[3]{serie}
+%  \begin{parse lines}{\color{serie!!+}``#1''\par}
+%  This is a nice little package
+%  and I really don't know
+%  What to do with it !
+%  May be tomorrow...
+%  \end{parse lines}
+% }
+%
+% \begin{tabular}{p{.7\linewidth}p{.25\linewidth}}
+% \box1 & \box 0
+% \end{tabular}
+%
+% {\small
+%  \definecolorseries{serie}{rgb}{last}{Fuchsia}{MidnightBlue}
+%  \resetcolorseries[3]{serie}
+% \begin{SaveVerbatim}[commandchars=$(),gobble=1]{myVerb}
+%
+%  \begin{($dr$underline(parse lines))}{($dr(\row)): #1\par}
+%     This is a nice little package
+%     and I really don't know
+%     What to do with it !
+%     May be tomorrow...
+%  \end{($dr$underline(parse lines))}
+% \end{SaveVerbatim}
+% \setbox1=\vbox{\hsize=.6\linewidth\UseVerbatim{myVerb}}
+% \setbox0=\vbox{%
+% \count255=0
+% \begin{parse lines}{\color{serie!!+}\row: #1\par}
+%  This is a nice little package
+%  and I really don't know
+%  What to do with it !
+%  May be tomorrow...
+% \end{parse lines}
+% }
+% \begin{tabular}{b{.7\linewidth}b{.25\linewidth}}
+% \box1 & \box 0
+% \end{tabular}
+% }
+%
+%
+% \subsection[\cs{dofilebyline}]{\csbf{dofilebyline}}
+%
+% \begin{declcs}[\red]{dofilebyline}\M{file-name} \\
+%  \cs[\red]{dofilebyline}\stform*\M{file-name}
+% \end{declcs}
+%
+% Expands the macro \csbf{do} on each line of a given file.
+%
+% Each line is read using the \TeX{} primitive \csbf{read}. By default, \cs{endlinechar} is suppressed ({\vb\cs{endlinechar}=-1})
+% in order not to add a space at the end of each line read. If you do not want this behaviour, use the \stform* star form.
+%
+% If the file does not exist, an error is displayed.
+%
+%
+% Example:
+% \begin{VerbLines}
+%     \def\do#1{\ifx\par#1\else \addto@hook\mytoken{#1}\fi}%
+%     \dofilebyline{file name.tex}
+% \end{VerbLines}
+%
+% In this example: \cs{ifx}\cs{par}\#1\cs{else} will evaluate to \texttt{false} if \#1 is empty.
+% Therefore, empty lines and double empty lines (equivalent to \cs{par}) are not captured into the token \cs{mytoken}.
+%
+%
+%
+% \StopEventually{
+% }
+%
+% \IMPLEMENTATION
+%
+% \subsection{Identification}
+%
+% The package namespace is \textttbf{\db parselin@}.
+%
+%    \begin{macrocode}
+%<*package>
+\NeedsTeXFormat{LaTeX2e}% LaTeX 2.09 can't be used (nor non-LaTeX)
+   [2005/12/01]% LaTeX must be 2005/12/01 or younger
+\ProvidesPackage{parselines}
+         [2010/08/13 v1.0 - a simple line parser for TeX]
+%    \end{macrocode}
+%
+% \subsection{Collecting stuff inside an environment}
+%
+%    \begin{macrocode}
+\ifdefined\globtoks  \globtoks\parselin@tk
+\else                \newtoks\parselin@tk
+\fi
+\newcommand\CollectEnvir{}
+\protected\def\CollectEnvir#1{%
+   \gdef\parselin@Finish{#1%
+      \expandafter{\the\parselin@tk}%
+      \global\let\parselin@Finish\@undefined}%
+   \ifx\parselin@tk#1\else
+      \expandafter\def\expandafter\parselin@Finish
+         \expandafter{\parselin@Finish\parselin@tk{}}%
+      \if \relax
+          \expandafter\expandafter\expandafter\parselin@isatoken
+            \expandafter\meaning\expandafter#1\string\toks
+          \relax
+         \expandafter\gdef\expandafter\parselin@Finish
+            \expandafter{\expandafter\expandafter
+               \expandafter\def\expandafter\expandafter
+               \parselin@Finish}%
+   \fi\fi
+   \parselin@tk{}\def\parselin@stack{b}\parselin@Collect@Body
+}% \CollectEnvir
+\long\def\parselin@Collect@Body#1\end#2{%
+  \edef\parselin@stack{\parselin@PushBegins#1\begin\end\expandafter\@gobble\parselin@stack}%
+  \ifx\parselin@stack\@empty
+      \global\parselin@tk\expandafter{\the\parselin@tk#1}%
+      \aftergroup\parselin@Finish
+      \end{#2}%
+  \else
+      \parselin@tk\expandafter{\the\parselin@tk#1\end#2}%
+      \expandafter\parselin@Collect@Body % recurse
+  \fi
+}% \parselin@Collect@Body
+\long\def\parselin@PushBegins#1\begin#2{\ifx\end#2\else b\expandafter\parselin@PushBegins\fi}
+\expandafter\def\expandafter\parselin@isatoken
+   \expandafter#\expandafter1\string\toks#2\relax{\detokenize{#2}\relax}%
+%    \end{macrocode}
+%
+%
+% \subsection{The \texorpdfstring{\textt{parse lines}}{parse lines} environment}
+%
+%    \begin{macrocode}
+\newenvironment{parse lines}[2][]
+{%
+   #1%
+   \count@\z@\def\row{\number\count@}%
+   \def\parselin@ProcessLine##1{\advance\count@\@ne #2}%
+   \parselin@endlinechar{%
+      \def~##1~{%
+         \ifx\parselin@@@@@@##1\relax
+         \else \parselin@ProcessLine{##1}\expandafter~%
+         \fi}%
+   }%
+   \catcode\endlinechar\active
+   \CollectEnvir\parselin@tk
+}
+{%
+   \parselin@endlinechar{%
+      \parselin@tk\expandafter{\the\parselin@tk\parselin@@@@@@~}%
+   }\the\parselin@tk
+}%
+\long\def\parselin@endlinechar#1{\begingroup
+   \lccode`\~\endlinechar  \lowercase{\endgroup#1}%
+}% \parselin@endlinechar
+\def\parselin@@@@@@{\parselin@@@@@@}
+%    \end{macrocode}
+%
+% \subsection{\cs{dofilebyline}}
+%
+%    \begin{macrocode}
+\newread\parselin@read
+\newrobustcmd*\dofilebyline{\let\parselin@Finish\@empty
+   \@ifstar
+      \parselin@dobyline
+      {\edef\parselin@Finish{\endlinechar\the\endlinechar\relax}%
+       \endlinechar\m@ne
+       \parselin@dobyline}%
+}% \dofilebyline
+\newrobustcmd\parselin@dobyline[1]{% #1 = file name
+   \IfFileExists{#1}
+      \parselin@do@byline
+      {\PackageError{parselines}
+         {No file #1 found !
+         \MessageBreak Your command \string\dobyline\space was ignored}\@eha
+      }%
+}% \parselin@dobyline
+\def\parselin@do@byline{%
+   \openin\parselin@read=\@filef@und%
+   \loop
+      \ifeof\parselin@read\else
+         \read\parselin@read to\@tempa
+         \expandafter\do\expandafter{\@tempa}%
+   \repeat
+   \parselin@Finish
+}% \parselin@do@byline
+%    \end{macrocode}
+%
+%
+%    \begin{macrocode}
+%</package>
+%    \end{macrocode}
+%
+% \DeleteShortVerb{\+}
+% \begin{History}
+%
+% ^^A   \begin{Version}{2010/06/20 v1.2}
+% ^^A   \item
+% ^^A   \end{Version}
+% ^^A
+% ^^A   \begin{Version}{2010/06/06 v1.1}
+% ^^A   \item
+% ^^A   \end{Version}
+%   \begin{Version}{2010/10/23 v1.1}
+%   \item \cs{row} counter added
+%   \item Better documentation.
+%   \end{Version}
+%
+%   \begin{Version}{2010/06/20 v1.0}
+%   \item First version.
+%   \end{Version}
+%
+% \end{History}
+%
+% \begin{thebibliography}{9}
+%
+% \bibitem{docstrip}
+%   \textit{The \xpackage{docstrip} program};
+%   2009/09/25 v2.5d;
+%   \CTAN{macros/latex/base/}.
+%
+% \end{thebibliography}
+%
+% \PrintIndex
+%
+% \Finale
-- 
cgit v1.2.3

