diff options
author | Karl Berry <karl@freefriends.org> | 2016-06-09 22:52:48 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2016-06-09 22:52:48 +0000 |
commit | 630a0032b5287429446b8ed9f02af719e9aa563e (patch) | |
tree | 94f3804bded9ec345c473a6fc00d17bd8f317eb2 /Master/texmf-dist/tex | |
parent | 0da7899076450108cd78b6c32594806ad926873a (diff) |
minted (8jun16)
git-svn-id: svn://tug.org/texlive/trunk@41329 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r-- | Master/texmf-dist/tex/latex/minted/minted.sty | 584 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/minted/minted1.sty | 2 |
2 files changed, 431 insertions, 155 deletions
diff --git a/Master/texmf-dist/tex/latex/minted/minted.sty b/Master/texmf-dist/tex/latex/minted/minted.sty index 197df6a01db..a9928e477a8 100644 --- a/Master/texmf-dist/tex/latex/minted/minted.sty +++ b/Master/texmf-dist/tex/latex/minted/minted.sty @@ -5,7 +5,7 @@ %% The original source files were: %% %% minted.dtx (with options: `package') -%% Copyright 2013--2015 Geoffrey M. Poore +%% Copyright 2013--2016 Geoffrey M. Poore %% Copyright 2010--2011 Konrad Rudolph %% %% This work may be distributed and/or modified under the @@ -27,7 +27,7 @@ %% and the derived file minted.sty. \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{minted} - [2015/09/09 v2.1 Yet another Pygments shim for LaTeX] + [2016/06/08 v2.2 Yet another Pygments shim for LaTeX] \RequirePackage{keyval} \RequirePackage{kvoptions} \RequirePackage{fancyvrb} @@ -39,6 +39,13 @@ \RequirePackage{etoolbox} \RequirePackage{xstring} \RequirePackage{lineno} +\RequirePackage{framed} +\IfFileExists{shellesc.sty} + {\RequirePackage{shellesc} + \@ifpackagelater{shellesc}{2016/04/29} + {} + {\protected\def\ShellEscape{\immediate\write18 }}} + {\protected\def\ShellEscape{\immediate\write18 }} \AtBeginDocument{% \@ifpackageloaded{color}{}{% \@ifpackageloaded{xcolor}{}{\RequirePackage{xcolor}}}% @@ -55,6 +62,8 @@ \define@key{minted}{cachedir}{% \@namedef{minted@cachedir}{#1}% \StrSubstitute{\minted@cachedir}{/}{\@backslashchar}[\minted@cachedir@windows]} +\DeclareBoolOption{finalizecache} +\DeclareBoolOption{frozencache} \let\minted@outputdir\@empty \let\minted@outputdir@windows\@empty \define@key{minted}{outputdir}{% @@ -67,13 +76,27 @@ \DeclareComplementaryOption{final}{draft} \ProcessKeyvalOptions* \ifthenelse{\boolean{minted@newfloat}}{\RequirePackage{newfloat}}{} -\ifcsname tikzexternalrealjob\endcsname - \minted@drafttrue - \minted@cachefalse +\ifcsname tikzifexternalizing\endcsname + \tikzifexternalizing{\minted@drafttrue\minted@cachefalse}{} \else + \ifcsname tikzexternalrealjob\endcsname + \minted@drafttrue + \minted@cachefalse + \else + \fi \fi -\ifthenelse{\boolean{minted@cache}}{% - \AtEndOfPackage{\ProvideDirectory{\minted@outputdir\minted@cachedir}}}{} +\ifthenelse{\boolean{minted@finalizecache}}% + {\ifthenelse{\boolean{minted@frozencache}}% + {\PackageError{minted}% + {Options "finalizecache" and "frozencache" are not compatible}% + {Options "finalizecache" and "frozencache" are not compatible}}% + {}}% + {} +\ifthenelse{\boolean{minted@cache}}% + {\ifthenelse{\boolean{minted@frozencache}}% + {}% + {\AtEndOfPackage{\ProvideDirectory{\minted@outputdir\minted@cachedir}}}}% + {} \newcommand{\minted@input}[1]{% \IfFileExists{#1}% {\input{#1}}% @@ -81,11 +104,12 @@ was^^Jprobably given a file that does not exist--otherwise, you may need ^^Jthe outputdir package option, or may be using an incompatible build tool\ifwindows,^^Jor may be using the kpsewhich option without having - PowerShell installed\fi}% + PowerShell installed\fi,^^Jor may be using frozencache with a missing file}% {This could be caused by using -output-directory or -aux-directory ^^Jwithout setting minted's outputdir, or by using a build tool that ^^Jchanges paths in ways minted cannot detect\ifwindows, or by using the - ^^Jkpsewhich option without PowerShell\fi.}}% + ^^Jkpsewhich option without PowerShell\fi, + ^^Jor using frozencache with a missing file.}}% } \newcommand{\minted@infile}{\minted@jobname.out.pyg} \newcommand{\minted@cachelist}{} @@ -116,43 +140,49 @@ \fi } \ifthenelse{\boolean{minted@draft}}% - {\AtEndDocument{% + {\AtEndDocument{% + \ifcsname minted@oldcachelist\endcsname + \StrSubstitute{\minted@oldcachelist}{,}{,^^J }[\minted@cachelist] + \minted@savecachelist + \fi}}% + {\ifthenelse{\boolean{minted@frozencache}}% + {\AtEndDocument{% \ifcsname minted@oldcachelist\endcsname - \let\minted@cachelist\minted@oldcachelist + \StrSubstitute{\minted@oldcachelist}{,}{,^^J }[\minted@cachelist] \minted@savecachelist \fi}}% - {\AtEndDocument{% - \minted@savecachelist - \minted@cleancache}}% + {\AtEndDocument{% + \minted@savecachelist + \minted@cleancache}}}% \ifwindows \providecommand{\DeleteFile}[2][]{% \ifthenelse{\equal{#1}{}}% - {\IfFileExists{#2}{\immediate\write18{del "#2"}}{}}% + {\IfFileExists{#2}{\ShellEscape{del #2}}{}}% {\IfFileExists{#1/#2}{% \StrSubstitute{#1}{/}{\@backslashchar}[\minted@windir] - \immediate\write18{del "\minted@windir\@backslashchar #2"}}{}}} + \ShellEscape{del \minted@windir\@backslashchar #2}}{}}} \else \providecommand{\DeleteFile}[2][]{% \ifthenelse{\equal{#1}{}}% - {\IfFileExists{#2}{\immediate\write18{rm "#2"}}{}}% - {\IfFileExists{#1/#2}{\immediate\write18{rm "#1/#2"}}{}}} + {\IfFileExists{#2}{\ShellEscape{rm #2}}{}}% + {\IfFileExists{#1/#2}{\ShellEscape{rm #1/#2}}{}}} \fi \ifwindows \newcommand{\ProvideDirectory}[1]{% \StrSubstitute{#1}{/}{\@backslashchar}[\minted@windir] - \immediate\write18{if not exist "\minted@windir" mkdir "\minted@windir"}} + \ShellEscape{if not exist \minted@windir\space mkdir \minted@windir}} \else \newcommand{\ProvideDirectory}[1]{% - \immediate\write18{mkdir -p "#1"}} + \ShellEscape{mkdir -p #1}} \fi \newboolean{AppExists} \newread\minted@appexistsfile \newcommand{\TestAppExists}[1]{ \ifwindows \DeleteFile{\minted@jobname.aex} - \immediate\write18{for \string^\@percentchar i in (#1.exe #1.bat #1.cmd) - do set >"\minted@jobname.aex" <nul: /p - x=\string^\@percentchar \string~$PATH:i>>"\minted@jobname.aex"} + \ShellEscape{for \string^\@percentchar i in (#1.exe #1.bat #1.cmd) + do set > \minted@jobname.aex <nul: /p + x=\string^\@percentchar \string~$PATH:i>> \minted@jobname.aex} %$ <- balance syntax highlighting \immediate\openin\minted@appexistsfile\minted@jobname.aex \expandafter\def\expandafter\@tmp@cr\expandafter{\the\endlinechar} @@ -165,7 +195,7 @@ \immediate\closein\minted@appexistsfile \DeleteFile{\minted@jobname.aex} \else - \immediate\write18{which "#1" && touch "\minted@jobname.aex"} + \ShellEscape{which #1 && touch \minted@jobname.aex} \IfFileExists{\minted@jobname.aex} {\AppExiststrue \DeleteFile{\minted@jobname.aex}} @@ -473,49 +503,58 @@ \expandafter\gdef% \csname minted@styleloaded@\ifstrempty{#1}{default-pyg-prefix}{#1}\endcsname{}% \ifthenelse{\boolean{minted@cache}}% - {\IfFileExists + {\IfFileExists {\minted@outputdir\minted@cachedir/\ifstrempty{#1}{default-pyg-prefix}{#1}.pygstyle}% {}% {% - \ifwindows - \immediate\write18{% - \MintedPygmentize\space -S \ifstrempty{#1}{default}{#1} -f latex - -P commandprefix=PYG#1 - > "\minted@outputdir@windows\minted@cachedir@windows\@backslashchar% - \ifstrempty{#1}{default-pyg-prefix}{#1}.pygstyle"}% - \else - \immediate\write18{% - \MintedPygmentize\space -S \ifstrempty{#1}{default}{#1} -f latex - -P commandprefix=PYG#1 - > "\minted@outputdir\minted@cachedir/% - \ifstrempty{#1}{default-pyg-prefix}{#1}.pygstyle"}% - \fi + \ifthenelse{\boolean{minted@frozencache}}% + {\PackageError{minted}% + {Missing style definition for #1 with frozencache}% + {Missing style definition for #1 with frozencache}}% + {\ifwindows + \ShellEscape{% + \MintedPygmentize\space -S \ifstrempty{#1}{default}{#1} -f latex + -P commandprefix=PYG#1 + > \minted@outputdir@windows\minted@cachedir@windows\@backslashchar% + \ifstrempty{#1}{default-pyg-prefix}{#1}.pygstyle}% + \else + \ShellEscape{% + \MintedPygmentize\space -S \ifstrempty{#1}{default}{#1} -f latex + -P commandprefix=PYG#1 + > \minted@outputdir\minted@cachedir/% + \ifstrempty{#1}{default-pyg-prefix}{#1}.pygstyle}% + \fi}% }% \begingroup \let\def\gdef + \catcode`\_=11 + \catcode`\-=11 \endlinechar=-1\relax \minted@input{% \minted@outputdir\minted@cachedir/\ifstrempty{#1}{default-pyg-prefix}{#1}.pygstyle}% \endgroup \minted@addcachefile{\ifstrempty{#1}{default-pyg-prefix}{#1}.pygstyle}}% - {\ifwindows - \immediate\write18{% + {% + \ifwindows + \ShellEscape{% \MintedPygmentize\space -S \ifstrempty{#1}{default}{#1} -f latex - -P commandprefix=PYG#1 > "\minted@outputdir@windows\minted@jobname.out.pyg"}% + -P commandprefix=PYG#1 > \minted@outputdir@windows\minted@jobname.out.pyg}% \else - \immediate\write18{% + \ShellEscape{% \MintedPygmentize\space -S \ifstrempty{#1}{default}{#1} -f latex - -P commandprefix=PYG#1 > "\minted@outputdir\minted@jobname.out.pyg"}% + -P commandprefix=PYG#1 > \minted@outputdir\minted@jobname.out.pyg}% \fi \begingroup \let\def\gdef + \catcode`\_=11 + \catcode`\-=11 \endlinechar=-1\relax \minted@input{\minted@outputdir\minted@jobname.out.pyg}% \endgroup}% \fi } \ifthenelse{\boolean{minted@draft}}{\renewcommand{\minted@checkstyle}[1]{}}{} -\AtBeginDocument{\minted@checkstyle{}} +\AtBeginDocument{\minted@checkstyle{}\setminted{style=default}} \newcommand{\minted@patch@PYGZsq}{% \ifcsname PYGZsq\endcsname \ifx\upquote@cmtt\minted@undefined\else @@ -627,6 +666,7 @@ \minted@def@optfv{fontseries} \minted@def@optfv{formatcom} \minted@def@optfv{label} +\minted@def@optfv{labelposition} \minted@def@optfv@switch{numberblanklines} \minted@def@optfv@switch{showspaces} \minted@def@optfv@switch{resetmargins} @@ -645,6 +685,10 @@ \minted@def@optfv{breaksymbolright} \minted@def@optfv{breaksymbolsepright} \minted@def@optfv{breaksymbolindentright} +\minted@def@optfv{breakbefore} +\minted@def@optfv{breakbeforesymbolpre} +\minted@def@optfv{breakbeforesymbolpost} +\minted@def@optfv@switch{breakbeforegroup} \minted@def@optfv{breakafter} \minted@def@optfv@switch{breakaftergroup} \minted@def@optfv{breakaftersymbolpre} @@ -731,6 +775,44 @@ \let\[\FV@leftsquarebracket \let\]\FV@rightsquarebracket } %$ <- highlighting +\define@key{FV}{breakbefore}{% + \ifstrempty{#1}% + {\let\FV@BreakBefore\@empty + \let\FancyVerbBreakStart\relax + \let\FancyVerbBreakStop\relax}% + {\def\FV@BreakBefore{#1}% + \let\FancyVerbBreakStart\FV@Break + \let\FancyVerbBreakStop\FV@EndBreak + \let\FV@Break@Token\FV@Break@BeforeAfterToken}% +} +\fvset{breakbefore={}} +\newboolean{FV@BreakBeforeGroup} +\define@booleankey{FV}{breakbeforegroup}% + {\FV@BreakBeforeGrouptrue}% + {\FV@BreakBeforeGroupfalse}% +\fvset{breakbeforegroup=true} +\def\FV@BreakBeforePrep{% + \ifx\FV@BreakBefore\@empty\relax + \else + \gdef\FV@BreakBefore@Def{}% + \begingroup + \def\FV@BreakBefore@Process##1##2\FV@Undefined{% + \expandafter\FV@BreakBefore@Process@i\expandafter{##1}% + \expandafter\ifx\expandafter\relax\detokenize{##2}\relax + \else + \FV@BreakBefore@Process##2\FV@Undefined + \fi + }% + \def\FV@BreakBefore@Process@i##1{% + \g@addto@macro\FV@BreakBefore@Def{% + \@namedef{FV@BreakBefore@Token\detokenize{##1}}{}}% + }% + \FV@EscChars + \expandafter\FV@BreakBefore@Process\FV@BreakBefore\FV@Undefined + \endgroup + \FV@BreakBefore@Def + \fi +} \define@key{FV}{breakafter}{% \ifstrempty{#1}% {\let\FV@BreakAfter\@empty @@ -739,7 +821,7 @@ {\def\FV@BreakAfter{#1}% \let\FancyVerbBreakStart\FV@Break \let\FancyVerbBreakStop\FV@EndBreak - \let\FV@Break@Token\FV@Break@AfterToken}% + \let\FV@Break@Token\FV@Break@BeforeAfterToken}% } \fvset{breakafter={}} \newboolean{FV@BreakAfterGroup} @@ -760,6 +842,20 @@ \fi }% \def\FV@BreakAfter@Process@i##1{% + \ifcsname FV@BreakBefore@Token\detokenize{##1}\endcsname + \ifthenelse{\boolean{FV@BreakBeforeGroup}}% + {\ifthenelse{\boolean{FV@BreakAfterGroup}}% + {}% + {\PackageError{minted}% + {Conflicting breakbeforegroup and breakaftergroup for "\detokenize{##1}"}% + {Conflicting breakbeforegroup and breakaftergroup for "\detokenize{##1}"}}}% + {\ifthenelse{\boolean{FV@BreakAfterGroup}}% + {\PackageError{minted}% + {Conflicting breakbeforegroup and breakaftergroup for "\detokenize{##1}"}% + {Conflicting breakbeforegroup and breakaftergroup for "\detokenize{##1}"}}% + {}}% + \else + \fi \g@addto@macro\FV@BreakAfter@Def{% \@namedef{FV@BreakAfter@Token\detokenize{##1}}{}}% }% @@ -770,7 +866,7 @@ \fi } \expandafter\def\expandafter\FV@FormattingPrep\expandafter{% - \expandafter\FV@BreakAfterPrep\FV@FormattingPrep} + \expandafter\FV@BreakBeforePrep\expandafter\FV@BreakAfterPrep\FV@FormattingPrep} \define@key{FV}{breakanywheresymbolpre}{% \ifstrempty{#1}% {\def\FancyVerbBreakAnywhereSymbolPre{}}% @@ -781,6 +877,16 @@ {\def\FancyVerbBreakAnywhereSymbolPost{}}% {\def\FancyVerbBreakAnywhereSymbolPost{\hbox{#1}}}} \fvset{breakanywheresymbolpost={}} +\define@key{FV}{breakbeforesymbolpre}{% + \ifstrempty{#1}% + {\def\FancyVerbBreakBeforeSymbolPre{}}% + {\def\FancyVerbBreakBeforeSymbolPre{\hbox{#1}}}} +\fvset{breakbeforesymbolpre={\,\footnotesize\ensuremath{_\rfloor}}} +\define@key{FV}{breakbeforesymbolpost}{% + \ifstrempty{#1}% + {\def\FancyVerbBreakBeforeSymbolPost{}}% + {\def\FancyVerbBreakBeforeSymbolPost{\hbox{#1}}}} +\fvset{breakbeforesymbolpost={}} \define@key{FV}{breakaftersymbolpre}{% \ifstrempty{#1}% {\def\FancyVerbBreakAfterSymbolPre{}}% @@ -794,6 +900,9 @@ \newcommand{\FancyVerbBreakAnywhereBreak}{% \discretionary{\FancyVerbBreakAnywhereSymbolPre}% {\FancyVerbBreakAnywhereSymbolPost}{}} +\newcommand{\FancyVerbBreakBeforeBreak}{% + \discretionary{\FancyVerbBreakBeforeSymbolPre}% + {\FancyVerbBreakBeforeSymbolPost}{}} \newcommand{\FancyVerbBreakAfterBreak}{% \discretionary{\FancyVerbBreakAfterSymbolPre}% {\FancyVerbBreakAfterSymbolPost}{}} @@ -823,6 +932,7 @@ } \def\FV@Break{% \def\FV@Tmp{}% + \let\FV@LastToken\minted@undefined \FV@Break@Scan } \def\FV@EndBreak{\FV@Tmp} @@ -847,26 +957,68 @@ \catcode`\$=3% \gdef\FV@Break@Math$#1${% \g@addto@macro{\FV@Tmp}{$#1$}% + \let\FV@LastToken\minted@undefined \FV@Break@Scan} \endgroup \def\FV@Break@Group#1{% \g@addto@macro{\FV@Tmp}{{#1}}% + \ifstrempty{#1}{}{\let\FV@LastToken\minted@undefined}% \FV@Break@Scan} \def\FV@Break@AnyToken#1{% \g@addto@macro{\FV@Tmp}{\FancyVerbBreakAnywhereBreak#1}% \FV@Break@Scan} -\def\FV@Break@AfterToken#1{% - \ifcsname FV@BreakAfter@Token\detokenize{#1}\endcsname - \let\FV@Break@Next\FV@Break@AfterTokenBreak +\def\FV@Break@BeforeAfterToken#1{% + \ifcsname FV@BreakBefore@Token\detokenize{#1}\endcsname + \let\FV@Break@Next\FV@Break@BeforeTokenBreak \else - \let\FV@Break@Next\FV@Break@AfterTokenNoBreak + \ifcsname FV@BreakAfter@Token\detokenize{#1}\endcsname + \let\FV@Break@Next\FV@Break@AfterTokenBreak + \else + \let\FV@Break@Next\FV@Break@BeforeAfterTokenNoBreak + \fi \fi \FV@Break@Next{#1}% } -\def\FV@Break@AfterTokenNoBreak#1{% +\def\FV@Break@BeforeAfterTokenNoBreak#1{% \g@addto@macro{\FV@Tmp}{#1}% + \let\FV@LastToken#1% \FV@Break@Scan} +\def\FV@Break@BeforeTokenBreak#1{% + \ifthenelse{\boolean{FV@BreakBeforeGroup}}% + {\ifx#1\FV@LastToken\relax + \ifcsname FV@BreakAfter@Token\detokenize{#1}\endcsname + \let\FV@Break@Next\FV@Break@BeforeTokenBreak@AfterRescan + \def\FV@RescanToken{#1}% + \else + \g@addto@macro{\FV@Tmp}{#1}% + \let\FV@Break@Next\FV@Break@Scan + \let\FV@LastToken#1% + \fi + \else + \ifcsname FV@BreakAfter@Token\detokenize{#1}\endcsname + \g@addto@macro{\FV@Tmp}{\FancyVerbBreakBeforeBreak}% + \let\FV@Break@Next\FV@Break@BeforeTokenBreak@AfterRescan + \def\FV@RescanToken{#1}% + \else + \g@addto@macro{\FV@Tmp}{\FancyVerbBreakBeforeBreak#1}% + \let\FV@Break@Next\FV@Break@Scan + \let\FV@LastToken#1% + \fi + \fi}% + {\ifcsname FV@BreakAfter@Token\detokenize{#1}\endcsname + \g@addto@macro{\FV@Tmp}{\FancyVerbBreakBeforeBreak}% + \let\FV@Break@Next\FV@Break@BeforeTokenBreak@AfterRescan + \def\FV@RescanToken{#1}% + \else + \g@addto@macro{\FV@Tmp}{\FancyVerbBreakBeforeBreak#1}% + \let\FV@Break@Next\FV@Break@Scan + \let\FV@LastToken#1% + \fi}% + \FV@Break@Next} +\def\FV@Break@BeforeTokenBreak@AfterRescan{% + \expandafter\FV@Break@AfterTokenBreak\FV@RescanToken} \def\FV@Break@AfterTokenBreak#1{% + \let\FV@LastToken#1% \@ifnextchar\FV@Space% {\g@addto@macro{\FV@Tmp}{#1}\FV@Break@Scan}% {\ifthenelse{\boolean{FV@BreakAfterGroup}}% @@ -876,7 +1028,6 @@ \else \ifx\@let@token\bgroup\relax \g@addto@macro{\FV@Tmp}{#1}% - \let\FV@TmpToken#1% \let\FV@Break@Next\FV@Break@AfterTokenBreak@Group \else \g@addto@macro{\FV@Tmp}{#1\FancyVerbBreakAfterBreak}% @@ -891,10 +1042,10 @@ \g@addto@macro{\FV@Tmp}{{#1}}% \ifstrempty{#1}% {\let\FV@Break@Next\FV@Break@AfterTokenBreak@Group@i}% - {\let\FV@Break@Next\FV@Break@Scan}% + {\let\FV@Break@Next\FV@Break@Scan\let\FV@LastToken\minted@undefined}% \FV@Break@Next} \def\FV@Break@AfterTokenBreak@Group@i{% - \@ifnextchar\FV@TmpToken% + \@ifnextchar\FV@LastToken% {\FV@Break@Scan}% {\g@addto@macro{\FV@Tmp}{\FancyVerbBreakAfterBreak}% \FV@Break@Scan}} @@ -935,7 +1086,8 @@ \ifthenelse{\boolean{FV@BreakAutoIndent}}% {\hspace*{-\wd\FV@LineIndentBox}}% {}% - \strut#1\nobreak\strut + \strut\FancyVerbFormatText{% + \FancyVerbBreakStart#1\FancyVerbBreakStop}\nobreak\strut \end{internallinenumbers*} }% \ifdefempty{\FancyVerbBreakSymbolRight}{}% @@ -944,6 +1096,10 @@ } \def\FancyVerbFormatText#1{#1} \def\FV@ListProcessLine@Break#1{% + \ifx\FV@ObeyTabsInit\relax\else + \PackageError{minted}% + {the options obeytabs and breaklines are not compatible}{}% + \fi \hbox to \hsize{% \kern\leftmargin \hbox to \linewidth{% @@ -958,12 +1114,10 @@ \sbox{\FV@LineBox}{\FancyVerbFormatLine{\FancyVerbFormatText{#1}}}% \ifdim\wd\FV@LineBox>\linewidth \setcounter{FancyVerbLineBreakLast}{0}% - \FV@SaveLineBox{\FancyVerbFormatText{% - \FancyVerbBreakStart#1\FancyVerbBreakStop}}% + \FV@SaveLineBox{#1}% \ifdefempty{\FancyVerbBreakSymbolRight}{}{% \let\FV@SetLineBreakLast\relax - \FV@SaveLineBox{\FancyVerbFormatText{% - \FancyVerbBreakStart#1\FancyVerbBreakStop}}}% + \FV@SaveLineBox{#1}}% \FV@LeftListNumber \FV@LeftListFrame \FancyVerbFormatLine{\usebox{\FV@LineBox}}% @@ -984,15 +1138,16 @@ \fi \fi \newsavebox{\minted@bgbox} -\newenvironment{minted@colorbg}[1]{ - %\setlength{\fboxsep}{-\fboxrule} - \def\minted@bgcol{#1} - \noindent - \begin{lrbox}{\minted@bgbox} - \begin{minipage}{\linewidth-2\fboxsep}} - {\end{minipage} - \end{lrbox}% - \colorbox{\minted@bgcol}{\usebox{\minted@bgbox}}} +\newenvironment{minted@colorbg}[1]{% + \setlength{\OuterFrameSep}{0pt}% + \colorlet{shadecolor}{#1}% + \let\minted@tmp\FV@NumberSep + \edef\FV@NumberSep{% + \the\numexpr\dimexpr\minted@tmp+\number\fboxsep\relax sp\relax}% + \medskip + \begin{snugshade*}} + {\end{snugshade*}% + \medskip\noindent} \newwrite\minted@code \newcommand{\minted@savecode}[1]{ \immediate\openout\minted@code\minted@jobname.pyg\relax @@ -1020,7 +1175,9 @@ \ifcsname MintedPygmentize\endcsname\else \newcommand{\MintedPygmentize}{pygmentize} \fi +\newcounter{minted@pygmentizecounter} \newcommand{\minted@pygmentize}[2][\minted@outputdir\minted@jobname.pyg]{% + \stepcounter{minted@pygmentizecounter}% \ifthenelse{\equal{\minted@get@opt{autogobble}{false}}{true}}% {\def\minted@codefile{\minted@outputdir\minted@jobname.pyg}}% {\def\minted@codefile{#1}}% @@ -1035,90 +1192,187 @@ -f latex -P commandprefix=PYG -F tokenmerge \minted@optlistcl@g \csname minted@optlistcl@lang\minted@lang\endcsname \minted@optlistcl@inlines - \minted@optlistcl@cmd -o "\minted@outputdir\minted@infile" + \minted@optlistcl@cmd -o \minted@outputdir\minted@infile\space \ifminted@kpsewhich \ifwindows - \detokenize{$}(kpsewhich "\minted@codefile")% + \detokenize{$}(kpsewhich \minted@codefile)% \else - \detokenize{`}kpsewhich "\minted@codefile" - \detokenize{||} "\minted@codefile"\detokenize{`}% + \detokenize{`}kpsewhich \minted@codefile\space + \detokenize{||} \minted@codefile\detokenize{`}% \fi \else - "\minted@codefile" + \minted@codefile \fi}% % For debugging, uncomment: %%%% % \immediate\typeout{\minted@cmd}% % %%%% \ifthenelse{\boolean{minted@cache}}% {% - \ifx\XeTeXinterchartoks\minted@undefined - \ifthenelse{\equal{\minted@get@opt{autogobble}{false}}{true}}% - {\edef\minted@hash{\pdf@filemdfivesum{#1}% - \pdf@mdfivesum{\minted@cmd autogobble}}}% - {\edef\minted@hash{\pdf@filemdfivesum{#1}% - \pdf@mdfivesum{\minted@cmd}}}% + \ifminted@frozencache \else - \immediate\openout\minted@code\minted@jobname.mintedcmd\relax - \immediate\write\minted@code{\minted@cmd}% - \ifthenelse{\equal{\minted@get@opt{autogobble}{false}}{true}}% - {\immediate\write\minted@code{autogobble}}{}% - \immediate\closeout\minted@code - %Cheating a little here by using ASCII codes to write `{` and `}` - %in the Python code - \def\minted@hashcmd{% - \detokenize{python -c "import hashlib; - hasher = hashlib.sha1(); - f = open(\"}\minted@outputdir\minted@jobname.mintedcmd\detokenize{\", \"rb\"); - hasher.update(f.read()); - f.close(); - f = open(\"}#1\detokenize{\", \"rb\"); - hasher.update(f.read()); - f.close(); - f = open(\"}\minted@outputdir\minted@jobname.mintedmd5\detokenize{\", \"w\"); - macro = \"\\edef\\minted@hash\" + chr(123) + hasher.hexdigest() + chr(125) + \"\"; - f.write(\"\\makeatletter\" + macro + \"\\makeatother\\endinput\n\"); - f.close();"}}% - \immediate\write18{\minted@hashcmd}% - \minted@input{\minted@outputdir\minted@jobname.mintedmd5}% + \ifx\XeTeXinterchartoks\minted@undefined + \ifthenelse{\equal{\minted@get@opt{autogobble}{false}}{true}}% + {\edef\minted@hash{\pdf@filemdfivesum{#1}% + \pdf@mdfivesum{\minted@cmd autogobble}}}% + {\edef\minted@hash{\pdf@filemdfivesum{#1}% + \pdf@mdfivesum{\minted@cmd}}}% + \else + \immediate\openout\minted@code\minted@jobname.mintedcmd\relax + \immediate\write\minted@code{\minted@cmd}% + \ifthenelse{\equal{\minted@get@opt{autogobble}{false}}{true}}% + {\immediate\write\minted@code{autogobble}}{}% + \immediate\closeout\minted@code + \edef\minted@argone@esc{#1}% + \StrSubstitute{\minted@argone@esc}{\@backslashchar}{\@backslashchar\@backslashchar}[\minted@argone@esc]% + \StrSubstitute{\minted@argone@esc}{"}{\@backslashchar"}[\minted@argone@esc]% + \edef\minted@tmpfname@esc{\minted@outputdir\minted@jobname}% + \StrSubstitute{\minted@tmpfname@esc}{\@backslashchar}{\@backslashchar\@backslashchar}[\minted@tmpfname@esc]% + \StrSubstitute{\minted@tmpfname@esc}{"}{\@backslashchar"}[\minted@tmpfname@esc]% + %Cheating a little here by using ASCII codes to write `{` and `}` + %in the Python code + \def\minted@hashcmd{% + \detokenize{python -c "import hashlib; import os; + hasher = hashlib.sha1(); + f = open(os.path.expanduser(os.path.expandvars(\"}\minted@tmpfname@esc.mintedcmd\detokenize{\")), \"rb\"); + hasher.update(f.read()); + f.close(); + f = open(os.path.expanduser(os.path.expandvars(\"}\minted@argone@esc\detokenize{\")), \"rb\"); + hasher.update(f.read()); + f.close(); + f = open(os.path.expanduser(os.path.expandvars(\"}\minted@tmpfname@esc.mintedmd5\detokenize{\")), \"w\"); + macro = \"\\edef\\minted@hash\" + chr(123) + hasher.hexdigest() + chr(125) + \"\"; + f.write(\"\\makeatletter\" + macro + \"\\makeatother\\endinput\n\"); + f.close();"}}% + \ShellEscape{\minted@hashcmd}% + \minted@input{\minted@outputdir\minted@jobname.mintedmd5}% + \fi + \edef\minted@infile{\minted@cachedir/\minted@hash.pygtex}% + \IfFileExists{\minted@infile}{}{% + \ifthenelse{\equal{\minted@get@opt{autogobble}{false}}{true}}{% + \edef\minted@argone@esc{#1}% + \StrSubstitute{\minted@argone@esc}{\@backslashchar}{\@backslashchar\@backslashchar}[\minted@argone@esc]% + \StrSubstitute{\minted@argone@esc}{"}{\@backslashchar"}[\minted@argone@esc]% + \edef\minted@tmpfname@esc{\minted@outputdir\minted@jobname}% + \StrSubstitute{\minted@tmpfname@esc}{\@backslashchar}{\@backslashchar\@backslashchar}[\minted@tmpfname@esc]% + \StrSubstitute{\minted@tmpfname@esc}{"}{\@backslashchar"}[\minted@tmpfname@esc]% + %Need a version of open() that supports encoding under Python 2 + \edef\minted@autogobblecmd{% + \detokenize{python -c "import sys; import os; + import textwrap; + from io import open; + f = open(os.path.expanduser(os.path.expandvars(\"}\minted@argone@esc\detokenize{\")), \"r\", encoding=\"}\minted@encoding\detokenize{\"); + t = f.read(); + f.close(); + f = open(os.path.expanduser(os.path.expandvars(\"}\minted@tmpfname@esc.pyg\detokenize{\")), \"w\", encoding=\"}\minted@encoding\detokenize{\"); + f.write(textwrap.dedent(t)); + f.close();"}% + }% + \ShellEscape{\minted@autogobblecmd}}{}% + \ShellEscape{\minted@cmd}}% \fi - \edef\minted@infile{\minted@cachedir/\minted@hash.pygtex}% - \IfFileExists{\minted@infile}{}{% - \ifthenelse{\equal{\minted@get@opt{autogobble}{false}}{true}}{% - %Need a version of open() that supports encoding under Python 2 - \edef\minted@autogobblecmd{% - \detokenize{python -c "import sys; - import textwrap; - from io import open; - f = open(\"}#1\detokenize{\", \"r\", encoding=\"}\minted@encoding\detokenize{\"); - t = f.read(); - f.close(); - f = open(\"}\minted@outputdir\minted@jobname.pyg\detokenize{\", \"w\", encoding=\"}\minted@encoding\detokenize{\"); - f.write(textwrap.dedent(t)); - f.close();"}% - }% - \immediate\write18{\minted@autogobblecmd}}{}% - \immediate\write18{\minted@cmd}}% - \expandafter\minted@addcachefile\expandafter{\minted@hash.pygtex}% + \ifthenelse{\boolean{minted@finalizecache}}% + {% + \edef\minted@cachefilename{listing\arabic{minted@pygmentizecounter}.pygtex}% + \edef\minted@actualinfile{\minted@cachedir/\minted@cachefilename}% + \ifwindows + \StrSubstitute{\minted@infile}{/}{\@backslashchar}[\minted@infile@windows] + \StrSubstitute{\minted@actualinfile}{/}{\@backslashchar}[\minted@actualinfile@windows] + \ShellEscape{move /y \minted@infile@windows\space\minted@actualinfile@windows}% + \else + \ShellEscape{mv -f \minted@infile\space\minted@actualinfile}% + \fi + \let\minted@infile\minted@actualinfile + \expandafter\minted@addcachefile\expandafter{\minted@cachefilename}% + }% + {\ifthenelse{\boolean{minted@frozencache}}% + {% + \edef\minted@cachefilename{listing\arabic{minted@pygmentizecounter}.pygtex}% + \edef\minted@infile{\minted@cachedir/\minted@cachefilename}% + \expandafter\minted@addcachefile\expandafter{\minted@cachefilename}}% + {\expandafter\minted@addcachefile\expandafter{\minted@hash.pygtex}}% + }% \minted@inputpyg}% {% \ifthenelse{\equal{\minted@get@opt{autogobble}{false}}{true}}{% + \edef\minted@argone@esc{#1}% + \StrSubstitute{\minted@argone@esc}{\@backslashchar}{\@backslashchar\@backslashchar}[\minted@argone@esc]% + \StrSubstitute{\minted@argone@esc}{"}{\@backslashchar"}[\minted@argone@esc]% + \edef\minted@tmpfname@esc{\minted@outputdir\minted@jobname}% + \StrSubstitute{\minted@tmpfname@esc}{\@backslashchar}{\@backslashchar\@backslashchar}[\minted@tmpfname@esc]% + \StrSubstitute{\minted@tmpfname@esc}{"}{\@backslashchar"}[\minted@tmpfname@esc]% %Need a version of open() that supports encoding under Python 2 \edef\minted@autogobblecmd{% - \detokenize{python -c "import sys; + \detokenize{python -c "import sys; import os; import textwrap; from io import open; - f = open(\"}#1\detokenize{\", \"r\", encoding=\"}\minted@encoding\detokenize{\"); + f = open(os.path.expanduser(os.path.expandvars(\"}\minted@argone@esc\detokenize{\")), \"r\", encoding=\"}\minted@encoding\detokenize{\"); t = f.read(); f.close(); - f = open(\"}\minted@outputdir\minted@jobname.pyg\detokenize{\", \"w\", encoding=\"}\minted@encoding\detokenize{\"); + f = open(os.path.expanduser(os.path.expandvars(\"}\minted@tmpfname@esc.pyg\detokenize{\")), \"w\", encoding=\"}\minted@encoding\detokenize{\"); f.write(textwrap.dedent(t)); f.close();"}% }% - \immediate\write18{\minted@autogobblecmd}}{}% - \immediate\write18{\minted@cmd}% + \ShellEscape{\minted@autogobblecmd}}{}% + \ShellEscape{\minted@cmd}% \minted@inputpyg}% } \def\FV@SpaceMMode{ } +\def\minted@BreakBeforePrep@extension{% + \ifcsname FV@BreakBefore@Token\@backslashchar\endcsname + \@namedef{FV@BreakBefore@Token\detokenize{\PYGZbs}}{}% + \fi + \ifcsname FV@BreakBefore@Token\FV@underscorechar\endcsname + \@namedef{FV@BreakBefore@Token\detokenize{\PYGZus}}{}% + \fi + \ifcsname FV@BreakBefore@Token\@charlb\endcsname + \@namedef{FV@BreakBefore@Token\detokenize{\PYGZob}}{}% + \fi + \ifcsname FV@BreakBefore@Token\@charrb\endcsname + \@namedef{FV@BreakBefore@Token\detokenize{\PYGZcb}}{}% + \fi + \ifcsname FV@BreakBefore@Token\detokenize{^}\endcsname + \@namedef{FV@BreakBefore@Token\detokenize{\PYGZca}}{}% + \fi + \ifcsname FV@BreakBefore@Token\FV@ampchar\endcsname + \@namedef{FV@BreakBefore@Token\detokenize{\PYGZam}}{}% + \fi + \ifcsname FV@BreakBefore@Token\detokenize{<}\endcsname + \@namedef{FV@BreakBefore@Token\detokenize{\PYGZlt}}{}% + \fi + \ifcsname FV@BreakBefore@Token\detokenize{>}\endcsname + \@namedef{FV@BreakBefore@Token\detokenize{\PYGZgt}}{}% + \fi + \ifcsname FV@BreakBefore@Token\FV@hashchar\endcsname + \@namedef{FV@BreakBefore@Token\detokenize{\PYGZsh}}{}% + \fi + \ifcsname FV@BreakBefore@Token\@percentchar\endcsname + \@namedef{FV@BreakBefore@Token\detokenize{\PYGZpc}}{}% + \fi + \ifcsname FV@BreakBefore@Token\FV@dollarchar\endcsname + \@namedef{FV@BreakBefore@Token\detokenize{\PYGZdl}}{}% + \fi + \ifcsname FV@BreakBefore@Token\detokenize{-}\endcsname + \@namedef{FV@BreakBefore@Token\detokenize{\PYGZhy}}{}% + \fi + \ifcsname FV@BreakBefore@Token\detokenize{'}\endcsname + \@namedef{FV@BreakBefore@Token\detokenize{\PYGZsq}}{}% + \fi + \ifcsname FV@BreakBefore@Token\detokenize{"}\endcsname + \@namedef{FV@BreakBefore@Token\detokenize{\PYGZdq}}{}% + \fi + \ifcsname FV@BreakBefore@Token\FV@tildechar\endcsname + \@namedef{FV@BreakBefore@Token\detokenize{\PYGZti}}{}% + \fi + \ifcsname FV@BreakBefore@Token\detokenize{@}\endcsname + \@namedef{FV@BreakBefore@Token\detokenize{\PYGZat}}{}% + \fi + \ifcsname FV@BreakBefore@Token\detokenize{[}\endcsname + \@namedef{FV@BreakBefore@Token\detokenize{\PYGZlb}}{}% + \fi + \ifcsname FV@BreakBefore@Token\detokenize{]}\endcsname + \@namedef{FV@BreakBefore@Token\detokenize{\PYGZrb}}{}% + \fi +} \def\minted@BreakAfterPrep@extension{% \ifcsname FV@BreakAfter@Token\@backslashchar\endcsname \@namedef{FV@BreakAfter@Token\detokenize{\PYGZbs}}{}% @@ -1176,6 +1430,9 @@ \fi } \newcommand{\minted@inputpyg}{% + \let\FV@BreakBeforePrep@orig\FV@BreakBeforePrep + \def\FV@BreakBeforePrep{% + \FV@BreakBeforePrep@orig\minted@BreakBeforePrep@extension}% \let\FV@BreakAfterPrep@orig\FV@BreakAfterPrep \def\FV@BreakAfterPrep{% \FV@BreakAfterPrep@orig\minted@BreakAfterPrep@extension}% @@ -1188,12 +1445,20 @@ \expandafter\def\csname PYG\minted@get@opt{style}{default}\endcsname##1##2{% \minted@orig@PYG@breakanywhere{##1}% {\FancyVerbBreakStart##2\FancyVerbBreakStop}}}{}% - \ifx\FV@BreakAfter\@empty + \ifx\FV@BreakBefore\@empty + \ifx\FV@BreakAfter\@empty + \else + \expandafter\let\expandafter\minted@orig@PYG@breakbeforeafter% + \csname PYG\minted@get@opt{style}{default}\endcsname + \expandafter\def\csname PYG\minted@get@opt{style}{default}\endcsname##1##2{% + \minted@orig@PYG@breakbeforeafter{##1}% + {\FancyVerbBreakStart##2\FancyVerbBreakStop}}% + \fi \else - \expandafter\let\expandafter\minted@orig@PYG@breakafter% + \expandafter\let\expandafter\minted@orig@PYG@breakbeforeafter% \csname PYG\minted@get@opt{style}{default}\endcsname \expandafter\def\csname PYG\minted@get@opt{style}{default}\endcsname##1##2{% - \minted@orig@PYG@breakafter{##1}% + \minted@orig@PYG@breakbeforeafter{##1}% {\FancyVerbBreakStart##2\FancyVerbBreakStop}}% \fi \ifthenelse{\boolean{minted@isinline}}% @@ -1469,37 +1734,48 @@ \providecommand{\listoflistings}{\listof{listing}{\listoflistingscaption}} \fi \AtEndOfPackage{% - \ifthenelse{\boolean{minted@draft}}{}{% - \ifnum\pdf@shellescape=1\relax\else - \PackageError{minted}% - {You must invoke LaTeX with the - -shell-escape flag}% - {Pass the -shell-escape flag to LaTeX. Refer to the minted.sty - documentation for more information.}% - \fi - \setminted{style=default}% - }% + \ifthenelse{\boolean{minted@draft}}% + {}% + {% + \ifthenelse{\boolean{minted@frozencache}}{}{% + \ifnum\pdf@shellescape=1\relax\else + \PackageError{minted}% + {You must invoke LaTeX with the + -shell-escape flag}% + {Pass the -shell-escape flag to LaTeX. Refer to the minted.sty + documentation for more information.}% + \fi}% + }% } \AtEndPreamble{% - \ifthenelse{\boolean{minted@draft}}{}{% - \TestAppExists{pygmentize}% - \ifAppExists\else - \PackageError{minted}% - {You must have `pygmentize' installed - to use this package}% - {Refer to the installation instructions in the minted - documentation for more information.}% - \fi + \ifthenelse{\boolean{minted@draft}}% + {}% + {% + \ifthenelse{\boolean{minted@frozencache}}{}{% + \TestAppExists{\MintedPygmentize}% + \ifAppExists\else + \PackageError{minted}% + {You must have `pygmentize' installed + to use this package}% + {Refer to the installation instructions in the minted + documentation for more information.}% + \fi}% }% } -\AtEndDocument{ - \ifx\XeTeXinterchartoks\minted@undefined - \else - \DeleteFile[\minted@outputdir]{\minted@jobname.mintedcmd}% - \DeleteFile[\minted@outputdir]{\minted@jobname.mintedmd5}% - \fi - \DeleteFile[\minted@outputdir]{\minted@jobname.pyg}% - \DeleteFile[\minted@outputdir]{\minted@jobname.out.pyg}% +\AfterEndDocument{% + \ifthenelse{\boolean{minted@draft}}% + {}% + {\ifthenelse{\boolean{minted@frozencache}}% + {} + {\ifx\XeTeXinterchartoks\minted@undefined + \else + \DeleteFile[\minted@outputdir]{\minted@jobname.mintedcmd}% + \DeleteFile[\minted@outputdir]{\minted@jobname.mintedmd5}% + \fi + \DeleteFile[\minted@outputdir]{\minted@jobname.pyg}% + \DeleteFile[\minted@outputdir]{\minted@jobname.out.pyg}% + }% + }% } \endinput %% diff --git a/Master/texmf-dist/tex/latex/minted/minted1.sty b/Master/texmf-dist/tex/latex/minted/minted1.sty index a8aaf50ad98..79ef87ed968 100644 --- a/Master/texmf-dist/tex/latex/minted/minted1.sty +++ b/Master/texmf-dist/tex/latex/minted/minted1.sty @@ -5,7 +5,7 @@ %% The original source files were: %% %% minted.dtx (with options: `packageone') -%% Copyright 2013--2015 Geoffrey M. Poore +%% Copyright 2013--2016 Geoffrey M. Poore %% Copyright 2010--2011 Konrad Rudolph %% %% This work may be distributed and/or modified under the |