diff options
author | Karl Berry <karl@freefriends.org> | 2010-04-03 15:42:12 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2010-04-03 15:42:12 +0000 |
commit | 14b154c49df4af70e973eeafb54e2f31250aff0e (patch) | |
tree | 3d16bd3f92c8dd87c3475e212fca73e37ce370d7 /Master/texmf-dist/tex/latex/nicetext | |
parent | 2a8bfdf220d7f65a85d288b2edef58e46dd9f654 (diff) |
nicetext 0.4 (30mar10)
git-svn-id: svn://tug.org/texlive/trunk@17661 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/nicetext')
-rw-r--r-- | Master/texmf-dist/tex/latex/nicetext/fdtxttex.tex | 59 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/nicetext/fifinddo.sty | 866 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/nicetext/makedoc.sty | 631 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/nicetext/mdoccorr.cfg | 62 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/nicetext/niceverb.sty | 796 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/nicetext/wiki.sty | 376 |
6 files changed, 2325 insertions, 465 deletions
diff --git a/Master/texmf-dist/tex/latex/nicetext/fdtxttex.tex b/Master/texmf-dist/tex/latex/nicetext/fdtxttex.tex deleted file mode 100644 index 9e5e3dda35a..00000000000 --- a/Master/texmf-dist/tex/latex/nicetext/fdtxttex.tex +++ /dev/null @@ -1,59 +0,0 @@ - \makeatletter -\typeout{^^J*fdtxttex.tex* 2010/03/22 txt to TeX by dialogue^^J - (apply \string\MakeDocCorrectHook) - ^^J} - -\RequirePackage{fifinddo} - -\def\MakeDocCorrectHook#1{#1} -\catcode`\_=11 -\def\CorrectionFile{\def\mdoc_corr} -\CorrectionFile{mdoccorr.cfg} -\ResultFile{sample.tex} -\def\InputFile{\def\input_file_name} -\InputFile{sample.txt} -\newif\iftoscreen - -\def\FD_dialogue{% - \typeout{^^J% - ===========================================================^^J% - \string\CorrectionFile{\mdoc_corr} - \space (define \@backslashchar MakeDocCorrectHook)^^J% - \string\InputFile {\input_file_name}^^J% - \string\ResultFile{\result_file_name} - \space\space\space\space\space\space\space - \string\toscreen\iftoscreen true\else false\fi ^^J% - ===========================================================% - }% - \typein[\action]% - {Run with these settings? (Y)es? (C)hange? (Otherwise quit.)}% - \csname action_\action \endcsname -} -\def\run_with_settings{% - \input{\mdoc_corr}% - \WriteProvides - \ProcessFileWith{\input_file_name}{% - \WriteResult{\expandafter \MakeDocCorrectHook - \expandafter{\fdInputLine}}% - \iftoscreen - \typeout{\expandafter \MakeDocCorrectHook - \expandafter{\fdInputLine}}% - \else - \message{.}% - \fi} - \CloseResultFile - \typeout{Done.}% - \FD_dialogue -} -\expandafter\let\csname action_y\endcsname \run_with_settings -\expandafter\let\csname action_Y\endcsname \run_with_settings - -\def\change_settings{% - \typein[\change]{^^JType setting command(s).}% - \change \FD_dialogue} -\expandafter\let\csname action_c\endcsname \change_settings -\expandafter\let\csname action_C\endcsname \change_settings - -\FD_dialogue - -\stop diff --git a/Master/texmf-dist/tex/latex/nicetext/fifinddo.sty b/Master/texmf-dist/tex/latex/nicetext/fifinddo.sty index 5ae6dab9f0c..456ddd1a67f 100644 --- a/Master/texmf-dist/tex/latex/nicetext/fifinddo.sty +++ b/Master/texmf-dist/tex/latex/nicetext/fifinddo.sty @@ -1,760 +1,1612 @@ %% Macro package `fifinddo.sty' for LaTeX2e, %% FIDO, FIND! + %% copyright (C) 2009 Uwe L\"uck, + %% http://www.contact-ednotes.sty.de.vu + %% -- author-maintained in the sense of LPPL below -- + %% for processing tex(t) files + %% (checking, filtering, converting, substituting, expanding, ...) + -\def\fileversion{0.31} \def\filedate{2010/03/23} + +\def\fileversion{0.4} \def\filedate{2010/03/29} + + %% This file can be redistributed and/or modified under + %% the terms of the LaTeX Project Public License; either + %% version 1.3a of the License, or any later version. + %% The latest version of this license is in + %% + %% http://www.latex-project.org/lppl.txt + %% + %% We did our best to help you, but there is NO WARRANTY. + %% Please report bugs, problems, and suggestions via + %% + %% http://www.contact-ednotes.sty.de.vu + %% + %% For the full documentation, look for `fifinddo.pdf'. + %% Its source starts in `fifinddo.tex'. + %% + %% === Format and package version === + \NeedsTeXFormat{LaTeX2e}[1994/12/01] + % 1994/12/01: \newcommand* etc. + \ProvidesPackage{fifinddo}[\filedate\space v\fileversion\space + filtering TeX(t) files by TeX (UL)] + %% + %% === Category codes === + %% + %% We use the ``underscore" as ``compound identifier." + \catcode`\_=11 %% underscore used in control words + %% + %% |\MakeOther| is a synonym for `\@makeother', needed for matching + %% special characters from the input file. It is exemplified by + %% |\fdPatternCodes| which is the default of |\PatternCodes|. + %% The latter is used in setup macros for reading patterns. + +%% We offer |\SetPatternCodes{<commands>}| + +%% (redefining `\PatternCodes') + +%% and |\ResetPatternCodes| + +%% (for returning to `\fdPatternCodes') + +%% so setup scripts such as 'mdoccorr.cfg' have shorter lines. + \@ifundefined{MakeOther}{\let\MakeOther\@makeother}{} + \newcommand*{\fdPatternCodes}{\MakeOther\&\MakeOther\$} -\newcommand*{\PatternCodes}{} \let\PatternCodes\fdPatternCodes - %% TODO adding/removing + +\newcommand*{\SetPatternCodes}{\def\PatternCodes} + +\newcommand*{\ResetPatternCodes}{\let\PatternCodes\fdPatternCodes} + +\newcommand*{\PatternCodes}{} \ResetPatternCodes + + %% TODO adding/removing; `*' may be wrong 2010/03/29 + +%% + %% It would be bad to have `\MakeOther\%' and `\MakeOther\ ' here in + %% that this may have unexpected, weird effects with arguments of -%% setup macros. Therefore neither `\dospecials' nor `\@sanitize' are + +%% setup macros. (With `\MakeOther\ ' you must not indent within a + +%% setup command, and if you add `\MakeOther\%' the setup command + +%% must stay in one line.) + +%% Therefore neither `\dospecials' nor `\@sanitize' are + %% used. Curly braces remain untouched as default delimiters in setup + %% macros. For matching them, you must use `\MakeOther\{' and + %% `\MakeOther' in your `\PatternCodes', or |\Delimiters| to introduce + %% new ones at the same time, e.g., `\Delimiters\[\]': + \newcommand*{\Delimiters}[2]{% + \MakeOther\{\MakeOther\}\catcode`#1=1\catcode`#2=2\relax} + +%% + %% For replacing strings or for defining other strings of ``other" + %% characters by `\edef', you can use some \LaTeX\ constructs---here + %% are copies |\PercentChar| and |\BackslashChar| of them + %% (do you need more?): + \newcommand*{\PercentChar}{} \let\PercentChar\@percentchar + \newcommand*{\BackslashChar}{} \let\BackslashChar\@backslashcar + %% + %% == File handling == + \newwrite\result_file %% or write to \@mainaux!? + %% |\ResultFile{<output>}| opens (and empties) a file + %% <output> to be written into. + \newcommand*{\ResultFile}[1]{% + \def\result_file_name{#1}% + \immediate\openout\result_file=#1} + %% |\WriteResult{<balanced>}| writes a <balanced> line into + %% <output> (or more lines with `^^J'). + \newcommand*{\WriteResult}[1]{% + \immediate\write\result_file{#1}} + %% |\WriteProvides| writes a `\ProvidesFile' command to the + %% opened <output> file. This should be used when <output> + %% is made as \LaTeXe\ input. + \newcommand*{\WriteProvides}{% + \WriteResult{% + \string\ProvidesFile{\result_file_name}% + [\the\year/\two@digits\month/\two@digits\day\space + automatically generated with fifinddo.sty]}}% + %% |\ProcessFileWith{<input>}{<loop-body>}| opens a file <input> + %% and runs a loop on its lines the main body of which is <loop-body>. + %% When the <loop> starts, a new line of <input> is stored as macro + %% %% <- the <loop> 2010/03/10 + %% |\fdInputLine|. + \newcommand*{\ProcessFileWith}[2]{% + \openin\@inputcheck=#1% + % \ifeof\@inputcheck %% bad `exists?' test + % \PackageError{fifinddo}{File `#1' not here}% + % {Mistyped?}% + % \else + \global\c@fdInputLine=\z@ %% line counter reset + \begingroup + \MakeOther\{\MakeOther\}\@sanitize + %% from docstrip.tex: + % \MakeOther\^^A\MakeOther\^^K%% irrelevant, not LaTeX + \endlinechar\m@ne + %% <- cf. TeXbook "extended keyboards" up-/downarrow + %% -> "math specials", cf. "space specials" + \MakeOther\^^I% ASCII horizontal tab -- guessed!? ^^L!? + %% With v3.1, we support non-ASCII: + \count@=128 + \loop + \ifnum\count@<\@cclvi + \catcode\count@=12 + \advance\count@\@ne + \repeat + \loop \ifeof\@inputcheck \else + \read\@inputcheck to \fdInputLine + \ignorespaces #2% + \repeat + \endgroup + % \fi + \closein\@inputcheck} + %% |\CloseResultFile| closes <output>. + \newcommand*{\CloseResultFile}{\immediate\closeout\result_file} + %% + %% TODO: write EOF for debugging!?---%% 2010/03/18 + %% Peter Wilson's \ctanpkgref{newfile} + %% provides more powerful file handling. + %% % <- TODO relevant? 2009/04/12 + %% -%% \pagebreak %% TODO move theory to fifinddo.tex 2009/04/12 + +%% %% \pagebreak %% removed 2010/03/24 + +%% TODO move theory to fifinddo.tex 2009/04/12 + %% == Basic handling of substring conditionals == + %% \label{sec:theory} + %% === ``Substring Theory" === + %% \begin{flushright}\it + %% I wished I could study string theory,\\ + %% but I only could study substring theory. + %% \end{flushright} + %% A \TeX\ macro, say, `\find' whose parameter text + %% (cf. \TeX book p.~203) + %% starts with `#1<pattern>#2&' stops \TeX\ with an error if it does + %% not find <pattern> and then `&'. Otherwise we have a situation + %% `\find<split1><pattern><split2>&', and `\find' reads <split1> as + %% #1 and <split2> as #2. An important point to note is that <split1> + %% will not contain <pattern>, but possibly <pattern> has more + %% occurrences in <split2>. In this sense, `\find' uses the + %% \emph{first} occurrence of <pattern> it finds in order to delimit #1. + %% Finding the \emph{last} occurrence of <pattern> therefore needs a + %% special idea. + %% + %% In order to use `\find' for a test whether <pattern> is in + %% <target>, we build a ``sandbox" |\find<sand>&|, where <sand> + %% contains <target> \emph{and additionally} <pattern>---as a + %% ``dummy;" so `&' delimits the search and `\find' finds + %% <pattern> either in <target> or somewhere else before `&'. + %% + %% Consider the simple sandbox |\find<target><pattern>&|. + %% We can test #1 and #2 on being empty by `\ifx$#1$' and `\ifx$#2$'. + %% If #2 is empty, <pattern> is \emph{not} in <target>. + %% If #1 is empty at the same time, <target> is empty. + %% If #1 is empty and #2 is not, <pattern> \emph{starts} <target>! + %% This can be used to implement + %% Wikipedia-like lists %% TODO 2009/04/11 + %% and to distinguish package code from comments in 'makedoc'. + %% + %% If #2 is \emph{not} empty, <pattern> occurs in <target>---or this once + %% was \emph{thought}, some time in developping the present package, + %% as well as in the version of 'substr.sty' marked + %% `2005-11-29',\footnote{\url{http://ctan.org/pkg/substr}. + %% 'substr' does not change category codes + %% as 'fifinddo' does + %% and uses \cs{@nil} as delimiter instead of + %% our &&.} try + %% (if that version still is installed)\footnote{The ``feature" has + %% been fixed with v1.2 as of 2009/10/20 of + %% 'substr.sty'.} + %% \[`\IfSubStringInString{<str1><str2><str1>}{<str1><str2>}{YES}{NO}'\] + %% which works \emph{verbatim} as well as considering <str1> and + %% <str2> \emph{placeholders}, e.g., for + %% \begin{center} + %% `\IfSubStringInString{day after day}{day after }{YES}{NO}'\footnote{% + %% Likewise \texttt{t\string\^ete-\string\`a-t\string\^ete} ...}\\ + %% %% <- `e' was missing 2010/03/17 + %% `\IfSubStringInString{AMSTERDAM}{AMSTERD}{YES}{NO}'\\ + %% `\IfSubStringInString{TORONTO}{TORON}{YES}{NO}'\\ + %% `\IfSubStringInString{bonbon}{bon}{YES}{NO}'\footnote{% + %% Polynesian: `aku aku', `rongorongo', `wiki wiki' ...}\\ + %% `\IfSubStringInString{bonobo}{bono}{YES}{NO}' + %% (an ape) + %% \end{center} + %% or `\IfSubStringInString{ionization}{ionizat}{YES}{NO}'.\footnote{% + %% Read 'substr.sty' or try ``normal" things to convince yourself + %% that the syntax indeed is + %% &\IfSubStringInString{<pattern>}{<target>}{<yes>}{<no>}.} + %% Same with \LaTeX's internal `\in@':\footnote{\cs{in@} has been + %% fixed after my warning on Heiko Oberdiek's proposal---at + %% least in the repository.---On 2009/04/21 + %% I learn from Manuel P\'egouri\'e-Gonnard + %% that the first versions of his 'ted' + %% had a similar bug, fixed on v1.05 essentially like here; + %% Steven Segletes confirms that his 'stringstrings' doesn't + %% suffer the problem (returning positions of substrings and + %% numbers of occurrences).} + %% \[`\makeatletter \in@{bonbon}{bon}\ifin@ YES\else NO\fi \makeatother'\] + %% %% \makeatletter \in@{bonbon}{bon}\ifin@ YES\else NO\fi \makeatother + %% %% \IfSubStringInString{ionization}{ionizat}{YES}{NO} + %% + %% In general, the previous approach \emph{fails if and exactly if} + %% <pattern> has a \emph{period} $p$---less than its length---in the sense of that + %% the $p$th token to the right or left of each token in <pattern> + %% is the \emph{same} token. + %% `AMSTERDAM' has a period 8, `day after day' 10, `bonbon' 3, `bonobo' 4. + %% There is a counterexample <target> of length $p$ iff + %% <pattern> has period $p$, namely the first substring of <pattern> + %% having length $p$. If the length of <pattern> exceeds a multiple + %% $mp$ of its period, the first $mp$ tokens of <pattern> form + %% a counterexample <target>. + %% + %% Therefore, a sandbox must have something between <target> and + %% <pattern>.\footnote{Must? Actually, I preferred this solution to + %% other ideas like measuring the length of <split2>.} + %% We choose |\find<target>~<pattern>$&| as standard. + %% The `$' will be used as an argument delimiter to get rid of the dummy + %% <pattern> in <split2>, as well as to decide whether the match was + %% in <target> or in the dummy part of the sandbox. + %% The `$' can be replaced by another tilde `~' in order to + %% test whether <target> \emph{ends} on a <pattern>, defining a macro + %% like `\findatend' whose parameter text starts with `#1<pattern>~#2&'. + %% + %% === Plan for proceeding === + %% When we check a file for several patterns, we seem to need + %% \emph{two} macros for each pattern: one that has the pattern + %% in its parameter text and one that stores the pattern for building + %% the sandbox.\footnote{If it were for the pattern only, the parsing + %% macro might suffice and the macro calling it might extract the + %% pattern from a ``dummy expansion." Somewhat too much for me now; + %% on the other hand the calling macro also hands some ``current" + %% informations to the parsing macro---oh, even this could be + %% handled by a general ``calling" macro \dots} + %% %% TODO 2009/04/15 + %% We use a separate \emph{``name space"} for each of + %% both kinds. The parsing macro and the macro building the sandbox + %% will have a common \emph{``identifier"} by which the user or + %% programmer calls them. Actually, she will usually (first) call + %% the sandbox box builder. The sandbox builder calls the parsing + %% macro. When \emph{all} occurrences of a pattern in the target are + %% looked for, the parser may call itself. + %% + %% Actually, the parsing macro will execute certain actions + %% depending on what it finds in the sandbox, so we call it a + %% \emph{``substring conditional"}. It may read additional arguments + %% after the sandbox that store information gathered before. + %% This is especially useful for designing \emph{``expandable"} + %% chains (sequences) of conditionals where macros cannot store information in + %% macros. The macro setting up the sandbox will initialize such + %% extra arguments at the same time. + %% + %% It may be more efficient \emph{not} to use the following setup + %% macros but to type the macros yourself, just using the following + %% as templates. The setup macros are especially useful with patterns + %% that contain ``special characters," as when you are looking for + %% %% TODO repetition of single right quote not working 2010/03/19 + %% lines that might be package comments. + %% + %% === Meta-Setup === + %% + %% A setup command <setup-cmd> will have the following syntax: + %% \[|<setup-cmd>{<job-id>}[<changes>]{<pattern>}<more-args>|\] + %% <changes> will, in the first instance, be category code changes + %% for reading <pattern> overriding the settings in `\PatternCodes'. + %% They are executed after the latter in a local group. + %% It may be safer to redefine `\PatternCodes' instead + %% of using the optional <changes> argument. + %% + %% A macro + %% \[|\StartFDsetup{<do-setup>}{<job-id>}[<changes>]|\] + %% shared by setup commands + %% may read <job-id> and <changes> for <setup-cmd>. + %% |<do-setup>| will be the macro that reads <pattern> (and more) + %% and processes it. It must contain `\endgroup' to match + %% `\begingroup' from `\FD_prepare_pattern'. + %% <job-id> is stored in a macro |\fdParserId|. + %% The default for <changes> is \emph{nothing}. + \newcommand*{\StartFDsetup}[1]{% + \let\FD_do_setup#1% + \afterassignment\FD_prepare_pattern + \def\fdParserId} + \newcommand*{\FD_prepare_pattern}[1][]{% + \begingroup \PatternCodes #1\FD_do_setup} + %% So <setup-cmd> should be set up about as follows: + %% \begin{quote} + %% `\newcommand*{<setup-cmd>}{\StartFDsetup<do-setup>}'\\ + %% `\newcommand*{<do-setup>}[<args>]{<action>}' + %% \end{quote} + %% <do-setup>'s first argument will be the <pattern> argument + %% of <setup-cmd>. + %% + %% === Setup for conditionals === + %% `substr_cond' is the ``name space" for substring conditionals. + %% A colon separates it from \emph{``job identifiers"} in the actual + %% macro names. + \def\substr_cond{substr_cond:} + %% + %% |\MakeSubstringConditional{<id>}[<changes>]{<pattern>}| + %% starts the definition of a conditional with identifier <id> + %% and pattern <pattern>. <changes> optionally add commands to + %% be executed after `\PatternCodes' in a local group. + %% + \newcommand*{\MakeSubstringConditional} + {\StartFDsetup\mk_substr_cond} + %% + %% `\begingroup' |\mk_substr_cond{<pattern>}| %% TODO!? 2010/03/22 + %% can be directly called by other programmer setup commands when + %% `\fdParserId' and <pattern> have been read. + \def\mk_substr_cond #1{%% #1 pattern string + \endgroup \@namedef{\substr_cond \fdParserId}##1#1##2&} + %% + %% This really is not \LaTeX. We are starting defining a macro + %% `\substr_cond:<id>' in primitive \TeX\ with `\def' in the form + %% \[`\def\substr_cond:<id>#1<pattern>#2&'\] + %% where `\csname' etc. render \lq`:<id>'\rq\ part of the macro name. + %% The user or programmer macro produces the part of the definition + %% until the delimiter `&' to match the sandbox. You have to add + %% (maybe) #3 etc. and the `{<definition text>}' + %% just as with primitive \TeX. + %% + %% === Setup for sandboxes === + %% There was a \emph{question:} will we rather see + %% \emph{string macros} or \emph{strings from macro arguments}? + %% The input file content always comes + %% as `\fdInputLine' first, so we at least \emph{must account} for + %% the possibility of string macros as input. + %% + %% One easy way to apply several checks and substitutions to + %% `\fdInputLine' before the result is written to <output> is + %% `\let\OutputString\fdInputLine' and then let `\OutputString' + %% be to what each job refers as \emph{its} + %% input and output, finally `\WriteResult{\OutputString}'. + %% (`\fdInputLine' might better not be touched, it could be used + %% for a final test whether any change applied for some message on + %% screen, even with an entirely expandable chain of actions.) + %% This way each job, indeed each recursive substitution of a single + %% string must start with expanding `\OutputString'. + %% + %% On the other hand, there is the idea of \emph{``expandable" + %% chains of substitutions}. We may, e.g., define a macro, say, + %% `\manysubstitutions{<macro-name>}', such that + %% `\WriteResult{\manysubstitutions{\fdInputLine}}' + %% writes to <output> the result of applying many expandable + %% substitutions to `\fdInputLine'. + %% Such a macro `\manysubstitutions' may read `\fdInputLine', + %% but it must not redefine any macros. + %% Instead, the substitution macros it calls must read results + %% of previous substitutions as \emph{arguments}. + %% + %% Another aspect: + %% the order of substitutions should be easy to + %% change. Therefore expanding of string macros should rather be + %% controlled by the way a job is \emph{called}, not right here + %% at the \emph{definition} of the job. For this reason, + %% a variant of the sandbox builder expanding some macro was given up. +%% %% <- TODO!? 2010/03/25 + + + %% `setup_substr_cond' is the name space for macros that build + %% sandboxes and initialize arguments for conditional macros. + \def\setup_substr_cond{setup_substr_cond:} + %% \[|\MakeSetupSubstringCondition{<id>}[<changes>]{<pattern>}{<more-args>}|\] + %% % <- TODO allow `%' and ` ' for breaking code lines. + %% ---same <id>, <changes>, <pattern> as for + %% `\MakeSubstringConditional' (this is bad, there may be + %% |\MakeSubstringConditional*{<more-args>}|)---creates the + %% % <- TODO: store args in \Make...Conditional + %% corresponding sandbox, by default without tilde wrap. + %% <more-args> may contain `{#1}' to store the string that was tested, + %% also `{<id>}' for calling repetitions and `{<pattern>}' for screen + %% or log informations. + \newcommand*{\MakeSetupSubstringCondition} + {\StartFDsetup\mk_setup_substr_cond} -%% `\begingroup' |\mk_setup_substr_cond{<pattern>}{<more-args>}| + +%% |\mk_setup_substr_cond{<pattern>}{<more-args>}| + +%% %% without \begingroup 2010/03/29 + %% can be directly called by other programmer setup commands after + %% `\fdParserId' and <pattern> have been read: + \def\mk_setup_substr_cond #1#2{%% #1 pattern string, + %% #2 additional arguments, e.g., `{#1}' to keep tested string + \endgroup + \expandafter \edef + \csname \setup_substr_cond \fdParserId \endcsname ##1{% + \make_not_expanding_cs{\substr_cond \fdParserId}% + %% By `\edef', the name of the substring conditional is stored here + %% as a single token. The rest of the sandbox follows. + ##1\noexpand~#1\dollar_tilde}% + \let\dollar_tilde\sandbox_dollar} + %% If a tilde `~' has been used instead of `$', the default + %% is restored. + \def\sandbox_dollar{$} + \let\dollar_tilde\sandbox_dollar + %% The following general tool |\make_not_expanding_cs| has been used + %% (many definitions in 'latex.ltx' could have used it): %% 2009/04/10 + \def\make_not_expanding_cs#1{% + \expandafter \noexpand \csname #1\endcsname} + %% + %% === Getting rid of the tildes === + %% |\let~\TildeGobbles| can be used to suppress dummy patterns + %% (contained in <split2>) + %% in `\write'ing or with `\edef'. ... will probably become obsolete + %% ... however, it is helpful in that you needn't care + %% whether there is a dummy wrap left at all. (2009/04/13) + \newcommand{\TildeGobbles}{} \def\TildeGobbles#1${} + %% |\RemoveDummyPattern| is used to remove the dummy pattern + %% \emph{immediately}, not waiting for `\write'ing + %% or other ``total" expansion: %% 2009/04/13 + \newcommand{\RemoveDummyPattern}{} \def\RemoveDummyPattern#1~#2${#1} + %% |\RemoveDummyPatternArg<macro>{<arg>}| executes + %% `\RemoveDummyPattern' in the next argument: + \newcommand*{\RemoveDummyPatternArg}[2]{% + \expandafter #1\expandafter {\RemoveDummyPattern #2}} + %% |\RemoveTilde| is used to remove the tilde that separated + %% the dummy pattern from <split1>. + % %% An alternative policy is to pass + % %% <target> (as an argument) to the parsing macro. + \newcommand{\RemoveTilde}{} \def\RemoveTilde#1~{#1} + %% |\RemoveTildeArg<macro>{<arg>}| executes `\RemoveTilde' + %% in the next argument: + \newcommand*{\RemoveTildeArg}[2]{% + \expandafter #1\expandafter {\RemoveTilde #2}} + %% + %% === Calling conditionals === + %% |\ProcessStringWith{<target-string>}{<id>}| builds the sandbox + %% to search <target-string> for the <pattern> associated with the + %% parser-conditional that is identified by <id>, the sandbox then + %% calls the parser. + +%% % Finally, the command \emph{``returns"} the + +%% % result of applying job <id> to <target-string>---in the sense of + +%% % \emph{expanding} to it. %% more precisely 2010/03/25 + +%% %% <- removed again, wrong 2010/03/26 + \newcommand*{\ProcessStringWith}[2]{% + \csname \setup_substr_cond #2\endcsname{#1}} + %% |\ProcessExpandedWith{<string-macro>}{<id>}| does the same but with + %% a \emph{macro} (like `\fdInputLine' or `\OutputString') in which + %% the string to be tested is stored. + +%% %% TODO or \the<tok-reg> 2010/03/25 + \newcommand*{\ProcessExpandedWith}[2]{% + \csname \setup_substr_cond #2\expandafter \endcsname + \expandafter{#1}} + %% I would have preferred the reversed order of arguments which seems + %% to be more natural, but the present is more efficient. + %% Macros with reversed order are currently stored after `\endinput' + %% in section~\ref{sec:pondered}, may be they once return. + %% + %% Anyway, most desired will be |\ProcessInputWith{<id>}| just + %% applying to `\fdInputLine': + \newcommand*{\ProcessInputWith}[1]{% + \csname \setup_substr_cond #1\expandafter \endcsname + \expandafter{\fdInputLine}} + %% (Definition almost copied for efficiency.) + %% TODO: error when undefined 2009/04/07 + %% + %% === Copy jobs === + %% A job identifier <id> may also be considered a mere \emph{hook}, + %% a \emph{placeholder} for a parsing job. What function actually is + %% called may depend on conditions that change while reading the + %% <input> file. %%% On a certain condition, + %% |\CopyFDconditionFromTo{<id1>}{<id2>}| + %% \emph{creates or redefines a sandbox builder} with identifier <id2> + %% that afterwards behaves like the sandbox builder <id1>. + %% So you can store a certain behaviour as <id1> in advance in order + %% once to change the behaviour of <id2> into that of <id1>. + \newcommand*{\CopyFDconditionFromTo}[2]{% + \expandafter \let + \csname \setup_substr_cond #2\expandafter \endcsname + \csname \setup_substr_cond #1\endcsname} + %% (Only the \emph{sandbox} is copied here---what about + %% changing conditionals?) %% TODO + %% + %% An ``almost" example is typesetting documentation from a package + %% file where the ``Legalese" header might be typeset verbatim + %% although it is marked as ``comment." (The present %% 2009/04/07 + %% example changes ``hand-made" macros instead.) + %% + %% This feature could have been placed more below as a ``programming + %% tool." + %% + %% == Programming tools == + %% === Tails of conditionals === + %% \label{sec:tails} + %% When creating complex \emph{expandable} conditionals, + %% this may amount to have primitive `\if' ... `\fi' conditionals + %% nested quite deeply, once perhaps too deep for \TeX's memory. + %% To avoid this, you can apply the common `\expandafter' trick + %% which finishes the current `\if' ... `\fi' before an inside + %% macro is executed (cf. \TeX book p.~219 on ``tail recursion"). + %% + %% Internally tests whether certain strings are present at certain + %% places will be carried out by tests on emptiness or + %% %% onwards) %% !? 2009/12/28 + %% on starting with `~'. E.g., + %% ``#1~=~<split1> empty" indicates that either the <pattern> + %% starts a line or the line is empty altogether (this must be + %% decided by another test). + %% + %% |\IfFDempty{<arg>}{<when-empty>}{<when-not-empty>}| + %% is used to test <arg> on emptyness (without expanding it): + \newcommand*{\IfFDempty}[1]{% + \ifx$#1$\expandafter \@firstoftwo \else + \expandafter \@secondoftwo \fi} + %% |\IfFDinputEmpty{<when-empty>}{<when-not-empty>}| is a variant of + %% the previous to execute <when-empty> if the loop processing <input> + %% finds an empty line---otherwise <when-not-empty>. + \newcommand*{\IfFDinputEmpty}{% + \ifx\fdInputLine\@empty \expandafter \@firstoftwo \else + \expandafter \@secondoftwo \fi} + %% |\IfFDdollar{<arg>}{<when-empty>}{<when-not-empty>}| + %% is another variant, testing <split2> for being `$', + %% main indicator of there is a match anywhere in <target> + %% (as opposed to starting or ending match): + \newcommand*{\IfFDdollar}[1]{% + \ifx$#1\expandafter \@firstoftwo \else + \expandafter \@secondoftwo \fi} + %% It is exemplified and explained in section~\ref{sec:replchain}. + %% (The whole policy requires that `~' remains active in any + %% testing macros here!) + %% + %% However, you might always just type the replacement text + %% (in one line) instead of + %% such an `\If'\,... (for efficiency \dots) + %% + %% If expandability is not desired, you can just chain macros that + %% rework (so re-define) `\OutputString' or so. + %% + %% 2009/04/11: tending towards combining ... + %% Keeping empty input and empty arguments apart is useful in that + %% \emph{one} test of emptiness per input line should suffice---it + %% may be left open whether this should be the first of all tests + %% \dots + %% + %% === Line counter === + %% A \LaTeX\ counter |fdInputLine| may be useful for screen or log + %% messages, moreover you can use it to control processing of the + %% <input> file ``from outside," not dependent on what the parsing + %% macros find. The header of the file might be typeset verbatim, + %% but we may be too lazy to define the ``header" in terms of + %% what is in the file. We just decide that the first ... lines + %% are the ``header," even without counting just trying whether + %% the output is fine. It may be necessary to change that number + %% manually when the header changes. + %% + %% You also can insert lines in <output> + %% which have no counterpart in <input>---if you know what you are + %% doing. With 'makedoc', there is a hook `\EveryComment' that can + %% be used to issue commands ``from outside" at a place where + %% executing the command is safe or appropriate. + \newcounter{fdInputLine} + %% You then must insert |\CountInputLines| in the second argument + %% of `\ProcessFileWith' (or in a macro called from there) + %% so that the counter is stepped. %% TODO!? 2009/04/07 + \newcommand*{\CountInputLines}{\global\advance\c@fdInputLine\@ne} + %% At present %% 2009/04/07 TODO + %% the counter is reset by `\ProcessFileWith', this may change. + %% + %% |\IfInputLine{<relation><number>}{<true>}{<false>}|, when called + %% from the processing loop (second argument of `\ProcessFileWith') + %% issues <true> commands if `\value{fdInputLine}<relation><number>' -%% is true, otherwise <false>. <relation> may usually be just `='. + +%% is true, otherwise <false>. <relation> is one out of + +%% \HardNVerb+<+, `=', `>'. %% 2010/03/24 2010/03/29 + \newcommand*{\IfInputLine}[1]{% + \ifnum\c@fdInputLine#1\relax \expandafter \@firstoftwo + \else \expandafter \@secondoftwo \fi} + %% + %% === The ``identity job" `LEAVE' === + %% \label{sec:LEAVE} + %% The job with identifier |LEAVE| + %% \emph{leaves} an (expandable) chain of jobs + %% (as expandable replacement in section~\ref{sec:replchain}) + %% and \emph{leaves} the processed string without changing it + %% and without the braces enclosing it: + \expandafter \let + \csname \setup_substr_cond LEAVE\endcsname \@firstofone + %% I.e., `\ProcessStringWith{<string>}{LEAVE}' expands to <string> + %% ... \ProcessStringWith{(Indeed!)}{LEAVE} + + %% == Setup for expandable chains of replacements == + %% \label{sec:replchain}%% TODO makedoc: provide less visible label/ref 2009/04/11 + %% By the following means, you can create macros + %% (`\Transform' among them) such that, e.g., + %% \[`\edef\OutputString{\Transform{<string>}}'\] renders `\OutputString' + %% the result of applying a chain (sequence) of stringwise replacements + %% to <string>. + %% You can even write a transformed input <string> to a file + %% without defining anything anything after `\read to'\,.\,.\,. + %% In this case however, you don't get any statistical message + %% about what happened or not. With `\edef\OutputString' you can at + %% least issue some `changed!' or `left!' (maybe `\message{!}' vs.\ + %% `\message{.}'). + %% There is an application in 'makedoc' for ``typographical upgrading" + %% from plain text to \TeX\ input. + %% + %% |\repl_all_chain_expandable| will be the backbone of the + %% replacements. It is called by some parsing macro <parser> + %% and receives from the latter <split1>~=~#1 and <split2>~=~#2. + %% #3 is the result of what happened so far. + \def\repl_all_chain_expandable#1#2#3#4#5#6{% + %% #1, #2 splits, #3 past, #4 substitute, + %% #5 repeat parser, #6 pass to + % \ifx~#2\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi + %% The previous line would be somewhat faster, but let us exemplify + %% `\IfFDdollar' from section~\ref{sec:tails} instead: + \IfFDdollar{#2}% + %% If #2 starts with `$'---with category code 3, ``math shift"!, + %% it \emph{is} `$', due to not reading `$' + %% from input with its standard category code 3 + %% and the sandbox construction (where `$' appears with its standard + %% category code). %% TODO might be explained earlier 2009/04/11 + %% %% or refer to here. + %% And this is the case \emph{exactly} when the <pattern> from + %% <parser> didn't match, again due to the input category codes. + %% Now on \emph{no} match, the sandbox builder #6 is called + %% with target string #3#1 where the last tested string is attached + %% to previous results. The ending `~' is removed, #6 inserts a new + %% wrap for the new dummy pattern. + {\RemoveTildeArg #6{#3#1}}% + %% Otherwise ... the \emph{sandbox builder} <sandbox> + %% (that will be shown below) that called <parser> + %% initialized #5 to be that <parser> itself. (<parser> otherwise + %% wouldn't know who it is.) So <parser> calls itself with another sandbox + %% `#2&'. Note that #2 contains \lq`~<pattern>$'\rq\ due to the initial + %% <sandbox> building. + {#5#2&{#3#1#4}{#4}#5#6}} + %% #4 is the replacement string that <sandbox> passed to <parse>. + %% The first argument after the `&' is previous stuff plus + %% the recently skipped <split1> + %% plus #4 replacing the string <pattern> that was matched. + %% + %% Finally, #5 and #6 again ``recall" <parser> and the sandbox + %% builder to which to change in case of no other match. + %% + %% \pagebreak[3] %% 2010/03/22 + %% % TODO move following up!? 2009/04/11 + %% \[|\MakeExpandableAllReplacer{<id>}[<chng>]{<find>}{<replace>}{<id-next>}|\] + %% creates sandbox and parser with common identifier <id> and search + %% pattern <find>. Each occurrence of <find> will be replaced by + %% <replace>. When <find> is not found, the sandbox builder for + %% <id-next> is called. This may be another replacing macro of the + %% same kind. To return the result without further transformations, + %% call job `LEAVE' (section~\ref{sec:LEAVE}). + %% Optional argument <chng> changes category codes locally + %% for reading <find> and <replace>. + %% %% <- added <cat>, <pattern> -> <find> 2010/03/19 + \newcommand*{\MakeExpandableAllReplacer} + {\StartFDsetup\mk_setup_xpdbl_all_repl} + \newcommand*{\mk_setup_xpdbl_all_repl}[3]{% + %% #1 pattern, #2 substitute, #3 pass to + \endgroup + %% We take pains to call next jobs by single + %% command strings and store them this way, not by `\csname', + %% as `\ProcessStringWith' would do it. `\edef\@tempa' + %% is used for this purpose, but \dots + \edef\@tempa{% + \noexpand\mk_setup_substr_cond{#1}{% + {}{#2}% + \noexpand\noexpand + %% That `\edef\@tempa' must \emph{not expand} the controll + %% words after they have been computed from `\csname' etc. + %% Moreover, expansion of the parser commands + %% must be avoided another time, when `\@tempa' is executed. + \make_not_expanding_cs{\substr_cond\fdParserId}% + \noexpand\noexpand + \make_not_expanding_cs{\setup_substr_cond #3}}}% + %% Those internal setup commands start with `\endgroup' to switch back + %% to standard category codes. We must match them here by + %% `\begingroup'. + \begingroup \@tempa + \begingroup \mk_substr_cond{#1}{% + \repl_all_chain_expandable{##1}{##2}}} + %% The final command is the one that we explained first. %% TODO 2009/04/11 + %% + %% \[|\PrependExpandableAllReplacer{<id>}[<cat>]{<find>}{<replace>}|\] + %% is hoped to be a slight relief in composing replacement chains. + %% It does something like invoking `\MakeExpandableAllReplacer' + %% with <prev-setup-id> for the last <next-id> argument + %% where <prev-setup-id> is the <id> of the job that was set up most + %% recently. If you have adjacent lines + %% \begin{quote} + %% \leavevmode\hbox to 0pt\bgroup + %% `\MakeExpandableAllReplacer{<id-0>}{<find-0>}{<subst-0>}{LEAVE}'% + %% \hss\egroup \\ + %% `\PrependExpandableAllReplacer{<id-1>}{<find-1>}{<subst-1>}'\\ + %% `\PrependExpandableAllReplacer{<id-2>}{<find-2>}{<subst-2>}' + %% \end{quote} + %% and call <id-2>, it will call <id-1>, and the latter will call + %% <id-0>. So you can reorder the chain my moving `\Prepend'... lines. + \newcommand*{\PrependExpandableAllReplacer}{% + \let\fdParserId_before\fdParserId + \StartFDsetup\prep_xpdbl_all_repl} + \newcommand*{\prep_xpdbl_all_repl}[2]{% + \mk_setup_xpdbl_all_repl{#1}{#2}{\fdParserId_before}}% + +%% + +%% %% 2010/03/29: + +%% |\MakeDocCorrectHook{<string>}| belongs to 'makedoc', + +%% but in the meantime ('nicetext' release 0.3) + +%% I have proposed to use it with 'fifinddo' only as well + +%% (running files `fdtxttex.tpl', `fdtxttex.tex'). + +%% Therefore I offer some simplification |\SetCorrectHookJob{<job-id>}| + +%% for defining `\MakeDocCorrectHook' \emph{here.} + +\newcommand*{\SetCorrectHookJob}[1]{% + + \def\MakeDocCorrectHook##1{\ProcessStringWith{##1}{#1}}} + +%% |\SetCorrectHookJobLast| just uses the job that was set up + +%% most recently. + +\newcommand*{\SetCorrectHookJobLast} + + {\SetCorrectHookJob\fdParserId} + %% + %% == Leave package mode == + %% We restore the underscore `_' for math subscripts. + %% (This might better depend on something \dots) %% TODO 2009/04/07 + \catcode`\_=8 %% restores underscore use for subscripts + %% + \endinput + %% \TeX\ ignores the rest of the file when it is \emph{input} + %% ``in the sense of `\input'", as opposed to just reading + %% the file line by line to a macro like `\fdInputLine'. + %% + %% == Pondered == + %% \label{sec:pondered} + %% TODO abbreviated commands (aliases) \MkSubstrCond... + %% TODO \@onlypreamble!? + \newcommand*{\ApplySubstringConditional}[1]{% + %% #1 identifier; text to be searched expected next + \csname setup_substr_cond:#1\endcsname} + \newcommand*{\ApplySubstringConditionalToExpanded}[1]{% 2009/03/31+ + \csname setup_substr_cond:#1\expandafter \endcsname \expandafter} + \newcommand*{\ApplySubstringConditionalToInputString}[1]{% 2009/03/31+ + \csname setup_substr_cond:#1\expandafter \endcsname + \expandafter {\fdInputLine}} + %% TODO or `\OutputString', even `\read' to `\OutputString'!? + % \newcommand*{\ApplySubstringConditionalToExpanded}[2]{% + % %% note: without assignments, robust! + % %% BUT the `\csname ... \expandafter \endcsname' method is faster + % \expandafter \reversed_apply_substr_cond + % \expandafter {#2}{#1}} + % \newcommand*{\reversed_apply_substr_cond}[2]{% + % \ApplySubstringConditional{#2}{#1}} + %% ODER: + % \newcommand*{\expand_attach_arg}[2]{%% 2009/03/31 + % %% #1 command with previous args, TODO cf. LaTeX3 + % \expandafter \attach_arg \expandafter {#1}{#2}} + % %% actually #1 may contain more than one token, + % %% only first expanded + % \newcommand*{\attach_arg}[2]{#2{#1}} + % \newcommand*{\ApplySubstringConditionalToExpanded}[2]{% + % \expandafter \attach_arg \expandafter + % {#2}{\ApplySubstringConditional{#1}}} + %% + %% + %% + %% == VERSION HISTORY == + %% + v0.1 2009/04/03 very first version, tested on morgan.sty + v0.2 2009/04/05 counter fdInputLine, \ProvidesFile moved from + \ProcessFile to \ResultFile, \CopyFD..., + category section first, more sectioning, + suppressing empty code lines before section + titles; discussion, \Delimiters + 2009/04/06 more discussion + 2009/04/07 more discussion, factored \WriteProvides out from + \ResultFile, \ProcessExpandedWith corrected + 2009/04/08 \InputString -> \fdInputline; + removed \ignorespaces + 2009/04/09 \WhenInputLine[2] -> \IfInputline[3], + \ProcessInputWith, typos, + \WriteProvides message `with' + 2009/04/10 \make_not_expanding_cs + DISCOVERED ``IF SUBSTRING" ALGORITHM WRONG + (<str1><str2><str1> in <str1><str2>) + v0.3 2009/04/11 SOME THINGS GIVEN UP EARLIER WILL BE REMOVED, + TO BE STORED IN THE COPY AS OF 2009/04/10 + mainly: sandbox setup (tilde/dollar) + REAL ADDITION: setup for expandable replacing + 2009/04/12 played with `chain' vs. `sequence'; + plain `...', `cf.', `etc.' for `mdcorr.cfg' + 2009/04/13 \RemoveTilde... + 2009/04/15 reworked text, same mistake \in@ + v0.31 2009/04/21f. comments on ted, stringstrings + 2009/12/28 "onwards)" !? "safer", not "more safe" + 2010/03/10 the loop starts + 2010/03/17 corr. t^ete; set up -> setup for + 2010/03/18 TODO EOF, ctan.org/pkg/newfile; non-ASCII + 2010/03/19 extended description of \MakeExpandableAll...; + '' -> " + 2010/03/20 \ctanpkgref + 2010/03/22 \StartFDsetup, \Prepend... + 2010/03/23 URL for `substr.sty' +SENT TO CTAN + + + +v0.4 2010/03/24 removed \pagebreak before "substrings"; + + <relation> with \IfInputLine precisely + + 2010/03/25 todo \ProcessExp... more precisely, etc. + + 2010/03/26 ... was wrong, removed + + 2010/03/29 \SetPatternCodes, \ResetPatternCodes, + + \SetCorrectHookJob, \SetCorrectHookJobLast; + + <relation> with \HardNVerb; + + don't mention \begingroup with + + \mk_setup_substr_cond; renamed v0.4 + + + TODO: cleveref 2010/03/18 + diff --git a/Master/texmf-dist/tex/latex/nicetext/makedoc.sty b/Master/texmf-dist/tex/latex/nicetext/makedoc.sty index 948c1b59b5e..292a44242d0 100644 --- a/Master/texmf-dist/tex/latex/nicetext/makedoc.sty +++ b/Master/texmf-dist/tex/latex/nicetext/makedoc.sty @@ -1,543 +1,1148 @@ %% Macro package `makedoc.sty' for LaTeX2e, + %% copyright (C) 2009 2010 Uwe L\"uck, + %% http://www.contact-ednotes.sty.de.vu + %% -- author-maintained in the sense of LPPL below -- + %% for preparing documentations from packages. -\def\fileversion{0.3} \def\filedate{2010/03/19} + + +\def\fileversion{0.4} \def\filedate{2010/03/30} + + %% This file can be redistributed and/or modified under + %% the terms of the LaTeX Project Public License; either + %% version 1.3a of the License, or any later version. + %% The latest version of this license is in + %% http://www.latex-project.org/lppl.txt + %% We did our best to help you, but there is NO WARRANTY. + %% + %% Please report bugs, problems, and suggestions via + %% + %% http://www.contact-ednotes.sty.de.vu + %% + \NeedsTeXFormat{LaTeX2e}[1994/12/01] + % 1994/12/01: \newcommand* etc. + \ProvidesPackage{makedoc}[\filedate\space v\fileversion\space + TeX input from *.sty (UL)] + %% + %% |\PackageCodeTrue| and |\PackageCodeFalse| set `\ifPackageCode' + %% globally, so redefinition of `~' (playing a key role in 'fifinddo') + %% may be kept local. Note the capital `T' and `F'! + \newcommand*{\PackageCodeTrue} {\global\let\ifPackageCode\iftrue} + \newcommand*{\PackageCodeFalse}{\global\let\ifPackageCode\iffalse} + %% |\ifPackageCode| is used to determine whether a listing environment + %% must be `\beg'un or `\end'ed. You may also want to suppress empty + %% code lines, while empty lines should issue a `\par' break in + %% ``comment" mode. + %% + %% Since `\newif' is not used, `\ifPackageCode' must be declared + %% explicitly. Declaration of new `\if's must be early in case + %% they occur in code that is skipped by another `\if'\dots + %% [TODO!? cf. others 2010/03/15] + \PackageCodeFalse + %% + %% 'makedoc' is an extension of 'fifinddo' on which it depends. + \RequirePackage{fifinddo}[2009/04/13] + %% Both 'fifinddo' and 'makedoc' use the ``underscore" `_' + %% as ``private letter" and restore its standard ``subscript" + %% function ({\it \TeX book Chap.\,7}) at their end. + %% Push\slash pop functionality as with `@' and `\RequirePackage' + %% is missing here. So after loading 'fifinddo', + %% we need to declare our private letter (again). + \catcode`\_=11 %% underscore used in control words + %% + %% \subsection{&\MakeDocCorrectHook\ (\dqtd{`txt2TeX'})} + %% |\MakeDocCorrectHook| is predefined to leave its argument without + %% the enclosing braces, otherwise unchanged: + \let\MakeDocCorrectHook\@firstofone + %% Less efficiently, the same could have been set up as + % \newcommand*{\MakeDocCorrectHook}[1]{\ProcessStringWith{#1}{LEAVE}} + %% according to 'fifinddo'. + %% + %% It may be \emph{redefined} in a \emph{configuration} file like + %% 'makedoc.cfg' or the 'makedoc' script file applying to a single + %% package file in order to, e.g., converting plain text to \TeX\ input + %% conforming to typographical conventions, making `$\dots$' from + %% \qtd{&.&.&.}, %% dots should not be replaced! + %% e.g. + %% Replace `LEAVE' in the previous suggestion by an identifier + %% whose job you have defined before, and use `\renewcommand' + %% in place of `\newcommand'. + %% See an example in 'makedoc.cfg'. + %% + %% You can \emph{test} your own `\MakeDocCorrectHook' by + %% \[`\typeout{\MakeDocCorrectHook{<test-string>}}'\] + %% ... provided (sometimes) `\MakeOther\ ' ... + %% You can even change it using `\IfInputLine' from 'fifinddo' in the + %% midst of preprocessing a package documentation. + %% -%% \subsection{Distinguish package code from comments}%% <- wiki style breaks in self-doc. + +%% \subsection{Distinguishing package code from comments}%% <- wiki style breaks in self-doc. + %% \label{sec:distinguish} + %% Use of comment marks is a matter of personal style. Only lines + %% starting with the sequence |%% | %% box 2010/03/16 + %% are typeset in \TeX\ quality + %% under the present release. Lines just containing |%%| + %% (without the space) are used to suppress empty code lines + %% preceding section titles (while keeping some visual space + %% in the package file). There is a preferable way to do this, + %% however not in the present release ... + %% + %% The parsing macros must be set up reading `%' and ` ' as ``other" + %% characters. Using the optional arguments for this creates + %% difficulties that can be somewhat avoided by redefining + %% |\PatternCodes|. + +\SetPatternCodes{\MakeOther\%\MakeOther\ }%% 2010/03/30 + %% -\renewcommand*{\PatternCodes}{\MakeOther\%\MakeOther\ }%% 2009/04/02 -%% + %% The next line sets the ``sandbox" for the detecting macro, as it + %% is coined in the documentation of 'fifinddo', with ``identifier" + %% |PPScomment|. + \MakeSetupSubstringCondition{PPScomment}{%% }{{#1}} + %% The last argument stores the expanded input line for reference by + %% macros called. The next line is a test whether the setup works. + % \expandafter \show \csname \setup_substr_cond PPScomment\endcsname + %% Here comes the definition of the corresponding testing macro. + %% #3 is the expanded input line from above. The `\If'\dots commands, + %% `\fdInputLine', `\fdInputLine', and `\RemoveDummyPatternArg' + %% are from 'fifinddo'. -\MakeSubstringConditional{PPScomment}{%% }#3{%% #3 entire test string + +\MakeSubstringConditional{PPScomment}{%% }#3{%% #3 entire test string + + \DecideCommentCode{#1}{#2}{#3}\PPstring} + +%% |\DecideCommentCode{#1}{#2}{#3}{#4}| is shared with the parser + +%% for the \lq`% '\rq\ commenting style. %% new 2010/03/28 + +\newcommand*{\DecideCommentCode}[4]{% + \IfFDinputEmpty{\OnEmptyInputLine}{% + %% The empty line test comes early to offer control with -%% `\OnEmptyInputLine' both code and comment mode. + +%% `\OnEmptyInputLine' both in code and comment mode. + %% Maybe it should always? %% TODO 2009/04/13 - \IfFDempty{#1}%% + + \IfFDempty{#1}% + {\TreatAsComment{% + \RemoveDummyPatternArg\MakeDocCorrectHook{#2}}}% - {\ifx\fdInputLine\PPstring - \ifPackageCode\else \WriteResult{}\fi%% 2009/04/05 - %% <- allow paragraphs in comments + + {\ifx\fdInputLine#4% + + \ifPackageCode\else \WriteResult{}\fi% + +%% ... allows paragraphs in comments. + \else \TreatAsCode{#3}\fi}}} -% \expandafter \show \csname \substr_cond PPScomment\endcsname -%% |\PPstring| stores the line suppressing empty code lines. + +%% Job |PScomment| deals with the |% | commenting style: + +\MakeSetupSubstringCondition{PScomment}{% }{{#1}} + +\MakeSubstringConditional{PScomment}{% }#3{% + + \DecideCommentCode{#1}{#2}{#3}\PercentChar} + +%% `\PercentChar' is from 'fifinddo'.---Return to `\fdPatternCodes': + +\ResetPatternCodes %% 2010/03/30 + +%% + +%% |\PPstring| stores the line suppressing empty code lines with + +%% the \lq`%% '\rq\ style: + \newcommand*{\PPstring}{} \xdef\PPstring{\PercentChar\PercentChar} + +%% + %% |comment| will be a ``generic" identifier to call a comment line + %% detector. It might be predefined to issue an ``undefined" error; -%% however this release predefines it to behave like `PPScomment'. + +%% however this release predefines it to behave like `PPScomment': + \CopyFDconditionFromTo{PPScomment}{comment} + +%% This means that the \lq`%% '\rq\ commenting style is assumed by + +%% default. \[`\CopyFDconditionFromTo{PScomment}{comment}'\] + +%% switches to the \lq`% '\rq\ style (with the {\it Wikipedia} + +%% sectioning parser). + +%% Or just choose \[`\ProcessInputWith{PScomment}'\] as <main-parser> + +%% (without the {\it Wikipedia} feature). + +%% + %% Alternative still to be considered: + % \@namedef{\setup_substr_cond comment}{% + % \PackageError{makedoc}{Job `comment' not defined}% + % {Use \string\CopyFDconditionFromTo{comment}}} + %% + %% \subsection{Choice of package code environment} + %% With v0.3, we adopt the solution for typesetting package code + %% that was implemented in the former 'makedoc.cfg'. So we rely + %% on the `listing' and `listingcont' environments of the + %% 'moreverb' package. + %% + %% The earlier idea was that 'makedoc.sty' uses an undefined \LaTeX\ + %% environment `packagecode' that will be defined in 'makedoc.cfg'. + %% An accompanying idea was that 'makedoc' works before the + %% `\documentclass' line inside a group, while 'makedoc.cfg' + %% is read \emph{after} the `\documentclass' line. + %% + %% We now want to simplify things. We replace + %% \[`packagecode' \mbox{\quad by\quad } `mdPackageCode'\] + %% and define the new environment globally here. 'moreverb' + %% and our choice for `\listinglabel' are + %% called at `\begin{document}'---outside the possible group. + \gdef\mdPackageCode{% + \small + %% Get rid of 'niceverb' stuff: + % \MakeOther\`\MakeOther\'%% probably OK with moreverb + \MakeOther\<\MakeOther\|% + %% From the next occurrence of the environment onwards, + %% `listing' must be replaced by `listingcont'. We must + %% copy the previous code diligently. + \gdef\mdPackageCode{\small \MakeOther\<\MakeOther\|% + \listingcont}% + \listing{1}} + \gdef\endmdPackageCode{% + \endlisting + \global\let\endmdPackageCode\endlistingcont} + \AtBeginDocument{% + \RequirePackage{moreverb}% + \renewcommand*{\listinglabel}[1]{% + \llap{\scriptsize\rmfamily\the#1}\hskip\listingoffset\relax}% + } + +%% |\ResetCodeLineNumbers| may be needed to \emph{reset} + +%% 'moreverb''s (global!) code line number settings + +%% (\emph{first} line number + {\it modulo} for displaying) + +%% when combining documentations of \emph{more} than one package + +%% with the present solution for implementing `mdPackageCode': + +\newcommand*{\ResetCodeLineNumbers}{% + + \global\listing@line\@ne \gdef\listing@step{\@ne}} + %% + %% \subsection{Dealing with comments} + %% |\TreatAsComment{<text>}| writes <text> to the documentation + %% file. If we had ``package code" (were in ``code mode") so far, + %% the listing environment is ended first. + \newcommand*{\TreatAsComment}[1]{% + \ifPackageCode + \WriteResult{\string\end{mdPackageCode\@empty}}% + %% The `\@empty' here is a lazy trick to save self-documentation + %% fighting 'verbatim''s ``highlight" of finding ends of listings + %% (to be improved). %% TODO 2010/03/09 + %% + %% We always use `\string' to prevent macro expansion in `\write'ing + %% in place of \LaTeX's `\protect', + %% as long as 'fifinddo' simply uses the primitive `\write' in place + %% of \LaTeX's `\proteced@write' ... %% todo 2009/04/08 + \PackageCodeFalse + \EveryComment + % \_empty_code_lines_false + \fi + \WriteResult{#1}} + %% Here, |\EveryComment| is a macro hook for inserting material that should + %% not appear in a listing environment, I had tried this %% 2010/03/18 + %% successfully: + %% \begin{verbatim} + %% \gdef\EveryComment{% + %% \global\let\EveryComment\relax + %% \WriteResult{\string\AutoCmdVerbSyntax}} + %% \end{verbatim} + %% Initialized: + \global\let\EveryComment\relax %% should be changed globally. + %% + %% \subsection{Sectioning} + %% \label{sec:secparsers} + %% We provide a facility from 'wiki.sty' that imitates the sectioning + %% syntax used in editing \emph{Wikipedia} pages, in a different + %% implementation (better compatibility) and in a more general way. + %% On Wikipedia, `== Definition ==' works similar as + %% `\section{Definition}' does with \LaTeX. With the present + %% implementation, you can type, e.g., + %% \[`%%%%%%%%%%%%%%%%%%%%%% == Definition == %%%%%%%%%%%%%%%%%%%%%%'\] + %% to get a similar result. The number of `%' characters doesn't + %% matter, and there can be other stuff, however: additional `=' + %% symbols may harm. Three sectioning levels are supported, through + %% `==<text>==', `===<text>===', and `====<text>====' (deepest). + %% + %% There are three detector macros made for programmers. + %% The most general one is + %% In the following definitions, there is a single tilde to prevent + %% `=' symbols being gobbled by the test (realized by accident). + %% %% 2009/04/13 + %% \par\noindent %% 2010/03/11 + %% |\SectionLevelThreeParseInput|: + \newcommand*{\SectionLevelThreeParseInput}{% + \expandafter \test_sec_level_iii \fdInputLine ~========&} + %% |\SectionLevelTwoParseInput| + \newcommand*{\SectionLevelTwoParseInput}{% + \expandafter \test_sec_level_ii \fdInputLine ~======&} + %% and |\SectionLevelOneParseInput| + \newcommand*{\SectionLevelOneParseInput}{% + \expandafter \test_sec_level_i \fdInputLine ~====&} + %% allow skipping deeper levels for efficiency. + %% % TODO in fifinddo: setup for 2 strings in 1 line 2009/04/13 + %% + %% In the terminology of the 'fifinddo' documentation, the previous + %% three commands are ``sandbox builders." The following three + %% commands are the corresponding ``substring conditionals." + %% However, 'fifinddo' so far %% todo 2009/04/08 + %% only deals with \emph{single} substrings, while here we are + %% dealing with \emph{pairs} of substrings. We are not using + %% general setup macros, but define the parsing macros ``manually," + %% as it is typical in many other macros in 'latex.ltx' and other + %% \LaTeX\ packages. You can fool our macros easily, there is + %% no syntax check. %% todo 2009/04/08 + \def\test_sec_level_iii#1====#2====#3&{% + \IfFDempty{#2}% + {\test_sec_level_ii #1======&}% + {\WriteSection\mdSectionLevelThree{#2}}} + \def\test_sec_level_ii#1===#2===#3&{% + \IfFDempty{#2}% + {\test_sec_level_i #1====&}% + {\WriteSection\mdSectionLevelTwo{#2}}} + \def\test_sec_level_i#1==#2==#3&{% + \IfFDempty{#2}% + {\RemoveTildeArg \ProcessStringWith{#1}{comment}}% + {\WriteSection\mdSectionLevelOne{#2}}} + %% `\ProcessStringWith' here passes the expanded `\fdInputLine' + %% to the general comment detector. + %% + %% |\WriteSection{<command>}{<text>}| replaces an input line + %% with a line \[`<command>{<text>}'\] + %% in the documentation file and switches into ``comment mode." + %% One possible space between `=' and the beginning of <text> + %% and one possible space between the end of <text> and `=' + %% are removed. + %% The method of dealing with surrounding blank + %% spaces is new with v0.3, moreover we now rely on a new method in + %% 'niceverb.sty' v0.3 to support its single right quote feature in + %% section titles.\footnote{&\ignorespaces\ and &\unskip\ used + %% previously do not work in PDF bookmarks.} + \newcommand*{\WriteSection}[2]{% + \TreatAsComment{^^J#1{\trim_correct{#2}}^^J}} + %% Trimming ``other" spaces is a little more clumsy than + %% what the 'trimspaces' package does whose code is by + %% Morten H\o gholm. It still has inspired the following. + \begingroup \MakeOther\ %% CARE! we must not indent ... + \long\gdef\trim_correct#1{\trim_fosp$#1$ $} + \long\gdef\trim_fosp#1$ {% + \IfFDempty{#1}{\trim_losp$}{\trim_losp#1$ }} + %% So we have a string \lq`\trim_losp$<text>$ $'\rq. + \long\gdef\trim_losp$#1 ${\tidy_sp_trim#1$} + %% So we have a string \lq`\tidy_sp_trim<text>$ $'\rq + %% or \lq`\tidy_sp_trim<text>$$'\rq. + \long\gdef\tidy_sp_trim#1$#2${\MakeDocCorrectHook{#1}} + \endgroup + %% We insert `\section' using |\mdSectionLevelOne| etc.\ + %% which the programmer can redefine, e.g., when the + %% documentation is part of a `\section' (or even deeper) + %% according to the ``documentation driver" file. + \newcommand*\mdSectionLevelOne {\string\section} + \newcommand*\mdSectionLevelTwo {\string\subsection} + \newcommand*\mdSectionLevelThree{\string\subsubsection} + %% + %% This sectioning feature is not used in (the documentation) of + %% 'makedoc.sty'---\emph{definitions} of the parsing macros fool + %% the same macros ... + %% + %% \subsection{Commented code} + %% |\TreatAsCode{<text>}| is the opposite to `\TreatAsComment{<text>}': + \newcommand*{\TreatAsCode}[1]{% + \ifPackageCode + % \_empty_code_lines_true + \else + \WriteResult{\string\begin{mdPackageCode}}% + \PackageCodeTrue + \fi + \WriteResult{#1}% + % \WriteResult{\maybe_result_empty_line #1}% + % \let\maybe_result_empty_line\empty + } + %% + %% \subsection{Dealing with empty input lines} %% TODO use!? 2010/03/09 + %% \label{sec:emptylines} + %% |\OnEmptyInputLine| is a default setting (or hook) for what to do + %% with empty lines in the input file. The default is to insert an + %% empty line in the output file: + \newcommand*{\OnEmptyInputLine}{\WriteResult{}} + %% |\NoEmptyCodeLines| changes the setting to suppressing empty code + %% lines, while in ``comment mode" an empty input line \emph{does} + %% insert an empty line, for starting a new paragraph: + \newcommand*{\NoEmptyCodeLines}{%% suppress empty code lines + \renewcommand*{\OnEmptyInputLine}{% + \ifPackageCode \else \WriteResult{}\fi}} + %% There is a better policy---didn't work so far ... + %% + %% \subsection{Bundling typical things: script commands} + %% \label{sec:script} + %% Practical experience suggested the following shorthands, + %% combining commands from 'makedoc' and 'fifinddo'. + %% + %% \subsubsection{Output file and &\filelist\ entry} + %% |\LaTeXresultFile{<output>}| chooses <output> as name + %% for the output file and saves you the extra line for inserting + %% the `\ProvidesFile' line as with 'fifinddo''s + %% `\WriteProvides'---however, it differs, actually it is 'makedoc' + %% that wants to be mentioned with `\ProvidesFile' ... + %% %% (otherwise copied from 'fifinddo') ... + \newcommand*{\LaTeXresultFile}[1]{% + \ResultFile{#1}%%% \WriteProvides} + \WriteResult{% + \string\ProvidesFile{\result_file_name}% + [\the\year/\two@digits\month/\two@digits\day\space + automatically generated with makedoc.sty]}}% + %% \subsubsection{Choose input file and run!} + %% |\MakeDoc{<input>}| preprocesses <input> to render input for + %% \LaTeX, considering what is typical for a \LaTeX\ package as the + %% <input> one here: + \newcommand*{\MakeDoc}[1]{% + %% In case of a ``header" (see below) we change into ``code mode": + \ifnum\header_lines>\z@ + \WriteResult{\string\begin{mdPackageCode}}% + \PackageCodeTrue %% TODO both lines makedoc command!? + %% 2009/04/08 + \else \PackageCodeFalse \fi + %% The loop follows. There is a placeholder `\makd_doc_line_body' + %% that is predefined below and can be changed while processing the + %% <input> file. + \ProcessFileWith{#1}{% + \CountInputLines %% stepping line counter is standard + \make_doc_line_body + \process_line_message}% + %% Currently the ``VERSION HISTORY" or, more generally, + %% a final part of the <input> file is typeset verbatim + %% (for ``tabbing" in the version history), + %% so we must leave ``code mode" finally: + \ifPackageCode + \WriteResult{\string\end{mdPackageCode\@empty}}%% self-doc-trick + \PackageCodeFalse %% TODO both lines makedoc command!? 2009/04/08 + \fi + %% When the <input> file has been processed, certain default settings + %% might be restored---in case another <input> file is processed for the + %% same documentation document: + % \HeaderLines{0}% + % \MainDocParser{\SectionLevelThreeParseInput}%% TODO!? 2009/04/08 + } + %% |\MakeCloseDoc{<input>}| %% 2010/03/11 + %% just is a shorthand for + %% \[`\MakeClose{<input>}\CloseResultFile'\] + %% where `\CloseResultFile' is from 'fifinddo'. + \newcommand*{\MakeCloseDoc}[1]{\MakeDoc{#1}\CloseResultFile} + %% `\MakeDoc' and `\MakeCloseDoc' actually \emph{process} + %% the <input> file, + %% depending on certain \emph{parameters} some of which are set + %% by the commands described next. + %% + %% \subsubsection{Preamble vs.\ main part of input file} + %% A \LaTeX\ package typically has a ``header" or ``preamble" + %% (automatically inserted by 'docstrip') with very scarce information + %% on which file it is and what it provides, and with much more Legalese. + %% Typesetting it in \TeX\ quality may be more misleading than + %% typesetting it \emph{verbatim}. So we typeset it \emph{verbatim}. + %% Now: where does the ``header" end? + %% `\NeedsTeXFormat' might be considered the border.---Yet it seems + %% to be more simple and reliable just to act in terms of the + %% \emph{number of lines} + %% that the header should be long. This length <how-many-lines> is declared by + %% |\HeaderLines{<how-many-lines>}|: + \newcommand*{\HeaderLines}{\def\header_lines} + \HeaderLines{0} + %% So the default is that there aren't any header lines, unless + %% another `\HeaderLines' is issued before some `\MakeDoc'. + %% The way input is parsed \emph{after} the ``header" is set by + %% |\MainDocParser{<parsing-command>}|. + \newcommand*{\MainDocParser}{\def\main_doc_parser} + %% `\SectionLevelThreeParseInput' from section~\ref{sec:secparsers} + %% is the default, two alternatives are defined there, another one is + %% `\ProcessInputWith{comment}' from 'fifinddo' and + %% %% clarified 2010/03/09 `\ref' 2010/03/10 + %% section~\ref{sec:distinguish} + %% (general dividing into code and comments). + \MainDocParser{\SectionLevelThreeParseInput} + %% Here is how `\HeaderLines' and `\MainDocParser' act: + \def\make_doc_line_body{% + \IfInputLine{>\header_lines}% + {\let\make_doc_line_body\main_doc_parser + \make_doc_line_body}% %% switch to deciding + {\TreatAsCode{\fdInputLine}}} %% header verbatim + %% \subsubsection{Screen messages} + %% |\ProcessLineMessage{<command>}| is designed to choose a screen + %% (or log) message <command>. + %% % A simple setting may be \[`\ProcessLineMessage{\message{.}}'\] with + %% `\ProcessLineMessage{\message{.}}' has a result like with 'docstrip'. + %% You just get one dot on screen per input line + %% as a simple confirmation that + %% the program is not hung up. %% TODO phrase!? 2009/04/08 + %% However, the message may slow down a run considerably + %% (if so, choose `\ProcessLineMessage{}' in the script). + %% % , you really have to + %% % wait about a second while you hardly notice the 'makedoc' run + %% % without screen messages. Therefore, the default is \emph{not} + %% % to issue any screen message.%% TODO more complex procedures!? 2009/04/08 + %% %---No! + %% But it is better for beginner users of the package, + %% so made default. %% 2009/04/09 + \newcommand*{\ProcessLineMessage}{\def\process_line_message} + % % \ProcessLineMessage{} %% no, still more efficient: + % \let\process_line_message\relax + \ProcessLineMessage{\message{.}} + %% + %% \subsubsection{Bundling-bundling Standalones} + %% |\MakeInputJobDoc{<header-lines>}{<main-parser>}| + %% by default produces a file + %% \[`\jobname.doc' \mbox{\quad from\quad } `\jobname.sty'\] + %% with some standard settings.\footnote{This command is new with v0.3.} + %% 'mdoccorr.cfg' (for `.txt'$\to$\LaTeX\ functionality) is read, + %% `\HeaderLines{<header-lines>}' + %% and `\MainDocParser{<main-parser>}' and finally + %% `\MakeCloseDoc{\jobname.sty}{\jobname.doc}' + %% % (with the arguments named before) + %% are executed. + %% Here `\jobname' expands to the file name base of the + %% `.tex' file you are running. It is assumed that you are preparing + %% documentation for `\jobname.tex' for your `\jobname.sty'. + %% In order to produce `<my-job>.doc' from `<my-job>.sty' instead, + %% \[`\renewcommand{\mdJobName}{<my-job>}'\] + %% If your input file has a different file name extension + %% <in-ext> than \qtd{`sty'}, use an optional argument + %% of `\MakeInputJobDoc': + %% \[|\MakeInputJobDoc[<in-ext>]{<header>}{<parser>}|\] + %% If the output file + %% should have a different extension <out-ext> than \qtd{`doc'}, + %% you must use \emph{two} optional arguments as follows: + %% \[|\MakeInputJobDoc[<in-ext>][<out-ext>]{<header>}{<parser>}|\] + %% `\MakeInputJobDoc' does \emph{not} execute `\ProcessLineMessage', + %% you can use the latter before so `\MakeInputJobDoc' respects it. + %% + %% |\MakeJobDoc| does the same as `\MakeInputJobDoc' apart from + %% typesetting the <created> file, so the latter needs an additional + %% `\input{<created>}'. + %% + %% My original idea was that all preprocessing of package files + %% to be documented should <happen> \emph{before} + %% `\documentclass'---loading + %% 'makedoc.sty' included---inside a group (\lq`{<happen>}'\rq---in + %% order to avoid compatibility issues). + %% However, it now appears to me that loading 'makedoc' the usual way + %% in the document \emph{preamble} + %% and processing the package file (that is to be documented) + %% within the `document' environment works well enough and + %% will be easier to comprehend. + %% + %% This is the code for both `\MakeJobDoc' and `\MakeInputJobDoc': + \@ifdefinable{\mdJobName}{\let\mdJobName\jobname} + \newif\if_makedoc_input_ + \newcommand*{\MakeInputJobDoc}{\_makedoc_input_true + \make_job_doc_read} + \newcommand*{\MakeJobDoc} {\_makedoc_input_false + \make_job_doc_read} + \newcommand*{\make_job_doc_read}[1][sty] + {\@testopt{\make_job_doc[#1]}{doc}} + %% Reading files as follows would fail with active 'niceverb' settings, + %% so we issue `\noNiceVerb' if it is defined. We do it inside a group + %% in case 'niceverb' settings are to be restored afterwards. + \def\make_job_doc[#1][#2]#3#4{% + \begingroup + \@ifundefined{noNiceVerb}{}% + {\let\MakeNormal\MakeNormalHere \noNiceVerb}% + \input{mdoccorr.cfg}% + %% <- TODO warning if not found!? + %% or if one from TEXMF/ used inadvertently!? + %% avoid reading twice!? 2010/03/11 + %% <- TODO stack danger in group!? 2010/03/13 + %% <- TODO or read it from 'makedoc' already! 2010/03/13 + \LaTeXresultFile{\mdJobName.#2}% + \HeaderLines{#3}% + \MainDocParser{#4}% + \MakeCloseDoc{\mdJobName.#1}% + %% For typesetting the file just created, some 'nicetext' features + %% may be needed ... so restore the previous ones ... + \endgroup + \if_makedoc_input_\input{\mdJobName.#2}\fi + } + %% This feature may \emph{change}. + %% + %% \subsection{Leave the package} + \catcode`\_=8 %% restores underscore use for subscripts + \endinput + %% + %% \subsection{VERSION HISTORY} + + v0.1 2009/04/03 very first version, tested on morgan.sty + v0.2 2009/04/05 \OnEmptyInputLine, \NoEmptyCodeLines + comment -> PPScomment, \IfFDinputEmpty, + \EveryComment, \PPstring may be par break + 2009/04/08 \InputString -> \fdInputLine, + \section -> \subsection; documentation! + 2009/04/08f. \MakeDoc + 2009/04/12 ``line too long'' w/o redefining \PatternCodes; + \MakeDocCorrectHook + 2009/04/13 tilde with sectioning + v0.3 2010/03/08 \WriteSection 'trimspaces'-like + 2010/03/09 "fool" ("wiki" sectioning) nicer worded, + more use of `...' in place of `\dots'; + different treatment of package code environment + (new separate subsection); clarification on + \ProcessInputWith{comment} + 2010/03/10 supplied `\ref' + 2010/03/11 \MakeCloseDoc; corrected "undifined"; + \par\noindent in ``Sectioning"; \MakeJobDoc + 2010/03/12 &.&.&.; updated copyright + 2010/03/13 corr.: `_' not ``other"; tried to explain my + earlier reasoning about `\ifPackageCode'; + \MakeInputJobDoc + 2010/03/14 \make_doc_job without \niceverb_aux_cat + 2010/03/15 another remark to \ifPackageCode + 2010/03/16 use box with comment line markers; + mdcorr -> mdoccorr + 2010/03/18 report on using \EveryComment + 2010/03/19 '' -> " + +v0.4 2010/03/23 "Distinguishing" + + 2010/03/24 "both in" + + 2010/03/27 switch back to \fdPatternCodes + + 2010/03/28 include `% ' commenting style + + 2010/03/29 \ResetCodeLineNumbers + + 2010/03/30 use \SetPatternCodes, \ResetPatternCodes + diff --git a/Master/texmf-dist/tex/latex/nicetext/mdoccorr.cfg b/Master/texmf-dist/tex/latex/nicetext/mdoccorr.cfg index 1d3ba475e95..665b037b0af 100644 --- a/Master/texmf-dist/tex/latex/nicetext/mdoccorr.cfg +++ b/Master/texmf-dist/tex/latex/nicetext/mdoccorr.cfg @@ -1,32 +1,80 @@ -\ProvidesFile{mdoccorr.cfg}[2010/03/23 +\ProvidesFile{mdoccorr.cfg}[2010/03/29 + local typographical corrections + with `makedoc.sty'] -%% ... also demonstrates 'niceverb.sty'. Some sanitizing: + +%% ... also demonstrates 'niceverb.sty'---see the typeset + +%% documentation of the present file in `makedoc.pdf'. + %% -\renewcommand*{\PatternCodes}{\MakeOther\\\MakeOther\ } + +%% |\SetPatternCodes{<commands>}| redefines + +%% `\PatternCodes' to be used in parsing and replacing + +%% (some ``sanitizing"). %% improved line breaks 2010/03/29 + +\SetPatternCodes{\MakeOther\\\MakeOther\ } + %% + %% |\MakeExpandableAllReplacer{<id>}{<find>}{<subst>}{<id-next>}|% + %% \footnote{Yes, + %% &\MakeExpandableAllReplacer{<id>}{<find>}{<subst>}{<id-next>}.} + \MakeExpandableAllReplacer{etc}{etc. }{etc.\ }{LEAVE} + %% So you can keep inter-sentence space after `etc.' + %% by a code line break. + %% + %% |\PrependExpandableAllReplacer{<id>}{<find>}{<subst>}|: + \PrependExpandableAllReplacer{cf}{cf. }{cf.\ } %% corr. 2010/03/23 + %% ... but think of `cf.~'. Don't leave `cf.' at code line end! + \PrependExpandableAllReplacer{dots}{...}{$\dots$} -%% ... chain starts here, and here |\MakeDocCorrectHook| enters: -\renewcommand*{\MakeDocCorrectHook}[1] - {\ProcessStringWith{#1}{dots}} + +%% ... chain starts here, and here |\MakeDocCorrectHook| (silently) + +%% enters through a default variant |\SetCorrectHookJobLast| + +%% of |\SetCorrectHookJob{<id>}|: + +\SetCorrectHookJobLast + %% -\renewcommand*{\PatternCodes}{\fdPatternCodes} + +%% |\ResetPatternCodes| resets `\PatternCodes' to their default + +%% value (which is `\fdPatternCodes'): + +\ResetPatternCodes + %% ... restores 'fifinddo' default. + \endinput + + HISTORY + 2009/04/05 with makedoc v0.2 + 2010/03/11 broke some too long code lines + 2010/03/16 rendered `mdoccorr.cfg' + 2010/03/22 try \Prepend... + 2010/03/23 corrected `cf' + +2010/03/29 use \SetPatternCodes etc. + diff --git a/Master/texmf-dist/tex/latex/nicetext/niceverb.sty b/Master/texmf-dist/tex/latex/nicetext/niceverb.sty index 823093a1020..22e0ad3aa2a 100644 --- a/Master/texmf-dist/tex/latex/nicetext/niceverb.sty +++ b/Master/texmf-dist/tex/latex/nicetext/niceverb.sty @@ -1,756 +1,1546 @@ \NeedsTeXFormat{LaTeX2e}[1994/12/01] -\ProvidesPackage{niceverb}[2010/03/23 v0.32 + +\ProvidesPackage{niceverb}[2010/03/29 v0.4 + minimize doc markup (UL)] + + %% Copyright (C) 2009, 2010 Uwe Lueck, + %% http://www.contact-ednotes.sty.de.vu + %% -- author-maintained in the sense of LPPL below -- + %% + %% This file can be redistributed and/or modified under + %% the terms of the LaTeX Project Public License; either + %% version 1.3a of the License, or any later version. + %% The latest version of this license is in + %% http://www.latex-project.org/lppl.txt + %% We did our best to help you, but there is NO WARRANTY. + %% + %% Please report bugs, problems, and suggestions via + %% + %% http://www.contact-ednotes.sty.de.vu + %% + %% === Switching Category Codes === + %% v0.3 introduces `\AssignCatCodeTo' and `\MakeNormal'. + %% + %% |\CatCode{\<character>}| + %% (or simply |\CatCode\<character>|) + %% saves one token per use and works when the category code + %% of \qtd{&`} (``single left quote") has changed. + \newcommand*{\CatCode}{\catcode`} + % \newcommand*{\CatCode}[1]{\catcode`#1 } %% no better 2010/02/27 + %% With |\AssignCatCodeTo{<number>}{\<char>}|, + %% `\CatCode' may still be useful for displaying + %% (debugging or playing). + %% Note that `\<char>' is the {\it second} argument here. + \newcommand*{\AssignCatCodeTo}[2]{\catcode`#2=#1\relax} + %% |\MakeLetter\<char>| is used for \emph{private letters}, i.e., + %% to allow <char> in ``internal", non-user control sequences + %% ({\it\TeX book} Chap.\,3). + %% |\MakeOther| is just a different implementation of + %% \LaTeX's \cs{@makeother}. + \newcommand*\MakeLetter{\AssignCatCodeTo{11}} + \def \MakeOther {\AssignCatCodeTo{12}} + %% ... overriding 'fifinddo' if ... %% TODO 2010/03/12 + %% + %% |\MakeActive\<char>| just revives the meaning of <char> + %% it had most recently + %% (as an &\active character ... + %% maybe ``Undefined control sequence" unless ...) + %% This is fine for reviving 'niceverb' functionality + %% after having disabled it by `\MakeNormal'\linebreak[0]---provided + %% no other package used <char> actively in the meantime ... + \providecommand*{\MakeActive}{\AssignCatCodeTo\active} %% used v0.3 + %% We take a copy |\MakeActiveHere| of `\MakeActive' + %% as the latter may become a dangerous thing for compatibility + %% with 'hyperref'. + \@ifdefinable\MakeActiveHere{% + \let\MakeActiveHere\MakeActive} + %% <- TODO aliascid + elsewhere 2010/03/12 + %% |\MakeActiveLet\<char><macro name>| activates <char> + %% and then gives it the meaning of <macro name>. + \newcommand*{\MakeActiveLet}[2]{%% cf. \@sverb/\do@noligs (doc.sty) + \MakeActiveHere#1% %% 2010/03/12 + \begingroup + \lccode`\~`#1\relax \lowercase{\endgroup \let~#2}} + %% We take a copy |\MakeActiveLetHere| as well. + \@ifdefinable\MakeActiveLetHere{% + \let\MakeActiveLetHere\MakeActiveLet} + %% %% |\MakeAlign\&| can be used to restore the meaning of `&' after we + %% %% have made it `\active'. + %% % \providecommand*{\MakeAlign} {\AssignCatCodeTo4} + %% We use the ``underscore" as a private letter + %% (the \LaTeX2 Project Team likes it as well). + %% Its usual meaning can be restored by |\MakeNormal\_| + %% For restoring the usual category codes of \TeX's special + %% characters later, we store them now. + %% (I.e., these characters are listed in the macro `\dospecials' + %% that expands to + %% $$\mbox{\tt\def\do{\string\do\unskip\string}\dospecials}$$ + %% their category codes are + %% {\AssignCatCodeTo{6}{\#}% + %% \AssignCatCodeTo{3}{\$}%% fifinddo-interference!? TODO 2010/02/27 + %% \AssignCatCodeTo{4}{\&}%% fifinddo-interference!? TODO 2010/02/27 + %% \def\do#1{\def\do##1{, + %% \the\CatCode##1}\the\CatCode#1}\dospecials} + %% respectively; ``end of line", ``ignored", ``letter", ``other", and + %% ``invalid" are missing---cf. {\it \TeX book} Chap.\,7.) + \def\do#1{\expandafter + \chardef \csname normal_catcode_\string#1\expandafter \endcsname + \CatCode#1\relax} + \dospecials + %% Tests: + %% ``normal category code" of `\' is + %% \expandafter\the\csname normal_catcode_\string\\\endcsname, + %% ``normal category code" of `$' is + %% \expandafter\the\csname normal_catcode_\string\$\endcsname; + %% ``normal category code" of `&' is + %% \expandafter\the\csname normal_catcode_\string\&\endcsname.%%% + %% \footnote{\LaTeX's \cs{nfss@catcodes} is similar, + %% but it makes space-like characters ignored. + %% Also cf. 'ltfinal.dtx'. + %% TODO: &\RestoreNormalCatcodes.} %% 2010/03/06 + %% + %% Here we switch to the ``underscore" as a ``letter" indeed + %% (for the rest of the package): + \MakeLetter\_ + + % \newcommand*{\make_iii_other}{\MakeOther\\\MakeOther\{\MakeOther\}} + %% <- replaced 2009/04/05 + %% |\MakeNormal\<char>| saves you from remembering ... + \newcommand*{\MakeNormal}[1]{% + \@ifundefined{\norm_catc_str#1}% + {\MakeOther#1}% + {\AssignCatCodeTo{\csname\norm_catc_str#1\endcsname}#1}} + \newcommand*{\norm_catc_str}{normal_catcode_\string} + %% TODO add ^^I and ^^M + %% We take a copy |\MakeNormalHere| of `\MakeNormal' as + %% with `\MakeActive'. + \@ifdefinable\MakeNormalHere{\let\MakeNormalHere\MakeNormal} + %% + %% === Robustness by &\IfTypesetting === + %% It seems we need some own ways to achieve various + %% compatibilities---using |\IfTypesetting{<if>}{<unless>}|. + %% It also saves some `\expandafter's. + \providecommand*{\IfTypesetting}{% + % \relax + %% This `\relax' suppressed ligatures of single right quotes! + %% %% removed 2010/03/23 + \ifx \protect\@typeset@protect + \expandafter \@firstoftwo + \else \expandafter \@secondoftwo \fi} + %% + %% === &\NVerb === + %% `\begin_min_verb' is a beginning shared by some macros here. + %% It begins like \LaTeX's `\verb', apart from the final `\tt'. + \newcommand*{\begin_min_verb}{% + \relax \ifmmode \hbox \else \leavevmode\null \fi + \bgroup \tt} + %% |\NVerb<char><code><char>| + \newcommand*{\NVerb}{% + \_no_nice_meta_verb_false \nice_maybe_meta_verb} + %% |\HardNVerb<char><code><char>| does not recognize meta-variables: + \newcommand*{\HardNVerb}{% + \_no_nice_meta_verb_true \nice_maybe_meta_verb} + \newif\if_no_nice_meta_verb_ + \newcommand*{\nice_maybe_meta_verb}[1]{% + %% Mainly avoid `\verb''s noligs list which overrides definitions + %% of some active characters, while 'cmtt' doesn't have any + %% ligatures anyway. + \IfTypesetting{% + \begin_min_verb + \let\do\MakeOther \dospecials + %% Turn off 'niceverb' specials: + \MakeOther\|\MakeOther\`\MakeOther\'% + \if_no_nice_meta_verb_\MakeOther\<\fi + \MakeActiveLetHere #1\niceverb_egroup + \verb@eol@error %% TODO change message 2009/04/09 + }{\string\NVerb \string#1}} + %% 2009/04/11: about `etc.' [preceding a box!? 2010/03/14] + \newcommand*{\niceverb_normal_egroup}{\egroup \ifmmode\else\@\fi} + \@ifdefinable\niceverb_egroup + {\let\niceverb_egroup\niceverb_normal_egroup} + %% + %% === Single Quotes Typeset Meta-Code === + %% |\LQverb| will be a ``permanent alias" + %% for the active left single quote. + %% + %% The verbatim feature must not act when another single left + %% quote is ahead---we assume a double quote is intended then + %% (thus the left quote feature does not allow to typeset + %% something verbatim that starts with a single left quote). + %% Rather, double quotes should be typeset then. + %% In page headers, a `\protect' may be in the way. + %% (A hook for `\relax'ing certain things in + %% `\markboth' and `\markright' would have been an alternative.) + \MakeActive\` + \newcommand*{\LQverb}{% + \IfTypesetting{\lq_double_test}{\protect`}} + \MakeOther\` + \newcommand*{\lq_double_test}{% + %% This test settles the next catcode, so better switch to ``other" + %% in advance (won't harm if left quote isn't next): + \begingroup + \let\do\MakeOther \dospecials + \MakeOther\|%% 2010/03/09! + \futurelet\let_token \lq_double_decide} + \newcommand*{\lq_double_decide}{% + \ifx\let_token\LQverb + \endgroup + ``\expandafter \@gobble + %% Corresponding right quotes will become ``other" due to + %% having no space at the left. + %% TODO to be changed with 'wiki.sty'. + \else + \ifx\let_token\protect + \expandafter\expandafter\expandafter \lq_double_decide_ii + \else + \endgroup + \expandafter\expandafter\expandafter \NVerb + \expandafter\expandafter\expandafter \'% + \fi + \fi} + %% `\lq_double_decide_ii' continues test behind `\protect'. + \newcommand*{\lq_double_decide_ii}[1]{% + \futurelet\let_token \lq_double_decide} + %% + %% === Ampersand (or &\cstx) Typesets Meta-Code === + %% |\CmdSyntaxVerb| will be a permanent alias for the active `&'. + \MakeActive\& + \newcommand*{\CmdSyntaxVerb}{% + \IfTypesetting{% + \begin_min_verb + %% v0.3 moves the previous line from &\cmd_syntax_verb + %% %% <- shows bug is fixed 2010/03/09 + %% where it is too late to establish private letters + %% according to next line which was in `\begin_min_verb' + %% earlier---an important bug fix! + \MakeLetter\@\MakeLetter\_% + \cmd_syntax_verb + }{\protect&\string}} + \MakeNormal\& + \newcommand*{\cmd_syntax_verb}[1]{% + \string#1\futurelet\let_token \after_cs} + %% However, `&' (or `\CmdSyntaxVerb') + %% may fail with private letters + %% (there should be a hook for them), %% TODO 2010/02/28 + %% especially in \emph{macro arguments} %% 2010/03/05 + %% and with 'hyperref' in titles of %% 2010/03/11 + %% \emph{sections bearing \cs{label}s}, + %% so we provide something like |\cs{<characters>}| from 'doc.sty'. + \DeclareRobustCommand*{\cs}[1]{% + \begin_min_verb \backslash_verb #1\egroup} + \newcommand*{\backslash_verb}{\char`\\} + %% Moreover, typing `&\par' in ``short" \emph{macro arguments} + %% fails, you better type `\cs{par}' then. Likewise, + %% `\cs{if<letters>}' and `\cs{fi}' is safer in case + %% you want to skip some part of the documentation + %% (e.g., a package option skips commented code) + %% by \cs{if}`<letters>'\cs{fi}. + %% Finally, there will be PDF bookmarks support for `\cs' + %% rather than for a real `&' or `\CmdSyntaxVerb' analogue like + %% |\cstx{<charcters>}*[<opt>]{<mand>}| as follows. + \DeclareRobustCommand*{\cstx}[1]{% %% corr. 2010/03/17 + \begin_min_verb \backslash_verb #1\futurelet\let_token \after_cs} + \newcommand*{\after_cs}{% + \ifcat\noexpand\let_token a\egroup \space + \else \expandafter \decide_verb \fi} + \newcommand*{\test_more_verb}{\futurelet\let_token \decide_verb} + \newcommand*{\decide_verb}{% + \jumpteg_on_with\bgroup\braces_verb + \jumpteg_on_with[\brackets_verb + \jumpteg_on_with*\star_verb + \egroup} + %% CAUTION/TODO wrong before (... if cmd without arg + %% use \ then or choose usual verb... + %% or \MakeLetter\( etc. ... or \xspace + \newcommand*{\jumpteg_on_with}[2]{% + \ifx\let_token#1\do_jumpteg_with#2\fi} + %% TODO cf. 'xfor', 'xspace' (&\break@loop); + %% `\DoOrBranch#1...#1' or so. %% found 2010/03/05 + \def\do_jumpteg_with#1#2\egroup{\fi#1} + \def\braces_verb#1{\string{#1\string}\test_more_verb} + \def\brackets_verb[#1]{[#1]\test_more_verb} + \def\star_verb*{*\test_more_verb} + %% not needed with \Auto... OTHERWISE useful in args! + %% %%2010/03/15: + %% As 'latex.ltx' has `\endgraf' as a permanent alias for the + %% primitive version of `\par' and `\endline' for `\cr', + %% we offer |\endcell| as a replacement for the original `&': + \let\endcell& + %% + %% === Escape Character Typesets Meta-Code === + %% |\BuildCsSyntax| will be a permanent alias for the active escape + %% character. + \DeclareRobustCommand*{\BuildCsSyntax}{% + \futurelet\let_token \build_cs_syntax_sp} + \newcommand*{\build_cs_syntax_sp}{% + \ifx\let_token\@sptoken \else %% TODO ^^M!? + \expandafter \start_build_cs_syntax + \fi} + \newcommand*{\start_build_cs_syntax}[1]{% - \edef\string_built{\string#1}%% #1 may be active + + \edef\string_built{\string#1}% + +%% #1 may be active.---With Donald Arseneau's 'import.sty' (e.g.), + +%% \qtd{&_} may be needed to be `\active' with the meaning of + +%% `\textunderscore', therefore restoring its category code + +%% needs some more care than with v0.32 and earlier: + + \edef\before_build_cs_sub{\the\CatCode\_}% + \MakeLetter\_\MakeLetter\@%% CAUTION, cf. ... + \test_more_cs} + \newcommand*{\test_more_cs}{% + \futurelet\let_token \decide_more_cs} + \newcommand*{\decide_more_cs}{% + \ifcat\noexpand\let_token a\expandafter \add_to_cs + \else - \MakeNormalHere\_\MakeOther\@% + +% \MakeNormalHere\_ + +%% Restoring \qtd{&_} more carefully with v0.33 + +%% (`\begingroup' ... `\endgroup'!?): + +%% %% 2010/03/27 + + \CatCode\_\before_build_cs_sub + + \MakeOther\@% + \expandafter \in@ \expandafter + {\csname \string_built \expandafter \endcsname + \expandafter}\expandafter{\niceverbNoVerbList}% + \ifin@ + \csname \string_built + \expandafter\expandafter\expandafter \endcsname + \else + \begin_min_verb \backslash_verb\string_built + \expandafter\expandafter\expandafter \test_more_verb + \fi + \fi} + %% TODO such \if nestings with ifthen!? + %% cf.: + % \let\let_token,\typeout{\meaning\let_token} + %% TEST TODO fuer xspace!? (\ifin@) + \newcommand*{\add_to_cs}[1]{% + \edef\string_built{\string_built#1}\test_more_cs} + %% + %% |\AutoCmdSyntaxVerb| starts, |\EndAutoCmdSyntaxVerb| \emph{ends} + %% ``auto mode." + \newcommand*{\AutoCmdSyntaxVerb}{% + \MakeActiveLetHere\\\BuildCsSyntax} + \newcommand*{\EndAutoCmdSyntaxVerb}{\CatCode\\\z@} + %% |\NormalCommand{<characters>}| executes `\<characters>' + %% in ``auto mode." + \newcommand*{\NormalCommand}{} \let\NormalCommand\@nameuse + %% %% 2010/03/11: + %% Once I may want to use this feature in {\it Wikipedia}-like + %% section titles as supported by 'makedoc', yet I cannot really + %% apply the present feature soon, so this must wait ... + %% (There is a special problem with `\newlabel' and 'hyperref' ...) + %% + %% Former tests: + % \futurelet\LetToken\relax \relax + % \show\LetToken \typeout{\ifcat\noexpand\LetToken aa\else x\fi} + %% + %% |\niceverbNoVerbList| is the list of macros that will be + %% \emph{executed} instead of being typeset. + \newcommand*{\niceverbNoVerbList}{% + \begin\end\item\verb\EndAutoCmdSyntaxVerb\NormalCommand + \section\subsection\subsubsection} %% TODO!? + %% |\AddToMacro{\niceverbNoVerbList}{<macros>}| can be used to + %% add <macros> to that list. + \providecommand*{\AddToMacro}[2]{% %% TODO move to ... 2010/03/05 + \expandafter \def \expandafter #1\expandafter {#1#2}} + %% <- was very wrong 2010/03/18 + +%% Hey, or just |\AddToNoVerbList{<macros>}|: %% 2010/03/28 + +\newcommand*{\AddToNoVerbList}{\AddToMacro\niceverbNoVerbList} + +%% + %% ``Auto mode" probably ain't mean a thing if it ain't invoked using + %% \[|\AutoCmdInput{<file>}|\] for typesetting <file> in ``auto mode:" + \newcommand*{\AutoCmdInput}[1]{% + %% I am not yet sure whether `\input' etc. should be in the exception + %% list permanently: %% TODO 2010/03/18 + \begingroup + \AddToMacro\niceverbNoVerbList{\ProvidesFile\endinput}% + %% <- TODO? 2010/03/18 + \AutoCmdSyntaxVerb + \input{#1}% + \EndAutoCmdSyntaxVerb + \endgroup + } + %% + %% === Meta-Variables === + %% |\MetaVar<var-id>>| will be a permanent alias for the active \qtd{&<}. + \def\MetaVar#1>{% + \mbox{\normalfont\itshape $\langle$#1\/$\rangle$}} + %% TODO offer without angles as well + %% As opposed to 'ltxguide.cls', this works outside verbatim as well. + %% + %% === Hash Mark is Code === + %% |\HashVerb<digit>| will be a permanent alias for the active hash mark. + \newcommand*{\HashVerb}[1]{{\tt\##1}} + %% + %% === Single Right Quotes for &\textsf === + %% |\RQsansserif| will be a permanent alias for the active single + %% right quote. + %% + %% The basic problem with the ``single right quote feature" + %% is that a single right quote may be meant to be an apostrophe. + %% This is certainly the case at the right of a letter. + %% On the other hand, we assume that it is \emph{not} an apostrophe + %% (i)~in vertical mode (opening a new paragraph), + %% (ii)~after a horizontal skip. + %% + %% For page headers, in expanding without typesetting, + %% the expansion of `\RQsansserif' must contain another active + %% single right quote.{\sloppy\par} + \MakeActive\' + \newcommand*{\RQsansserif}{% + \IfTypesetting{\niceverb_rq_sf_test}{\protect'}} + \MakeOther\' + %% Another macro just to avoid more sequences of `\expandafter': + \newcommand*{\niceverb_rq_sf_test}{% + \ifhmode + \ifdim\lastskip>\z@ + \expandafter\expandafter\expandafter \DoRQsansserif + \else + \ifnum\niceverb_spacefactor + \expandafter\expandafter\expandafter\expandafter + \expandafter\expandafter\expandafter + \DoRQsansserif + \else '\fi + \fi + \else \ifvmode + \expandafter\expandafter\expandafter \DoRQsansserif + \else '\fi + \fi} + %% |\DoRQsansserif| %% 2010/03/10 + %% is \emph{another} (possible) alias for the + %% active single right quote, see below. + \MakeActive\' + \@ifdefinable\DoRQsansserif + {\def\DoRQsansserif#1'{\textsf{#1}}} + \MakeOther\' + %% The following cases are typical and cannot be decided by the + %% previous criteria: + %% (i)~parenthesis, (ii)~footnotes and after ``horizontal" + %% environments like `\[<math>\]', (iii)~section titles, + %% (iv)~`\noindent'. + %% We introduce some dangerous tricks---redefinitions of + %% % \LaTeX's internals `\@footnotetext' and `\@sect' + %% %% <- 2010/03/16 -> + %% \LaTeX's internal `\@sect' and of \TeX's primitives + %% `\noindent' and `\ignorespaces' as well as by + %% a signal `\spacefactor' value of 1001. + %% In page headers, \LaTeX\ equips the single right quote with the + %% meaning of `\active@math@prime' which must be overridden. + \newcommand*{\nvAllowRQSS}{% + \MakeActiveLetHere\'\RQsansserif + \niceverb_ignore} %% 2010/03/16 + %% These and the entire right quote functionality are + %% activated by %% removed todo 2010/03/10 + %% \[|\nvRightQuoteSansSerif| + %% \mbox{\quad and disabled by\quad} + %% |\nvRightQuoteNormal|\]---at + %% `\begin{document}'---where we collect previous settings---or + %% later: + \AtBeginDocument{% + \edef\before_niceverb_parenthesis{\the\sfcode`\(}% + \let \before_niceverb_ignore \ignorespaces %% 2010/03/16 + \let \before_niceverb_sect \@sect + \let \before_niceverb_noindent \noindent} %% 2010/03/08 + %% We assume that `\@sect' has the same + %% % We assume that `\@footnotetext' and `\@sect' have the same + %% parameters there as in \LaTeX\ + %% (even if redefined by another package, like 'hyperref'). + \def\niceverb_sect#1#2#3#4#5#6[#7]#8{% + \before_niceverb_sect{#1}{#2}{#3}{#4}{#5}{#6}% + [{\protect\nvAllowRQSS #7}]% + {\protect\nvAllowRQSS #8}} + %% 2010/03/20: + \newcommand*{\niceverb_spacefactor}{\spacefactor=1001\relax} + \newcommand*{\niceverb_noindent}{% + \before_niceverb_noindent \niceverb_spacefactor} + \newcommand*{\niceverb_ignore}{% + \ifhmode \niceverb_spacefactor \fi \before_niceverb_ignore} + %% + %% Here are the main switches: + \newcommand*{\nvRightQuoteSansSerif}{% + \MakeActiveLet\'\RQsansserif + \sfcode`\(=1001 %% enable in parentheses 2009/04/10 + %% I also added \HardNVerb+\sfcode`/=1001+ in the preamble + %% of 'makedoc.tex'. %% 2010/03/15 + % \let\@footnotetext\niceverb_footnotetext + \let\ignorespaces\niceverb_ignore %% 2010/03/16 + \let\@sect\niceverb_sect + \let\noindent\niceverb_noindent} %% 2010/03/08 + \newcommand*{\nvRightQuoteNormal}{% + \MakeNormal\'% %% 2010/03/21 + \sfcode`\(=\before_niceverb_parenthesis\relax + \let\ignorespaces\before_niceverb_ignore %% 2010/03/16 + \let\@sect\before_niceverb_sect + \let\noindent\before_niceverb_noindent} %% 2010/03/08 + %% |\nvAllRightQuotesSansSerif| %% 2010/03/10 + %% (after `\begin{document}'!) + %% forces the `\textsf' feature + %% \emph{without} testing for apostrophes. You then must be + %% sure---DANGER! CARE!---to + %% use \qtd{&\rq} only for obtaining an apostrophe and the + %% double quote character \qtd{&"} for closing double quotes, + %% or our `\dqtd{<text>}' for the entire quoting. + \newcommand*{\nvAllRightQuotesSansSerif}{% + \nvRightQuoteNormal + \MakeActiveLet\'\DoRQsansserif} + %% I started v0.31 (signal `\sfcode'=1000, lowercase letters + %% get `\sfcode'=1001) because + %% \NVerb+\href{http://ctan.org/pkg/<pkg>}{<pkg>}+ failed. + %% However, what I actually needed was |\ctanpkgref{<pack-name>}|: + \DeclareRobustCommand*{\ctanpkgref}[1]{% + \href{http://ctan.org/pkg/#1}{\textsf{#1}}} + %% + %% === Command-Highlighting Boxes === + %% With v0.3, we include one kind of command syntax boxes + %% whose <content> is (in 'niceverb' syntax) + %% delimited as \GenCmdBox+|<content>|+. + %% %% 2010/03/14: + \newsavebox\niceverb_savebox + %% |\GenCmdBox<char><content><char>}| works like + %% `\NVerb<char><content><char>' except putting the latter's result + %% into a framed (or coloured or ...) box.{\sloppy\par} + \newcommand*{\GenCmdBox} {\_no_nice_meta_verb_false \gen_cmd_box} + %% |\HardVerbBox| is a variant of `\GenCmdBox' with the meta-variable + %% feature disabled + %% (for the documentation of the present package). + \newcommand*{\HardVerbBox}{\_no_nice_meta_verb_true \gen_cmd_box} + \newcommand*{\gen_cmd_box}{% + \bgroup + \let\niceverb_egroup\nice_collect_verb_egroup + \global %% TODO!? for \cmdboxitem 2010/03/15 + %% <- TODO replace \niceverb_egroup by parameter, + %% save one nesting level 2010/03/15 + \setbox\niceverb_savebox \hbox\bgroup + \if_no_nice_meta_verb_ + \expandafter \HardNVerb + \else \expandafter \NVerb \fi} + \newcommand*{\nice_collect_verb_egroup}{% + \egroup \egroup + \ifvmode \expandafter \VerticalCmdBox + \else \ifmmode \hbox \fi + \expandafter \InlineCmdBox \fi + {\box\niceverb_savebox}% + \niceverb_normal_egroup} + %% |\nvCmdBox| will be the permanent alias for \qtd{&|}. + \newcommand*{\nvCmdBox}{\GenCmdBox\|} + %% |\VerticalCmdBox{<content>}| + %% may eventually start a `decl' environment + %% as in 'ltxguide.cls', looking ahead for another \qtd{&|} + %% in order to (perhaps) append another row. + %% Another possibility is first to do some + %% \[`\if@nobreak\else \pagebreak[2]\fi'\] + %% etc. and then invoke `\InlineCmdBox'. + %% The user can choose later by some `\renewcommand'. + %% We do the perhaps most essential thing here + %% (again cf. `\begin_min_verb'):{\sloppy\par} + \newcommand*{\VerticalCmdBox}{\leavevmode\null\InlineCmdBox} + %% The command declaration boxes in the documentation of + %% Nicola Talbot's \ctanpkgref{datatool} + %% would be an especially nice realization of `\VerticalCmdBox'. + %% + %% |\InlineCmdBox{<content>}|, according to our idea, should not + %% change baseline skip, even with some `\fboxsep' and `\fboxrule'. + %% (However, it may be a good idea to increase the overall + %% normal baseline skip.) + %% We therefore replace actual height and depth of the content by + %% the height and depth of math parentheses. + \newcommand*{\InlineCmdBox}[1]{% + \bgroup + %% ... needed in math mode with `\begin_min_verb'. + \fboxsep 1pt + \kern\SetOffInlineCmdBoxOuter + \smash{\SetOffInlineCmdBox{\kern\SetOffInlineCmdBoxInner + \InlineCmdBoxArea{#1}% + \kern\SetOffInlineCmdBoxInner}}% + \mathstrut + \kern\SetOffInlineCmdBoxOuter + \egroup + } + %% The default choice for |\SetOffInlineCmdBox| is `\fbox': + \@ifdefinable\SetOffInlineCmdBox{\let\SetOffInlineCmdBox\fbox} + %% You can `\renewcommand' it to change `\fboxsep', `\fboxrule' + %% etc. or to use a `\colorbox' with the 'color' package, e.g., + %% I used the following setting so far: + %% %% 2010/03/10 + %% \begin{verbatim} + %% \RequirePackage{color} + %% \renewcommand*{\SetOffInlineCmdBox} + %% {\colorbox[cmyk]{.1,0,.2,.05}} + %% \end{verbatim} + %% |\SetOffInlineCmdBoxInner| enables controlling the inner + %% horizontal space to the box margin independently of + %% `\fboxsep'. + %% %% We set it to 0\,pt. as default (it is a macro only, + %% %% for a while). + \newcommand*{\SetOffInlineCmdBoxInner}{-\fboxsep\thinspace} + %% This choice is inspired by `\cstok' for ``boxed" things + %% in Knuth's 'manmac.tex' which formats {\it The \TeX book}. + %% %% <- 2010/03/10 + %% + %% |\SetOffInlineCmdBoxOuter| allows that the box hangs out into the + %% margin horizontally. + %% We set it to 0\,pt as default (it is a macro only, for a while). + \newcommand*{\SetOffInlineCmdBoxOuter}{\z@} + %% The height and depth of the frame should be the same for all + %% inline boxes, we think. + %% The present choice |\InnerCmdBoxArea| for the spacing + %% respects code characters rather than the height and depth + %% of the angle brackets that surround meta-variable names. + \newcommand*{\InlineCmdBoxArea}[1]{% + \smash{#1}\vphantom{gjpq\backslash_verb}} + %% \GenCmdBox+\cmdboxitem|<content>|+ is another variant of + %% `\GenCmdBox'. It should replace `\item[<content>]' in the + %% `description' environment. %% 2010/03/15 + \newcommand*{\cmdboxitem}{% + \bgroup + \let\niceverb_egroup\cmd_item_egroup + \global %% TODO!? 2010/03/15 + \setbox\niceverb_savebox \hbox\bgroup + \NVerb} + \newcommand*{\cmd_item_egroup}{% + \egroup \egroup \egroup + \item[\InlineCmdBox{\box\niceverb_savebox}]} + %% + %% === When 'niceverb' Gets Nasty === + %% These things are new with v0.3. + %% ==== Quotes ==== + %% %% WRONG 2010/03/05: + %% % The left quote feature for meta-code requires that the right quote + %% % feature---for replacing `\textsf'---is activated---no, rather: + %% % that the right quote \qtd{&'} is `\active'. + %% % + %% In order to get \emph{real} single quotes, you could use `\lq <text>\rq', + %% maybe appending a `\ ', but the code |\qtd{<text>}| may look better + %% and be easier to type. + \newcommand*{\qtd}[1]{`#1'} + %% However, here we get the problem that the left quote in + %% \NVerb\+\qtd{`<code>'}+ will be unable to switch into + %% verbatim mode entirely---then use `&', + %% e.g., \qtd{&\qtd{&&&&}} typesets \qtd{\qtd{&&}}, i.e., + %% the ampersand in single (non-verbatim) quotes. + % TODO \qtdverb!? alternative meaning for \LQverb!? 2010/03/06 + % rather rare, & takes less space 2010/03/09 + %% |\dqtd{<text>}| can be used for enclosing in \emph{double} quotes + %% with the dangerous `\nvAllRightQuotesSansSerif' (see above). + \newcommand*{\dqtd}[1]{``#1"} + %% + %% ==== 'hyperref' ==== + %% This is for\slash about compatibility with the 'hyperref' package. + %% (One preliminary thing: in doubt, don't load 'niceverb' earlier + %% than 'hyperref'.) %% TODO 2010/03/14 + %% + %% We need some substitutions for PDF bookmarks with + %% 'hyperref'. We issue them at `\begin{document}' when we know + %% if 'hyperref' is at work.\footnote{An alternative approach would be + %% using + %% \ctanpkgref{afterpackage} + %% by Alex Rozhenko.} + \AtBeginDocument{% + \@ifpackageloaded{hyperref}{% + \newcommand*{\PDFcstring}{% %% moved here 2010/03/09 + \134\expandafter\@gobble\string}% %% ASCII octal encoding + \pdfstringdefDisableCommands{% + \let\nvAllowRQSS\empty %% not \relax 2010/03/12 + %% 2010/03/12 + \MakeActiveLetHere\`\lq \MakeActiveLetHere\'\rq + \MakeActiveLetHere\&\PDFcstring + \def\cs{\134}% %% 2010/03/17 + }% + %% Moreover, in order to avoid spurious %% 2010/03/14 + %% \texttt{Label(s) may have changed} with 'hyperref', + %% a single right quote must be \emph{read} as active + %% by a `\newlabel' if and only if it has been active when + %% `\@currentlabelname' was formed.\footnote{This uses + %% \cs{@onelevelsanitize}, therefore &\protect doesn't + %% change the behaviour of ``active" characters.} + %% as `\active'. We use `\protected@write' as this cares for + %% `\nofiles'. `\@auxout' may be `\@partaux' for `\include'. + \newcommand*{\niceverb_aux_cat}[2]{% %% 2010/03/14 + \protected@write\@auxout{}{\string#1\string#2}}% + \renewcommand*{\MakeActive}[1]{% + \MakeActiveHere#1% + \niceverb_aux_cat\MakeActiveHere#1}% + \renewcommand*{\MakeActiveLet}[2]{% + \MakeActiveLetHere#1#2% + \niceverb_aux_cat\MakeActiveHere#1}% + \renewcommand*{\MakeNormal}[1]{% + \MakeNormalHere#1% + \niceverb_aux_cat\MakeNormalHere#1}% + }{}% + } + %% TODO doesn't 'babel' have the same problem? 2010/03/12 + %% ==== 'hyper-xr' ==== %% 2010/03/21 + %% With the 'hyper-xr' package creating links into external documents, + %% preceding `\externaldocument{<file>}' with + %% `\MakeActiveLet\&\CmdSyntaxVerb' may be needed. + %% I do not want to redefine something here right now as I + %% I have too little experience with this situation. + %% + %% ==== Turning off and on altogether ==== + %% These commands are new with v0.3. + %% + %% |\noNiceVerb| \emph{disables} all 'niceverb' features. + \newcommand*{\noNiceVerb} {\MakeNormal\`% + \MakeNormal\&% + \MakeNormal\<% + \MakeNormal\#% + \nvRightQuoteNormal + \MakeNormal\|} + %% |\useNiceVerb| \emph{activates} all the 'niceverb' features + %% (apart from ``auto mode"). + \newcommand*{\useNiceVerb}{\MakeActiveLet\`\LQverb + %% TODO to be changed with 'wiki.sty' v0.2 + \MakeActiveLet\&\CmdSyntaxVerb + \MakeActiveLet\<\MetaVar + \MakeActiveLet\#\HashVerb + \nvRightQuoteSansSerif + \MakeActiveLet\|\nvCmdBox} + %% + %% === Activating the 'niceverb' Syntax === + %% 'niceverb' features are activated at `\begin{document}' + %% so (some) other packages can be loaded \emph{after} 'niceverb'. + %% For v0.3, we do this after possible settings for + %% compatibility with 'hyperref'. + \AtBeginDocument{\useNiceVerb} + %% + %% === Leave Package Mode === + \MakeNormalHere\_ %% 2010/03/12 + \endinput + %% + %% === VERSION HISTORY === + + v0.1 2009/02/21 very first, sent to CTAN + v0.2 2009/04/04 ...NoVerbList: \subsubsection, \AddToMacro, + 2009/04/05 \SimpleVerb makes more other than iii + 2009/04/06 just uses \dospecials + 2009/04/08 debugging code for rq/sf, +\relax + 2009/04/09 +\verb@eol@error, prepared for new doc method, + removed spurious \makeat..., -\relax (ligature), + 2009/04/10 ('-trick + 2009/04/11 \@ after \SimpleVerb + 2009/04/14 noted TODO below + 2009/04/15 change v0.1 to 2009/02/21 + v0.30 2010/02/27 short, more explained, \AssignCatCodeTo, + use \MakeActive for re-activating, \MakeNormal + 2010/02/28 fixed @ and _ with & by moving \begin_min_verb; + replaced \lq by `; Capitals in Titles + 2010/03/05 \SimpleVerb -> \NVerb; + use \MakeActive + \MakeNormal; \rq -> '; + renamed some sections; \lq_verb -> \LQverb, + \niceverb_meta -> \MetaVar, + \param_verb -> \HashVerb + 2010/03/06 removed \MakeAlign; removed @ and _ todo below; + \NVerb makes ` and ' other; + \nvAllowRQSF allows ' in column titles, + 2010/03/08 \LQverb and & work in column titles, + \RQverb works with \noindent; + bookmark substitutions + 2010/03/09 extended notes on 'hyperref' (in)compatibility; + \MakeLetter\@ in \CmdSyntaxVerb only; + |...| implemented as \prepareCmdBox etc.! + 2010/03/10 \colorbox example, \thinspace; ltxguide!; + removed todo; ..._exec -> \DoRQsansserif; + minor doc changes in ``Nasty" + 2010/03/11 doc changes in ``Escape Character ..." and + ``Ampersand" + 2010/03/12 \niceverb_aux_cat, \MakeActiveHere etc., + \IfTypesetting, \noNiceVerb, \useNiceVerb, + corr. bracing mistake in \MakeNormal! + 2010/03/14 0.31 -> 0.3; \HardNVerb, \GenCmdBox, + \prepareCmdBox -> \nvCmdBox + 2010/03/15 \endcell; \cmdboxitem; remark on \sfcode`/ + 2010/03/16 corr. -> \endline; + advice on \cs{par}, \cs{if...}, \cs{fi}; + redefined \ignorespaces for RQ feature + 2010/03/17 corr. `\fututelet', corr. \cs PDF substitution + 2010/03/18 |\niceverbNoVerbList|, |\AddToMacro| etc.; + corr. \AddToMacro; + \lastskip-fix of \niceverb_ignore, + another fix of \niceverb_noindent + 2010/03/19 another fix of \niceverb_ignore: \spacefactor + 2010/03/20 ... again: \niceverb_spacefactor + + NOT DISTRIBUTED, just stored saved as separate version + + v0.31 2010/03/20 right quote feauture: letters get \sfcode=1001 + `column title' -> `page headers', \ctanpkgref + + NOT DISTRIBUTED, just stored as separate version + + v0.32 2010/03/21 taking best things from v0.30 and v0.31 + 2010/03/23 removed \relax from \IfTypesetting +SENT TO CTAN + + + +v0.4 2010/03/27 restoring `_' with "auto mode" safer + + 2010/03/28 \AddToNoVerbList + + 2010/03/29 note above, renamed v0.4 + diff --git a/Master/texmf-dist/tex/latex/nicetext/wiki.sty b/Master/texmf-dist/tex/latex/nicetext/wiki.sty deleted file mode 100644 index 6fe7b4e4b46..00000000000 --- a/Master/texmf-dist/tex/latex/nicetext/wiki.sty +++ /dev/null @@ -1,376 +0,0 @@ -\ProvidesPackage{wiki}[2008/07/02 v0.2 LaTeX through Wiki markup] -%% <- vorige Aenderungen gg. 2008/06/25 verworfen -%% -%% == Legal == -%% (C) 2008 Uwe Lueck http://contact-ednotes.sty.de.vu -%% License: http://www.latex-project.org/lppl/ -%% -- AUTHOR-MAINTAINED, NO WARRANTY! -%% -%% == Features == -%% -%% The `wiki' package enables LaTeX users to use some of the -%% markup used in editing Wikipedia pages, cf. -%% -%% http://en.wikipedia.org/wiki/Wikipedia:Cheatsheet -%% -%% or German: -%% -%% http://de.wikipedia.org/wiki/Hilfe:Bearbeitungshilfe -%% http://de.wikipedia.org/wiki/Hilfe:Textgestaltung -%% -%% Advantages of such a kind of markup are: -%% -%% 1. easier and faster to type than LaTeX code; -%% -%% 2. intuitive, understandable at a glance; -%% -%% 3. in reading the source code of the document, -%% the markup doesn't much distract from the ''text'' -%% to be printed. -%% -%% There is a binary `easylatex' available on CTAN which is more -%% powerful than the `wiki' package; the idea here is that a ''macro -%% package'' doing something similar is easier to use and to customize. -%% -%% -%% === What the Package Supports === -%% -%% 1. ''Italics'' are marked up by surrounding pairs of apostrophes, -%% '''boldface''' needs one apostrophe more on each side. -%% Boldface and italics may be nested or overlap. -%% (This endangers quoting, but I have dealt with it.) -%% -%% 2. Surrounding ``equals'' symbols (`=') mark up section headings -%% etc.: `== Section ==', `=== Subsection ===', down to -%% `===== Subparagraph ====='. -%% -%% 3. If a line starts with `*', it becomes an item in an -%% `itemize' environment. Likewise, `#' creates an `enumerate' -%% environment, and `;' makes an item in a `discription' -%% environment (differs from Wiki! -- since I don't understand -%% what the Wiki version is good for). `:' makes a `quote' -- -%% while on Wikipedia instead is used for comments on talk -%% pages. But it is also used for indented math displays, -%% so it may be combined with $...$ here. -%% An indented line is typeset ''verbatim''. Each of these -%% environments is ended by a code line without leading blank -%% spaces. -%% -%% -%% === Limitations === -%% -%% 1. The markup ``language'' provided here replaces a few most -%% common LaTeX commands only in their most simple versions. -%% (Yet I think that already this makes the code more readable; -%% the more special cases are very rare.) E.g., it's not -%% possible to suppress the italic correction as with -%% `\textit{...\nocorr}'. However, in ``normal'' cases it -%% should be possible to use the more powerful LaTeX markup -%% mixed with ``Wiki'' markup. -%% -%% 2. The parsing algorithms employed here differ in outcome to -%% those of Wikipedia in difficult cases. -%% -%% 3. Tables, nesting lists, links, Wiki templates and tags -%% are not supported -- and I don't expect that I can afford -%% improving this soon! -%% -%% 4. I still have encountered problems that I didn't understand ... -%% -%% == Package Options and User Commands == -%% -%% \usepackage[<options>]{wiki}, of course. There are <options> -%% `noEnvironments', `noFonts', `noHeadings' giving up -%% functionality for lists etc., for italics and boldface, -%% for section headings etc., respectively. -%% -%% There are commands \wikimarkup, \wikiEnvironments, -%% \wikiFonts, \wikiHeadings to turn respective functionality on -%% (unless disabled by package option). \nowikimarkup, -%% \nowikiEnvironments, \nowikiFonts, \nowikiHeadings turn them -%% off. -%% -%% '''Vital:''' The package does ''not'' execute \wikimarkup -%% because this would have strange effects, e.g., packages -%% loaded later may break. The user must put activating -%% commands into the `document' environment, maybe just preceding -%% the first heading. -%% -%% Dangers to be avoided by \nowiki... are: -%% * \wikiHeadings (which also is executed by \wikimarkup) -%% disables TeX assignments using `='. -%% * \wikiEnvironments (executed by \wikimarkup) executes macros -%% at every end of a code line (containing no comment marke), -%% and it tries to typeset a following line verbatim if it is -%% indented. -%% -%% -%% == Implementation and Further Remarks == - -%% === Commands for Category Codes === -% \RequirePackage{fdcodes} - %% <- TODO -- or do away ... -> -\providecommand*\AssignCatCode[2]{\catcode`#1=#2\relax} -\providecommand*\MakeActive[1]{\catcode`#1=\active} -% \providecommand*\MakeLetter[1]{\catcode`#1=11\relax} - %% <- Declaring characters usable in command strings - %% Todo: print arrow indicators like ``->'' as real arrows -\providecommand*\MakeOther [1]{\catcode`#1=12\relax} - -\AssignCatCode{\_}{11} -% \MakeLetter\_ %% own macros somewhat LaTeX3-style -%% Todo \newcommand <-> \def !? - -%% === Package Options === -\DeclareOption{noFonts} {\let\wikiFonts \empty - \let\nowikiFonts \relax} -\DeclareOption{noHeadings} {\let\wikiHeadings \empty - \let\nowikiHeadings \relax} -\DeclareOption{noEnvironments}{\let\wikiEnvironments \empty - \let\nowikiEnvironments\relax} -\DeclareOption{noVerbatim}{% - \def\W_active_return{ \futurelet\@let@token\W_on_firsttoken}} - %% \[no]wikiVerbatim must wait, too complex 2008/07/01 -\ProcessOptions - -%% === Auxiliaries for both Fonts and Headings === - - \@tempswafalse - \ifx\wikiFonts \empty \else \@tempswatrue \fi - \ifx\wikiHeadings\empty \else \@tempswatrue \fi - \if@tempswa -\def\W_start_samecnt{\futurelet\@let@token\W_process_samecnt} -\def\W_init_samecnt#1#2#3{% - \let\W_samesymb =#1%% repeated symbol - \def\W_repllist {#2}% replacing strings - \def\W_incase_all{#3}% final replacement - \def\W_next##1{\W_start_samecnt}} -\def\W_process_samecnt{% - \expandafter \W_splitlist \W_repllist \@nil - \W_next} -\def\W_splitlist#1#2\@nil{% - \def\W_repllist{#2}% - \ifx\@let@token\W_samesymb - \ifx\W_repllist\empty \def\W_next##1{\W_incase_all}\fi - \else - \def\W_next{#1}% - \fi} - \fi - -%% === Italics and Boldface === - -%% ==== Code ==== - \ifx\wikiFonts\empty \else -\def\W_toggle#1#2#3{\def#1{\W_toggle#1{#3}{#2}}#2} -%% Cf. LaTeX's `\DeclareTextFontCommand': -\def\W_bf_toggle{% - \W_toggle\W_bf_toggle{\bfseries\W_maybe@ic}{\mdseries\W_maybe@ic}} -\def\W_maybe@ic{\futurelet\@let@token\W_maybe_maybe@ic} -\def\W_maybe_maybe@ic{% - \ifx\@let@token\W_rq_robust \else \expandafter \maybe@ic \fi} -\def\W_it_toggle{% - \W_toggle\W_it_toggle{\itshape\maybe@ic}{\upshape\maybe@ic}} -%% <- Doesn't support \nocorr. - -\def\W_rq_robust{%% will become meaning of single right quote. - \ifx\protect\@typeset@protect - \ifmmode \rq \else - \W_init_samecnt{\W_rq_robust}% - {\rq\W_it_toggle}% - {\W_bf_toggle}% - \expandafter\expandafter\expandafter \W_start_samecnt - \fi - \else \rq \fi} -%% Remark: -%% LaTeX's \rq expands to ``other'' apostrophe: -\CheckCommand*\rq{'} %% Must be before `\catcode`\' -%% \wikiFonts -- restoring `...' and ``...'' -- + \nowikiFonts: -%% requiring single left quote \active as well: -\CheckCommand*{\lq}{`} -\MakeActive\`\MakeActive\' -\def\wikiFonts{% - \MakeActive\`\MakeActive\'% - \def`##1'{\lq ##1\rq}% - \let'\W_rq_robust} -\def\nowikiFonts{\MakeOther`\MakeOther\'} -\MakeOther\` \MakeOther\' - \fi - -%% ==== Remarks ==== -%% Wiki: a''b'''cd typesets `b' in italic with an apostrophe, -%% a''b'''c'''d typsets all after `a' in italic with bold `b'. -%% One might use make a difference depending on \lastskip. -%% Wikimedia seems to read more ahead, maybe entire paragraphs. -%% %% <- Todo: try here!? (Test!) -%% -%% Todo: Variants using \textit and \textbf (option, switching -%% command) -%% -%% german.sty's "` and "' are not affected. -%% -%% Merit: ``...'' resembles ''...''; indeed Wikipedia Guidelines -%% demand to think which of both is appropriate in a -%% certain situation. - -%% A test about \ifx with active characters: -%\catcode`\`=\active \let`\rq \let'\rq -%\ifx`'\typeout{OHHH}\else \typeout{OCH}\fi %% OHHH -%% <- how typeset code commented out!? (^!? diff. comment char.!?) -%% indent %! TODO or no space after %!! TODO!! -%% xEDIT: dann Alt C/D fuer Kommentar/Dok./auskomm. (!?) !! - -%% === Section Headings === - - \ifx\wikiHeadings\empty \else -\providecommand*{\normalequals}{=} -\MakeActive\= -\def\wikiHeadings{\MakeActive\=\let=\W_eq_robust} -\def\nowikiHeadings{\MakeOther\=} -\def\W_eq_robust{% - \ifx\protect\@typeset@protect - %% in case without math mode in heading - \ifmmode \normalequals \else - \W_init_samecnt{\W_eq_robust}% - {\normalequals\W_sec\W_subsec\W_subsubsec - \W_para\W_subpara}% - {\W_bf_toggle}% - \expandafter\expandafter\expandafter \W_start_samecnt - \fi - \else \normalequals \fi} - -\def\W_sec #1=={\section{#1}} -\def\W_subsec #1==={\subsection{#1}} -\def\W_subsubsec #1===={\subsubsection{#1}} -\def\W_para #1====={\paragraph{#1}} -\def\W_subpara #1======{\subparagraph{#1}} - -\MakeOther\= - \fi - -%% Todo: think of reimplementation by the start-line -%% mechanism which is going to be used for lists. - -%% === Environments === -%% - \ifx\wikiEnvironments\empty \else - -%% ==== Prepare Dealing with Indents ==== - -\MakeActive{\^^M}% -\def\wikiEnvironments{\MakeActive{\^^M}\let^^M\W_active_return}% -\def\nowikiEnvironments{\AssignCatCode{\^^M}{5}}% -\nowikiEnvironments%% TeX <return> restored - -\MakeActive{\ }% -\@ifundefined{W_active_return}{% -\expandafter\def\expandafter\W_active_return\expandafter{% -\space\catcode`\ \active\let \W_indent% -%% <- \W_indent will start verbatim -\futurelet\@let@token\W_on_firsttoken}% -}{}%% end of \@ifundefined which is true without noVerbatim -%% Much doubling for saving time (!??): -\expandafter\def\expandafter\W_list_activereturn\expandafter{% -\space\catcode`\ \active\let \W_restore_space% -%% <- \W_indent will start verbatim -\futurelet\@let@token\W_maybe_newitem}% -% \def\W_restore_space{\catcode`\ 10\relax}% - %% <- was vital for a math display in a list -> -\def\W_restore_space{\catcode`\ 10\ignorespaces}% -\W_restore_space%% TeX blank space restored - -%% ==== Start and End List-Like Environments ==== - -%% \W_on_firsttoken may be edited (preamble or .cfg): -\def\W_on_firsttoken{% - % \show\@let@token - \W_restore_space - \let\W_next\relax %% must be before \W_skip... works - \ifx\@let@token\W_active_return \expandafter \W_par \fi - %% <- found by guessing/with \show\@let@token - \let\W_item\item - \W_on_startenv{*}{itemize}% - \W_on_startenv{\W_hash}{enumerate}% - \W_on_startenv{;}{description}% - \let\W_item\relax %% must precede `quote' - \W_on_startenv{:}{quote}%% instead of quotation 2008/07/01 - \W_next} -\let\W_hash=# -\def\W_par#1\W_next{\par} -\def\W_skiprest_item#1\W_next#2{\W_item} - -\MakeActive{\^^M}% -\def\W_on_startenv#1#2{% - \ifx#1\@let@token% - \begin{#2}% - \let\W_itemsymbol#1% - \let^^M\W_list_activereturn% - \expandafter \W_skiprest_item% - \fi}% -\nowikiEnvironments% - -\def\W_maybe_newitem{% - \W_restore_space - \ifx\@let@token\W_itemsymbol - \expandafter \W_gobbling_item - \else - \ifx\@let@token\W_restore_space - \else - \ifx\@let@token\W_list_activereturn - \par - \else - \edef\W_next{\noexpand\end{\@currenvir}}% - \W_next - \fi - \fi - \fi} -\def\W_gobbling_item#1{\item} - -%% ==== Verbatim Environment ==== - -\def\W_indent{\begin{W_verbatim}} -\def\W_verbatim{% - \let\obeylines\W_obeylines - \@verbatim \frenchspacing\@vobeyspaces} -\let\endW_verbatim\endverbatim - -\MakeActive{\^^M} -\def\W_obeylines{% - \catcode`\^^M\active% - \def^^M{\par\futurelet\@let@token\W_check_verbcont}}% -\nowikiEnvironments% - -\def\W_check_verbcont{% - \ifx\@let@token\@xobeysp - \expandafter \@gobble %% gobble one space - \else - \def\W_next{\end{W_verbatim}}% - \expandafter \W_next - \fi} - -%% TODO: enable user to switch between environment ``encodings'' -%% or to disable some of them (edit \W_on_firsttoken) - - \fi %% from \ifx\wikiEnvironments \else - - -%% === Turning Wiki Markup On and Off === - -\def\wikimarkup{\wikiFonts\wikiHeadings\wikiEnvironments} -\def\nowikimarkup{% - \MakeOther\`\MakeOther\'\MakeOther\=\AssignCatCode{\^^M}{5}} - -% \wikimarkup %% strange effects here, to be put into document - -\AssignCatCode\_{8} -\endinput - -%% todo: tables, links, templates, (pseudo-)html-tags ... -%% TODO: credits: easylatex etc. -%% TODO: useful for: ... intuitive markup, ``poor man's WYSIWYG'', -%% ASCII-WYSIWYG. -%% Todo: improve Wiki markup: ``tab'' indents instead of `:' -%% as in testing for end of list: after finding one -%% leading space, test for another. - - - |