diff options
author | Karl Berry <karl@freefriends.org> | 2021-12-23 21:33:04 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2021-12-23 21:33:04 +0000 |
commit | 6887d69680260a38243b2a13759a1c8b9efa884b (patch) | |
tree | fee1b5ea2649adeeb05ed8848613d2cdd93aba73 /Master/texmf-dist/tex/latex/censor/censor.sty | |
parent | 2805a50c9f05126b7b1fafdd8e0e27b7a1d86112 (diff) |
censor (23dec21)
git-svn-id: svn://tug.org/texlive/trunk@61389 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/censor/censor.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/censor/censor.sty | 135 |
1 files changed, 53 insertions, 82 deletions
diff --git a/Master/texmf-dist/tex/latex/censor/censor.sty b/Master/texmf-dist/tex/latex/censor/censor.sty index 49e11906198..6335b16ae36 100644 --- a/Master/texmf-dist/tex/latex/censor/censor.sty +++ b/Master/texmf-dist/tex/latex/censor/censor.sty @@ -1,7 +1,7 @@ % censor.sty -\def\censorversionnumber{3.22} +\def\censorversionnumber{4.0} \ProvidesPackage{censor} -[2018/11/15 \censorversionnumber +[2021/12/23 \censorversionnumber Provides capability for redaction of sensitive information] % @@ -30,15 +30,17 @@ % 3.21 - Fixed bug regarding \xblackout rules remaining after a % \StopCensoring % 3.22 - changed `\if to \ifx in definition of \bl@t, to handle macros like \% +% 4.0 - Recast \blackout and \xblackout in terms of tokcycle environments +% - Introduced \blackoutenv...\endblackoutenv and +% \xblackoutenv...\endxblackoutenv \usepackage{pbox} -\usepackage{ifnextok} \newlength\censorruledepth \newlength\censorruleheight \censorruledepth=-0.3ex% -0.3ex DEFAULT \censorruleheight=2.1ex% 2.1ex DEFAULT -\def\censordot{.}% versus \def\censordot{ }% +\def\censordot{\censor{.}}% versus \def\censordot{ }% \newcommand\censorrule[1]{\protect\rule[\censorruledepth]{#1}{\censorruleheight}} @@ -53,90 +55,57 @@ \newcommand\StopCensoring{% \let\censor\un@censor% \let\censorbox\un@censorbox% - \let\xblackout\blackout% + \renewcommand\censpace{ }% } \newcommand\RestartCensoring{% \renewcommand\censor{\@ifstar{\@cenlen}{\@cenword}}% \renewcommand\censorbox{\@ifstar{\censor@dim}{\censor@box}}% - \let\xblackout\sv@xblackout% + \let\censpace\sv@censpace% } -\let\sv@tilde~ - -\def\stringend{$} - -\long\def\blackout#1{\def~{-}\censor@Block#1\stringend\let~\sv@tilde} -\long\def\censor@Block{\IfNextToken\stringend{\@gobble}% - {\IfNextToken\@sptoken{ \bl@t{\censor@Block}}% - {\bl@t{\censor@Block}}}} - -% V2.00 DEFINITION: -% \def\bl@t#1#2{\censor{#2}#1} - -% V2.10 DEFINITION (MADE \long IN V3.1): -%\long\def\bl@t#1#2{\if\bpar#2\par\else\if.#2\censordot\else\censor{#2}\fi\fi#1} - -% V3.22 DEFINITION -\long\def\bl@t#1#2{\ifx\bpar#2\par\else\if.#2\censordot\else\censor{#2}\fi\fi#1} - -%\def\bpar{_} %V3.00 DEFINITION -\let\bpar\par %AS OF V3.1, CAN HANDLE \par - -\long\def\xblackout#1{\rule{0ex}{0ex}% - \def~{-}% - \def\@justpar{F}% - \def\@justperiod{F}% - \def\@justspace{F}% - \xcensor@Block#1\stringend% - \let~\sv@tilde% - } - -\let\sv@xblackout\xblackout - -\long\def\xcensor@Block{\IfNextToken\stringend{\@gobble}% - {\IfNextToken\@sptoken{ \def\@justspace{T}\xbl@t{\xcensor@Block}}% - {\xbl@t{\xcensor@Block}}}} - -\newlength\periodrlap\setlength\periodrlap{1.6ex} -\newlength\afterperiodlap\setlength\afterperiodlap{1.2ex} -\newlength\lletterlap\setlength\lletterlap{0.55ex} -\newlength\rletterlap\setlength\rletterlap{0.55ex} -\newlength\afterspacelap\setlength\afterspacelap{0.0ex} - -\def\@periodrlap{\rlap{\censorrule{\periodrlap}}} -\def\@afterperiodlap{\llap{\censorrule{\afterperiodlap}}} -\def\@lletterlap{\llap{\censorrule{\lletterlap}}} -\def\@rletterlap{\rlap{\censorrule{\rletterlap}}} -\def\@afterspacelap{\llap{\censorrule{\afterspacelap}}} - -\long\def\xbl@t#1#2{% - \ifx\par#2% - \par\def\@justpar{T}% - \else% - \if T\@justspace% - \rule{0ex}{1ex}\@afterspacelap% - \fi% - \if.#2% - \def\@justperiod{T}% - \@periodrlap% - \censordot% - \else% - \if F\@justpar% - \if T\@justperiod% - \@afterperiodlap% - \else% - \@lletterlap% - \fi% - \fi% - \censor{#2}% - \@rletterlap% - \def\@justpar{F}% - \def\@justperiod{F}% - \def\@justspace{F}% - \fi% - \fi% - #1% -} +%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\usepackage{tokcycle}[2021/03/10] + + +\def\@dump#1{\addcytoks[1]{\expandafter\censor\expandafter{#1}}\def#1{}} +\def\@append#1#2{\tc@defx#1{#1#2}} + +\def\spacelap{0.6ex} +\def\censpace{\rlap{\censorrule{\spacelap}} \llap{\censorrule{\spacelap}}} +\let\sv@censpace\censpace + +\long\def\blackout#1{\blackoutenv#1\endblackoutenv} +\long\def\xblackout#1{\xblackoutenv#1\endxblackoutenv} + +\newif\ifexpandarg + +\xtokcycleenvironment\xblackoutenv + {\ifx.##1\@dump\censored@word\addcytoks[1]{\censordot}\else + \@append\censored@word{##1}% + \tcpeek\@next\ifx\@next\@tcEscapeptr\@dump\censored@word\fi\fi} + {\tctestifcon\ifexpandarg{\expandafter\processtoks\expandafter{\expanded{##1}}}% + {\processtoks{##1}}\@dump\censored@word\expandargfalse} + {\@dump\censored@word\tctestifx{~##1}{\@append\censored@word{##1}}% + {\tctestifx{\expanded##1}{\expandargtrue}{\addcytoks{##1}}}} + {\@dump\censored@word\addcytoks{\censpace}} + {\def\censored@word{}} + {\@dump\censored@word} +\xtokcycleenvironment\blackoutenv + {\ifx.##1\@dump\censored@word\addcytoks[1]{\censordot}\else + \@append\censored@word{##1}% + \tcpeek\@next\ifx\@next\@tcEscapeptr\@dump\censored@word\fi\fi} + {\tctestifcon\ifexpandarg{\expandafter\processtoks\expandafter{\expanded{##1}}}% + {\processtoks{##1}}\@dump\censored@word\expandargfalse} + {\@dump\censored@word\tctestifx{~##1}{\@append\censored@word{##1}}% + {\tctestifx{\expanded##1}{\expandargtrue}{\addcytoks{##1}}}} + {\@dump\censored@word\addcytoks{##1}} + {\def\censored@word{}} + {\@dump\censored@word} + + + +%%%%%%%%%%%%%%%%%%%%%%%%%% \newcommand\censorbox{\@ifstar{\censor@dim}{\censor@box}} \newcommand\censor@dim[4][]{{#1% @@ -152,3 +121,5 @@ % NOTE: A \protect\censorbox{} MAY BE REQUIRED INSIDE SOME ENVIRONMENTS \endinput + + |