summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/minted
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2015-09-10 20:56:54 +0000
committerKarl Berry <karl@freefriends.org>2015-09-10 20:56:54 +0000
commitb9de8b37ede65e75de420bd3814aa62f4e1017d6 (patch)
treee567f16f699ad973eec5a2a6bf459936100e9e37 /Master/texmf-dist/tex/latex/minted
parentd55d075d6e1c947a2332b90c36d75147a6919180 (diff)
minted (10sep15)
git-svn-id: svn://tug.org/texlive/trunk@38339 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/minted')
-rw-r--r--Master/texmf-dist/tex/latex/minted/minted.sty617
1 files changed, 451 insertions, 166 deletions
diff --git a/Master/texmf-dist/tex/latex/minted/minted.sty b/Master/texmf-dist/tex/latex/minted/minted.sty
index 7fef35aade6..197df6a01db 100644
--- a/Master/texmf-dist/tex/latex/minted/minted.sty
+++ b/Master/texmf-dist/tex/latex/minted/minted.sty
@@ -27,7 +27,7 @@
%% and the derived file minted.sty.
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{minted}
- [2015/01/31 v2.0 Yet another Pygments shim for LaTeX]
+ [2015/09/09 v2.1 Yet another Pygments shim for LaTeX]
\RequirePackage{keyval}
\RequirePackage{kvoptions}
\RequirePackage{fancyvrb}
@@ -48,8 +48,8 @@
\DeclareBoolOption{newfloat}
\DeclareBoolOption[true]{cache}
\StrSubstitute{\jobname}{ }{_}[\minted@jobname]
+\StrSubstitute{\minted@jobname}{*}{_}[\minted@jobname]
\StrSubstitute{\minted@jobname}{"}{}[\minted@jobname]
-\StrSubstitute{\minted@jobname}{*}{-}[\minted@jobname]
\newcommand{\minted@cachedir}{\detokenize{_}minted-\minted@jobname}
\let\minted@cachedir@windows\minted@cachedir
\define@key{minted}{cachedir}{%
@@ -67,6 +67,11 @@
\DeclareComplementaryOption{final}{draft}
\ProcessKeyvalOptions*
\ifthenelse{\boolean{minted@newfloat}}{\RequirePackage{newfloat}}{}
+\ifcsname tikzexternalrealjob\endcsname
+ \minted@drafttrue
+ \minted@cachefalse
+\else
+\fi
\ifthenelse{\boolean{minted@cache}}{%
\AtEndOfPackage{\ProvideDirectory{\minted@outputdir\minted@cachedir}}}{}
\newcommand{\minted@input}[1]{%
@@ -82,7 +87,7 @@
^^Jchanges paths in ways minted cannot detect\ifwindows, or by using the
^^Jkpsewhich option without PowerShell\fi.}}%
}
-\newcommand{\minted@infile}{\jobname.out.pyg}
+\newcommand{\minted@infile}{\minted@jobname.out.pyg}
\newcommand{\minted@cachelist}{}
\newcommand{\minted@addcachefile}[1]{%
\expandafter\long\expandafter\gdef\expandafter\minted@cachelist\expandafter{%
@@ -144,12 +149,12 @@
\newread\minted@appexistsfile
\newcommand{\TestAppExists}[1]{
\ifwindows
- \DeleteFile{\jobname.aex}
+ \DeleteFile{\minted@jobname.aex}
\immediate\write18{for \string^\@percentchar i in (#1.exe #1.bat #1.cmd)
- do set >"\jobname.aex" <nul: /p
- x=\string^\@percentchar \string~$PATH:i>>"\jobname.aex"}
+ do set >"\minted@jobname.aex" <nul: /p
+ x=\string^\@percentchar \string~$PATH:i>>"\minted@jobname.aex"}
%$ <- balance syntax highlighting
- \immediate\openin\minted@appexistsfile\jobname.aex
+ \immediate\openin\minted@appexistsfile\minted@jobname.aex
\expandafter\def\expandafter\@tmp@cr\expandafter{\the\endlinechar}
\endlinechar=-1\relax
\readline\minted@appexistsfile to \minted@apppathifexists
@@ -158,12 +163,12 @@
{\AppExistsfalse}
{\AppExiststrue}
\immediate\closein\minted@appexistsfile
- \DeleteFile{\jobname.aex}
+ \DeleteFile{\minted@jobname.aex}
\else
- \immediate\write18{which "#1" && touch "\jobname.aex"}
- \IfFileExists{\jobname.aex}
+ \immediate\write18{which "#1" && touch "\minted@jobname.aex"}
+ \IfFileExists{\minted@jobname.aex}
{\AppExiststrue
- \DeleteFile{\jobname.aex}}
+ \DeleteFile{\minted@jobname.aex}}
{\AppExistsfalse}
\fi
}
@@ -241,6 +246,8 @@
\edef\minted@ampchar{\string&}
\edef\minted@underscorechar{\string_}
\edef\minted@tildechar{\string~}
+\edef\minted@leftsquarebracket{\string[}
+\edef\minted@rightsquarebracket{\string]}
\newcommand{\minted@escchars}{%
\let\#\minted@hashchar
\let\%\@percentchar
@@ -252,6 +259,8 @@
\let\\\@backslashchar
\let~\minted@tildechar
\let\~\minted@tildechar
+ \let\[\minted@leftsquarebracket
+ \let\]\minted@rightsquarebracket
} %$ <- highlighting
\newcommand{\minted@addto@optlistcl@e}[2]{%
\begingroup
@@ -306,91 +315,6 @@
\minted@addto@optlistcl@e{\minted@optlistcl@cmd}{#3=#4}%
\@namedef{minted@opt@cmd:#2}{#4}}}%
}
-\newcommand{\minted@def@optcl@style}{%
- \define@key{minted@opt@g}{style}{%
- \minted@addto@optlistcl{\minted@optlistcl@g}%
- {-P style=##1 -P commandprefix=PYG##1}%
- \minted@checkstyle{##1}%
- \@namedef{minted@opt@g:style}{##1}}%
- \define@key{minted@opt@g@i}{style}{%
- \minted@addto@optlistcl{\minted@optlistcl@g@i}%
- {-P style=##1 -P commandprefix=PYG##1}%
- \minted@checkstyle{##1}%
- \@namedef{minted@opt@g@i:style}{##1}}%
- \define@key{minted@opt@lang}{style}{%
- \minted@addto@optlistcl@lang{minted@optlistcl@lang\minted@lang}%
- {-P style=##1 -P commandprefix=PYG##1}%
- \minted@checkstyle{##1}%
- \@namedef{minted@opt@lang\minted@lang:style}{##1}}%
- \define@key{minted@opt@lang@i}{style}{%
- \minted@addto@optlistcl@lang{minted@optlistcl@lang\minted@lang @i}%
- {-P style=##1 -P commandprefix=PYG##1}%
- \minted@checkstyle{##1}%
- \@namedef{minted@opt@lang\minted@lang @i:style}{##1}}%
- \define@key{minted@opt@cmd}{style}{%
- \minted@addto@optlistcl{\minted@optlistcl@cmd}%
- {-P style=##1 -P commandprefix=PYG##1}%
- \minted@checkstyle{##1}%
- \@namedef{minted@opt@cmd:style}{##1}}%
-}
-\newcommand{\minted@patch@Zsq}[1]{%
- \ifx\upquote@cmtt\minted@undefined\else
- \ifx\encodingdefault\upquote@OTone
- \ifx\ttdefault\upquote@cmtt
- \expandafter\ifdefstring\expandafter{\csname PYG#1Zsq\endcsname}{\char`\'}%
- {\expandafter\gdef\csname PYG#1Zsq\endcsname{\char13 }}{}%
- \else
- \expandafter\ifdefstring\expandafter{\csname PYG#1Zsq\endcsname}{\char`\'}%
- {\expandafter\gdef\csname PYG#1Zsq\endcsname{\textquotesingle}}{}%
- \fi
- \else
- \expandafter\ifdefstring\expandafter{\csname PYG#1Zsq\endcsname}{\char`\'}%
- {\expandafter\gdef\csname PYG#1Zsq\endcsname{\textquotesingle}}{}%
- \fi
- \fi
-}
-\newcommand{\minted@checkstyle}[1]{%
- \ifcsname minted@styleloaded@#1\endcsname\else
- \expandafter\gdef\csname minted@styleloaded@#1\endcsname{}%
- \ifthenelse{\boolean{minted@cache}}%
- {\IfFileExists{\minted@outputdir\minted@cachedir/#1.pygstyle}{}{%
- \ifwindows
- \immediate\write18{\MintedPygmentize\space -S #1 -f latex
- -P commandprefix=PYG#1
- > "\minted@outputdir@windows\minted@cachedir@windows\@backslashchar#1.pygstyle"}%
- \else
- \immediate\write18{\MintedPygmentize\space -S #1 -f latex
- -P commandprefix=PYG#1
- > "\minted@outputdir\minted@cachedir/#1.pygstyle"}%
- \fi
- }%
- \begingroup
- \let\def\gdef
- \endlinechar=-1\relax
- \minted@input{\minted@outputdir\minted@cachedir/#1.pygstyle}%
- \endgroup
- \minted@addcachefile{#1.pygstyle}}%
- {\ifwindows
- \immediate\write18{\MintedPygmentize\space -S #1 -f latex
- -P commandprefix=PYG#1 > "\minted@outputdir@windows\jobname.out.pyg"}%
- \else
- \immediate\write18{\MintedPygmentize\space -S #1 -f latex
- -P commandprefix=PYG#1 > "\minted@outputdir\jobname.out.pyg"}%
- \fi
- \begingroup
- \let\def\gdef
- \endlinechar=-1\relax
- \minted@input{\minted@outputdir\jobname.out.pyg}%
- \endgroup}%
- \ifx\@onlypreamble\@notprerr
- \minted@patch@Zsq{#1}%
- \else
- \minted@patch@Zsq{#1}%
- \AtBeginDocument{\minted@patch@Zsq{#1}}%
- \fi
- \fi
-}
-\ifthenelse{\boolean{minted@draft}}{\renewcommand{\minted@checkstyle}[1]{}}{}
\newcommand{\minted@def@optcl@switch}[2]{%
\define@booleankey{minted@opt@g}{#1}%
{\minted@addto@optlistcl{\minted@optlistcl@g}{#2=True}%
@@ -515,6 +439,120 @@
{}%
\expandafter\fvset\expandafter{\minted@optlistfv@cmd}%
}
+\newcommand{\minted@def@opt}[2][]{%
+ \define@key{minted@opt@g}{#2}{%
+ \@namedef{minted@opt@g:#2}{##1}}
+ \define@key{minted@opt@g@i}{#2}{%
+ \@namedef{minted@opt@g@i:#2}{##1}}
+ \define@key{minted@opt@lang}{#2}{%
+ \@namedef{minted@opt@lang\minted@lang:#2}{##1}}
+ \define@key{minted@opt@lang@i}{#2}{%
+ \@namedef{minted@opt@lang\minted@lang @i:#2}{##1}}
+ \define@key{minted@opt@cmd}{#2}{%
+ \@namedef{minted@opt@cmd:#2}{##1}}
+}
+\newcommand{\minted@def@opt@style}{%
+ \define@key{minted@opt@g}{style}{%
+ \minted@checkstyle{##1}%
+ \@namedef{minted@opt@g:style}{##1}}%
+ \define@key{minted@opt@g@i}{style}{%
+ \minted@checkstyle{##1}%
+ \@namedef{minted@opt@g@i:style}{##1}}%
+ \define@key{minted@opt@lang}{style}{%
+ \minted@checkstyle{##1}%
+ \@namedef{minted@opt@lang\minted@lang:style}{##1}}%
+ \define@key{minted@opt@lang@i}{style}{%
+ \minted@checkstyle{##1}%
+ \@namedef{minted@opt@lang\minted@lang @i:style}{##1}}%
+ \define@key{minted@opt@cmd}{style}{%
+ \minted@checkstyle{##1}%
+ \@namedef{minted@opt@cmd:style}{##1}}%
+}
+\newcommand{\minted@checkstyle}[1]{%
+ \ifcsname minted@styleloaded@\ifstrempty{#1}{default-pyg-prefix}{#1}\endcsname\else
+ \expandafter\gdef%
+ \csname minted@styleloaded@\ifstrempty{#1}{default-pyg-prefix}{#1}\endcsname{}%
+ \ifthenelse{\boolean{minted@cache}}%
+ {\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
+ }%
+ \begingroup
+ \let\def\gdef
+ \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{%
+ \MintedPygmentize\space -S \ifstrempty{#1}{default}{#1} -f latex
+ -P commandprefix=PYG#1 > "\minted@outputdir@windows\minted@jobname.out.pyg"}%
+ \else
+ \immediate\write18{%
+ \MintedPygmentize\space -S \ifstrempty{#1}{default}{#1} -f latex
+ -P commandprefix=PYG#1 > "\minted@outputdir\minted@jobname.out.pyg"}%
+ \fi
+ \begingroup
+ \let\def\gdef
+ \endlinechar=-1\relax
+ \minted@input{\minted@outputdir\minted@jobname.out.pyg}%
+ \endgroup}%
+ \fi
+}
+\ifthenelse{\boolean{minted@draft}}{\renewcommand{\minted@checkstyle}[1]{}}{}
+\AtBeginDocument{\minted@checkstyle{}}
+\newcommand{\minted@patch@PYGZsq}{%
+ \ifcsname PYGZsq\endcsname
+ \ifx\upquote@cmtt\minted@undefined\else
+ \ifx\encodingdefault\upquote@OTone
+ \ifx\ttdefault\upquote@cmtt
+ \expandafter\ifdefstring\expandafter{\csname PYGZsq\endcsname}{\char`\'}%
+ {\expandafter\gdef\csname PYGZsq\endcsname{\char13 }}{}%
+ \else
+ \expandafter\ifdefstring\expandafter{\csname PYGZsq\endcsname}{\char`\'}%
+ {\expandafter\gdef\csname PYGZsq\endcsname{\textquotesingle}}{}%
+ \fi
+ \else
+ \expandafter\ifdefstring\expandafter{\csname PYGZsq\endcsname}{\char`\'}%
+ {\expandafter\gdef\csname PYGZsq\endcsname{\textquotesingle}}{}%
+ \fi
+ \fi
+ \fi
+}
+\ifthenelse{\boolean{minted@draft}}{}{\AtBeginDocument{\minted@patch@PYGZsq}}
+\newcommand{\minted@def@opt@switch}[2][false]{%
+ \define@booleankey{minted@opt@g}{#2}%
+ {\@namedef{minted@opt@g:#2}{true}}%
+ {\@namedef{minted@opt@g:#2}{false}}
+ \define@booleankey{minted@opt@g@i}{#2}%
+ {\@namedef{minted@opt@g@i:#2}{true}}%
+ {\@namedef{minted@opt@g@i:#2}{false}}
+ \define@booleankey{minted@opt@lang}{#2}%
+ {\@namedef{minted@opt@lang\minted@lang:#2}{true}}%
+ {\@namedef{minted@opt@lang\minted@lang:#2}{false}}
+ \define@booleankey{minted@opt@lang@i}{#2}%
+ {\@namedef{minted@opt@lang\minted@lang @i:#2}{true}}%
+ {\@namedef{minted@opt@lang\minted@lang @i:#2}{false}}
+ \define@booleankey{minted@opt@cmd}{#2}%
+ {\@namedef{minted@opt@cmd:#2}{true}}%
+ {\@namedef{minted@opt@cmd:#2}{false}}%
+ \@namedef{minted@opt@g:#2}{#1}%
+}
\def\minted@get@opt#1#2{%
\ifcsname minted@opt@cmd:#1\endcsname
\csname minted@opt@cmd:#1\endcsname
@@ -550,37 +588,6 @@
\fi
\fi
}%
-\newcommand{\minted@def@opt}[2][]{%
- \define@key{minted@opt@g}{#2}{%
- \@namedef{minted@opt@g:#2}{##1}}
- \define@key{minted@opt@g@i}{#2}{%
- \@namedef{minted@opt@g@i:#2}{##1}}
- \define@key{minted@opt@lang}{#2}{%
- \@namedef{minted@opt@lang\minted@lang:#2}{##1}}
- \define@key{minted@opt@lang@i}{#2}{%
- \@namedef{minted@opt@lang\minted@lang @i:#2}{##1}}
- \define@key{minted@opt@cmd}{#2}{%
- \@namedef{minted@opt@cmd:#2}{##1}}
-}
-\newcommand{\minted@def@opt@switch}[2][false]{%
- \define@booleankey{minted@opt@g}{#2}%
- {\@namedef{minted@opt@g:#2}{true}}%
- {\@namedef{minted@opt@g:#2}{false}}
- \define@booleankey{minted@opt@g@i}{#2}%
- {\@namedef{minted@opt@g@i:#2}{true}}%
- {\@namedef{minted@opt@g@i:#2}{false}}
- \define@booleankey{minted@opt@lang}{#2}%
- {\@namedef{minted@opt@lang\minted@lang:#2}{true}}%
- {\@namedef{minted@opt@lang\minted@lang:#2}{false}}
- \define@booleankey{minted@opt@lang@i}{#2}%
- {\@namedef{minted@opt@lang\minted@lang @i:#2}{true}}%
- {\@namedef{minted@opt@lang\minted@lang @i:#2}{false}}
- \define@booleankey{minted@opt@cmd}{#2}%
- {\@namedef{minted@opt@cmd:#2}{true}}%
- {\@namedef{minted@opt@cmd:#2}{false}}%
- \@namedef{minted@opt@g:#2}{#1}%
-}
-
\minted@def@optcl{encoding}{-P encoding}{#1}
\minted@def@optcl{outencoding}{-P outencoding}{#1}
\minted@def@optcl@e{escapeinside}{-P "escapeinside}{#1"}
@@ -597,12 +604,8 @@
\minted@def@optcl@switch{texcl}{-P texcomments}
\minted@def@optcl@switch{texcomments}{-P texcomments}
\minted@def@optcl@switch{mathescape}{-P mathescape}
-\ifcsname KV@FV@linenos\endcsname\else
-\define@booleankey{FV}{linenos}%
- {\@nameuse{FV@Numbers@left}}{\@nameuse{FV@Numbers@none}}
-\fi
\minted@def@optfv@switch{linenos}
-\minted@def@optcl@style
+\minted@def@opt@style
\minted@def@optfv{frame}
\minted@def@optfv{framesep}
\minted@def@optfv{framerule}
@@ -642,7 +645,15 @@
\minted@def@optfv{breaksymbolright}
\minted@def@optfv{breaksymbolsepright}
\minted@def@optfv{breaksymbolindentright}
+\minted@def@optfv{breakafter}
+\minted@def@optfv@switch{breakaftergroup}
+\minted@def@optfv{breakaftersymbolpre}
+\minted@def@optfv{breakaftersymbolpost}
+\minted@def@optfv@switch{breakanywhere}
+\minted@def@optfv{breakanywheresymbolpre}
+\minted@def@optfv{breakanywheresymbolpost}
\minted@def@opt@switch{breakbytoken}
+\minted@def@opt@switch{breakbytokenanywhere}
\minted@def@opt{bgcolor}
\minted@def@opt@switch{autogobble}
\newcommand{\minted@encoding}{\minted@get@opt{encoding}{UTF8}}
@@ -687,6 +698,105 @@
\setcounter{FancyVerbLineBreakLast}{\value{linenumber}}}
\newcommand{\FancyVerbFormatBreakSymbolRight}[1]{%
\ifnum\value{linenumber}=\value{FancyVerbLineBreakLast}\relax\else{#1}\fi}
+\newboolean{FV@BreakAnywhere}
+\define@booleankey{FV}{breakanywhere}%
+ {\FV@BreakAnywheretrue
+ \let\FancyVerbBreakStart\FV@Break
+ \let\FancyVerbBreakStop\FV@EndBreak
+ \let\FV@Break@Token\FV@Break@AnyToken}%
+ {\FV@BreakAnywherefalse
+ \let\FancyVerbBreakStart\relax
+ \let\FancyVerbBreakStop\relax}
+\fvset{breakanywhere=false}
+\let\FancyVerbBreakStart\relax
+\let\FancyVerbBreakStop\relax
+\edef\FV@hashchar{\string#}
+\edef\FV@dollarchar{\string$}
+\edef\FV@ampchar{\string&}
+\edef\FV@underscorechar{\string_}
+\edef\FV@tildechar{\string~}
+\edef\FV@leftsquarebracket{\string[}
+\edef\FV@rightsquarebracket{\string]}
+\newcommand{\FV@EscChars}{%
+ \let\#\FV@hashchar
+ \let\%\@percentchar
+ \let\{\@charlb
+ \let\}\@charrb
+ \let\$\FV@dollarchar
+ \let\&\FV@ampchar
+ \let\_\FV@underscorechar
+ \let\\\@backslashchar
+ \let~\FV@tildechar
+ \let\~\FV@tildechar
+ \let\[\FV@leftsquarebracket
+ \let\]\FV@rightsquarebracket
+} %$ <- highlighting
+\define@key{FV}{breakafter}{%
+ \ifstrempty{#1}%
+ {\let\FV@BreakAfter\@empty
+ \let\FancyVerbBreakStart\relax
+ \let\FancyVerbBreakStop\relax}%
+ {\def\FV@BreakAfter{#1}%
+ \let\FancyVerbBreakStart\FV@Break
+ \let\FancyVerbBreakStop\FV@EndBreak
+ \let\FV@Break@Token\FV@Break@AfterToken}%
+}
+\fvset{breakafter={}}
+\newboolean{FV@BreakAfterGroup}
+\define@booleankey{FV}{breakaftergroup}%
+ {\FV@BreakAfterGrouptrue}%
+ {\FV@BreakAfterGroupfalse}%
+\fvset{breakaftergroup=true}
+\def\FV@BreakAfterPrep{%
+ \ifx\FV@BreakAfter\@empty\relax
+ \else
+ \gdef\FV@BreakAfter@Def{}%
+ \begingroup
+ \def\FV@BreakAfter@Process##1##2\FV@Undefined{%
+ \expandafter\FV@BreakAfter@Process@i\expandafter{##1}%
+ \expandafter\ifx\expandafter\relax\detokenize{##2}\relax
+ \else
+ \FV@BreakAfter@Process##2\FV@Undefined
+ \fi
+ }%
+ \def\FV@BreakAfter@Process@i##1{%
+ \g@addto@macro\FV@BreakAfter@Def{%
+ \@namedef{FV@BreakAfter@Token\detokenize{##1}}{}}%
+ }%
+ \FV@EscChars
+ \expandafter\FV@BreakAfter@Process\FV@BreakAfter\FV@Undefined
+ \endgroup
+ \FV@BreakAfter@Def
+ \fi
+}
+\expandafter\def\expandafter\FV@FormattingPrep\expandafter{%
+ \expandafter\FV@BreakAfterPrep\FV@FormattingPrep}
+\define@key{FV}{breakanywheresymbolpre}{%
+ \ifstrempty{#1}%
+ {\def\FancyVerbBreakAnywhereSymbolPre{}}%
+ {\def\FancyVerbBreakAnywhereSymbolPre{\hbox{#1}}}}
+\fvset{breakanywheresymbolpre={\,\footnotesize\ensuremath{_\rfloor}}}
+\define@key{FV}{breakanywheresymbolpost}{%
+ \ifstrempty{#1}%
+ {\def\FancyVerbBreakAnywhereSymbolPost{}}%
+ {\def\FancyVerbBreakAnywhereSymbolPost{\hbox{#1}}}}
+\fvset{breakanywheresymbolpost={}}
+\define@key{FV}{breakaftersymbolpre}{%
+ \ifstrempty{#1}%
+ {\def\FancyVerbBreakAfterSymbolPre{}}%
+ {\def\FancyVerbBreakAfterSymbolPre{\hbox{#1}}}}
+\fvset{breakaftersymbolpre={\,\footnotesize\ensuremath{_\rfloor}}}
+\define@key{FV}{breakaftersymbolpost}{%
+ \ifstrempty{#1}%
+ {\def\FancyVerbBreakAfterSymbolPost{}}%
+ {\def\FancyVerbBreakAfterSymbolPost{\hbox{#1}}}}
+\fvset{breakaftersymbolpost={}}
+\newcommand{\FancyVerbBreakAnywhereBreak}{%
+ \discretionary{\FancyVerbBreakAnywhereSymbolPre}%
+ {\FancyVerbBreakAnywhereSymbolPost}{}}
+\newcommand{\FancyVerbBreakAfterBreak}{%
+ \discretionary{\FancyVerbBreakAfterSymbolPre}%
+ {\FancyVerbBreakAfterSymbolPost}{}}
\newsavebox{\FV@LineBox}
\newsavebox{\FV@LineIndentBox}
\let\FV@LineIndentChars\@empty
@@ -711,6 +821,83 @@
\fi
\FV@Next
}
+\def\FV@Break{%
+ \def\FV@Tmp{}%
+ \FV@Break@Scan
+}
+\def\FV@EndBreak{\FV@Tmp}
+\begingroup
+\catcode`\$=3%
+\gdef\FV@Break@Scan{%
+ \@ifnextchar\FV@EndBreak%
+ {}%
+ {\ifx\@let@token$\relax
+ \let\FV@Break@Next\FV@Break@Math
+ \else
+ \ifx\@let@token\bgroup\relax
+ \let\FV@Break@Next\FV@Break@Group
+ \else
+ \let\FV@Break@Next\FV@Break@Token
+ \fi
+ \fi
+ \FV@Break@Next}%
+}
+\endgroup
+\begingroup
+\catcode`\$=3%
+\gdef\FV@Break@Math$#1${%
+ \g@addto@macro{\FV@Tmp}{$#1$}%
+ \FV@Break@Scan}
+\endgroup
+\def\FV@Break@Group#1{%
+ \g@addto@macro{\FV@Tmp}{{#1}}%
+ \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
+ \else
+ \let\FV@Break@Next\FV@Break@AfterTokenNoBreak
+ \fi
+ \FV@Break@Next{#1}%
+}
+\def\FV@Break@AfterTokenNoBreak#1{%
+ \g@addto@macro{\FV@Tmp}{#1}%
+ \FV@Break@Scan}
+\def\FV@Break@AfterTokenBreak#1{%
+ \@ifnextchar\FV@Space%
+ {\g@addto@macro{\FV@Tmp}{#1}\FV@Break@Scan}%
+ {\ifthenelse{\boolean{FV@BreakAfterGroup}}%
+ {\ifx\@let@token#1\relax
+ \g@addto@macro{\FV@Tmp}{#1}%
+ \let\FV@Break@Next\FV@Break@Scan
+ \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}%
+ \let\FV@Break@Next\FV@Break@Scan
+ \fi
+ \fi}%
+ {\g@addto@macro{\FV@Tmp}{#1\FancyVerbBreakAfterBreak}%
+ \let\FV@Break@Next\FV@Break@Scan}%
+ \FV@Break@Next}%
+}
+\def\FV@Break@AfterTokenBreak@Group#1{%
+ \g@addto@macro{\FV@Tmp}{{#1}}%
+ \ifstrempty{#1}%
+ {\let\FV@Break@Next\FV@Break@AfterTokenBreak@Group@i}%
+ {\let\FV@Break@Next\FV@Break@Scan}%
+ \FV@Break@Next}
+\def\FV@Break@AfterTokenBreak@Group@i{%
+ \@ifnextchar\FV@TmpToken%
+ {\FV@Break@Scan}%
+ {\g@addto@macro{\FV@Tmp}{\FancyVerbBreakAfterBreak}%
+ \FV@Break@Scan}}
\def\FV@makeLineNumber{%
\hss
\FancyVerbFormatBreakSymbolLeft{\FancyVerbBreakSymbolLeft}%
@@ -748,13 +935,14 @@
\ifthenelse{\boolean{FV@BreakAutoIndent}}%
{\hspace*{-\wd\FV@LineIndentBox}}%
{}%
- \strut#1\strut
+ \strut#1\nobreak\strut
\end{internallinenumbers*}
}%
\ifdefempty{\FancyVerbBreakSymbolRight}{}%
{\hbox to \FV@BreakSymbolIndentRight{\hfill}}%
}%
}
+\def\FancyVerbFormatText#1{#1}
\def\FV@ListProcessLine@Break#1{%
\hbox to \hsize{%
\kern\leftmargin
@@ -767,13 +955,15 @@
\advance\linewidth by -\FV@FrameSep
\advance\linewidth by -\FV@FrameRule
\fi
- \sbox{\FV@LineBox}{\FancyVerbFormatLine{#1}}%
+ \sbox{\FV@LineBox}{\FancyVerbFormatLine{\FancyVerbFormatText{#1}}}%
\ifdim\wd\FV@LineBox>\linewidth
\setcounter{FancyVerbLineBreakLast}{0}%
- \FV@SaveLineBox{#1}%
+ \FV@SaveLineBox{\FancyVerbFormatText{%
+ \FancyVerbBreakStart#1\FancyVerbBreakStop}}%
\ifdefempty{\FancyVerbBreakSymbolRight}{}{%
\let\FV@SetLineBreakLast\relax
- \FV@SaveLineBox{#1}}%
+ \FV@SaveLineBox{\FancyVerbFormatText{%
+ \FancyVerbBreakStart#1\FancyVerbBreakStop}}}%
\FV@LeftListNumber
\FV@LeftListFrame
\FancyVerbFormatLine{\usebox{\FV@LineBox}}%
@@ -783,11 +973,15 @@
\FV@LeftListNumber
\FV@LeftListFrame
\FancyVerbFormatLine{%
- \parbox[t]{\linewidth}{\noindent\strut#1\strut}}%
+ \parbox[t]{\linewidth}{\noindent\strut\FancyVerbFormatText{#1}\strut}}%
\FV@RightListFrame
\FV@RightListNumber
\fi}%
\hss}\baselineskip\z@\lineskip\z@}
+\ifcsname KV@FV@linenos\endcsname\else
+\define@booleankey{FV}{linenos}%
+ {\@nameuse{FV@Numbers@left}}{\@nameuse{FV@Numbers@none}}
+\fi
\fi
\newsavebox{\minted@bgbox}
\newenvironment{minted@colorbg}[1]{
@@ -801,7 +995,7 @@
\colorbox{\minted@bgcol}{\usebox{\minted@bgbox}}}
\newwrite\minted@code
\newcommand{\minted@savecode}[1]{
- \immediate\openout\minted@code\jobname.pyg\relax
+ \immediate\openout\minted@code\minted@jobname.pyg\relax
\immediate\write\minted@code{\expandafter\detokenize\expandafter{#1}}%
\immediate\closeout\minted@code}
\newcounter{minted@FancyVerbLineTemp}
@@ -823,10 +1017,12 @@
\newcommand{\minted@FVE@VerbatimOut}{%
\immediate\closeout\FV@OutFile\endgroup\@esphack
\setcounter{FancyVerbLine}{\value{minted@FancyVerbLineTemp}}}%
-\newcommand{\MintedPygmentize}{pygmentize}
-\newcommand{\minted@pygmentize}[2][\minted@outputdir\jobname.pyg]{%
+\ifcsname MintedPygmentize\endcsname\else
+ \newcommand{\MintedPygmentize}{pygmentize}
+\fi
+\newcommand{\minted@pygmentize}[2][\minted@outputdir\minted@jobname.pyg]{%
\ifthenelse{\equal{\minted@get@opt{autogobble}{false}}{true}}%
- {\def\minted@codefile{\minted@outputdir\jobname.pyg}}%
+ {\def\minted@codefile{\minted@outputdir\minted@jobname.pyg}}%
{\def\minted@codefile{#1}}%
\ifthenelse{\boolean{minted@isinline}}%
{\def\minted@optlistcl@inlines{%
@@ -836,7 +1032,7 @@
\def\minted@cmd{%
\ifminted@kpsewhich\ifwindows powershell\space\fi\fi
\MintedPygmentize\space -l #2
- -f latex -F tokenmerge
+ -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"
@@ -862,7 +1058,7 @@
{\edef\minted@hash{\pdf@filemdfivesum{#1}%
\pdf@mdfivesum{\minted@cmd}}}%
\else
- \immediate\openout\minted@code\jobname.mintedcmd\relax
+ \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}}{}%
@@ -872,18 +1068,18 @@
\def\minted@hashcmd{%
\detokenize{python -c "import hashlib;
hasher = hashlib.sha1();
- f = open(\"}\minted@outputdir\jobname.mintedcmd\detokenize{\", \"rb\");
+ 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\jobname.mintedmd5\detokenize{\", \"w\");
+ 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\jobname.mintedmd5}%
+ \minted@input{\minted@outputdir\minted@jobname.mintedmd5}%
\fi
\edef\minted@infile{\minted@cachedir/\minted@hash.pygtex}%
\IfFileExists{\minted@infile}{}{%
@@ -896,7 +1092,7 @@
f = open(\"}#1\detokenize{\", \"r\", encoding=\"}\minted@encoding\detokenize{\");
t = f.read();
f.close();
- f = open(\"}\minted@outputdir\jobname.pyg\detokenize{\", \"w\", encoding=\"}\minted@encoding\detokenize{\");
+ f = open(\"}\minted@outputdir\minted@jobname.pyg\detokenize{\", \"w\", encoding=\"}\minted@encoding\detokenize{\");
f.write(textwrap.dedent(t));
f.close();"}%
}%
@@ -914,7 +1110,7 @@
f = open(\"}#1\detokenize{\", \"r\", encoding=\"}\minted@encoding\detokenize{\");
t = f.read();
f.close();
- f = open(\"}\minted@outputdir\jobname.pyg\detokenize{\", \"w\", encoding=\"}\minted@encoding\detokenize{\");
+ f = open(\"}\minted@outputdir\minted@jobname.pyg\detokenize{\", \"w\", encoding=\"}\minted@encoding\detokenize{\");
f.write(textwrap.dedent(t));
f.close();"}%
}%
@@ -923,37 +1119,122 @@
\minted@inputpyg}%
}
\def\FV@SpaceMMode{ }
+\def\minted@BreakAfterPrep@extension{%
+ \ifcsname FV@BreakAfter@Token\@backslashchar\endcsname
+ \@namedef{FV@BreakAfter@Token\detokenize{\PYGZbs}}{}%
+ \fi
+ \ifcsname FV@BreakAfter@Token\FV@underscorechar\endcsname
+ \@namedef{FV@BreakAfter@Token\detokenize{\PYGZus}}{}%
+ \fi
+ \ifcsname FV@BreakAfter@Token\@charlb\endcsname
+ \@namedef{FV@BreakAfter@Token\detokenize{\PYGZob}}{}%
+ \fi
+ \ifcsname FV@BreakAfter@Token\@charrb\endcsname
+ \@namedef{FV@BreakAfter@Token\detokenize{\PYGZcb}}{}%
+ \fi
+ \ifcsname FV@BreakAfter@Token\detokenize{^}\endcsname
+ \@namedef{FV@BreakAfter@Token\detokenize{\PYGZca}}{}%
+ \fi
+ \ifcsname FV@BreakAfter@Token\FV@ampchar\endcsname
+ \@namedef{FV@BreakAfter@Token\detokenize{\PYGZam}}{}%
+ \fi
+ \ifcsname FV@BreakAfter@Token\detokenize{<}\endcsname
+ \@namedef{FV@BreakAfter@Token\detokenize{\PYGZlt}}{}%
+ \fi
+ \ifcsname FV@BreakAfter@Token\detokenize{>}\endcsname
+ \@namedef{FV@BreakAfter@Token\detokenize{\PYGZgt}}{}%
+ \fi
+ \ifcsname FV@BreakAfter@Token\FV@hashchar\endcsname
+ \@namedef{FV@BreakAfter@Token\detokenize{\PYGZsh}}{}%
+ \fi
+ \ifcsname FV@BreakAfter@Token\@percentchar\endcsname
+ \@namedef{FV@BreakAfter@Token\detokenize{\PYGZpc}}{}%
+ \fi
+ \ifcsname FV@BreakAfter@Token\FV@dollarchar\endcsname
+ \@namedef{FV@BreakAfter@Token\detokenize{\PYGZdl}}{}%
+ \fi
+ \ifcsname FV@BreakAfter@Token\detokenize{-}\endcsname
+ \@namedef{FV@BreakAfter@Token\detokenize{\PYGZhy}}{}%
+ \fi
+ \ifcsname FV@BreakAfter@Token\detokenize{'}\endcsname
+ \@namedef{FV@BreakAfter@Token\detokenize{\PYGZsq}}{}%
+ \fi
+ \ifcsname FV@BreakAfter@Token\detokenize{"}\endcsname
+ \@namedef{FV@BreakAfter@Token\detokenize{\PYGZdq}}{}%
+ \fi
+ \ifcsname FV@BreakAfter@Token\FV@tildechar\endcsname
+ \@namedef{FV@BreakAfter@Token\detokenize{\PYGZti}}{}%
+ \fi
+ \ifcsname FV@BreakAfter@Token\detokenize{@}\endcsname
+ \@namedef{FV@BreakAfter@Token\detokenize{\PYGZat}}{}%
+ \fi
+ \ifcsname FV@BreakAfter@Token\detokenize{[}\endcsname
+ \@namedef{FV@BreakAfter@Token\detokenize{\PYGZlb}}{}%
+ \fi
+ \ifcsname FV@BreakAfter@Token\detokenize{]}\endcsname
+ \@namedef{FV@BreakAfter@Token\detokenize{\PYGZrb}}{}%
+ \fi
+}
\newcommand{\minted@inputpyg}{%
+ \let\FV@BreakAfterPrep@orig\FV@BreakAfterPrep
+ \def\FV@BreakAfterPrep{%
+ \FV@BreakAfterPrep@orig\minted@BreakAfterPrep@extension}%
\everymath\expandafter{\the\everymath\let\FV@Space\FV@SpaceMMode}%
+ \ifthenelse{\equal{\minted@get@opt{breakbytokenanywhere}{false}}{true}}%
+ {\setkeys{minted@opt@cmd}{breakbytoken=true}}{}%
+ \ifthenelse{\boolean{FV@BreakAnywhere}}%
+ {\expandafter\let\expandafter\minted@orig@PYG@breakanywhere%
+ \csname PYG\minted@get@opt{style}{default}\endcsname
+ \expandafter\def\csname PYG\minted@get@opt{style}{default}\endcsname##1##2{%
+ \minted@orig@PYG@breakanywhere{##1}%
+ {\FancyVerbBreakStart##2\FancyVerbBreakStop}}}{}%
+ \ifx\FV@BreakAfter\@empty
+ \else
+ \expandafter\let\expandafter\minted@orig@PYG@breakafter%
+ \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}%
+ {\FancyVerbBreakStart##2\FancyVerbBreakStop}}%
+ \fi
\ifthenelse{\boolean{minted@isinline}}%
{\ifthenelse{\equal{\minted@get@opt{breaklines}{false}}{true}}%
{\let\FV@BeginVBox\relax
\let\FV@EndVBox\relax
\def\FV@BProcessLine##1{\FancyVerbFormatLine{##1}}%
\ifthenelse{\equal{\minted@get@opt{breakbytoken}{false}}{true}}%
- {\expandafter\let\expandafter\minted@orig@PYG%
- \csname PYG\minted@get@opt{style}{default}\endcsname
- \expandafter\def\csname PYG\minted@get@opt{style}{default}\endcsname##1##2{%
- \allowbreak{}\hbox{\minted@orig@PYG{##1}{##2}}}%
+ {\minted@inputpyg@breakbytoken
\minted@inputpyg@inline}%
{\minted@inputpyg@inline}}%
{\minted@inputpyg@inline}}%
{\ifthenelse{\equal{\minted@get@opt{breaklines}{false}}{true}}%
{\ifthenelse{\equal{\minted@get@opt{breakbytoken}{false}}{true}}%
- {\expandafter\let\expandafter\minted@orig@PYG%
- \csname PYG\minted@get@opt{style}{default}\endcsname
- \expandafter\def\csname PYG\minted@get@opt{style}{default}\endcsname##1##2{%
- \allowbreak{}\hbox{\minted@orig@PYG{##1}{##2}}}%
+ {\minted@inputpyg@breakbytoken
\minted@inputpyg@block}%
{\minted@inputpyg@block}}%
{\minted@inputpyg@block}}%
}
+\def\minted@inputpyg@breakbytoken{%
+ \expandafter\let\expandafter\minted@orig@PYG@breakbytoken%
+ \csname PYG\minted@get@opt{style}{default}\endcsname
+ \ifthenelse{\equal{\minted@get@opt{breakbytokenanywhere}{false}}{true}}%
+ {\let\minted@orig@allowbreak\allowbreak
+ \def\allowbreak{\let\allowbreak\minted@orig@allowbreak}%
+ \expandafter\def\csname PYG\minted@get@opt{style}{default}\endcsname##1##2{%
+ \allowbreak{}\leavevmode\hbox{\minted@orig@PYG@breakbytoken{##1}{##2}}}}%
+ {\expandafter\def\csname PYG\minted@get@opt{style}{default}\endcsname##1##2{%
+ \leavevmode\hbox{\minted@orig@PYG@breakbytoken{##1}{##2}}}}%
+}
\def\minted@inputpyg@inline{%
+ \expandafter\let\expandafter\PYG%
+ \csname PYG\minted@get@opt{style}{default}\endcsname
\ifthenelse{\equal{\minted@get@opt{bgcolor}{}}{}}%
{\minted@input{\minted@outputdir\minted@infile}}%
- {\colorbox{\minted@get@opt{bgcolor}{}}{\minted@input{\minted@outputdir\minted@infile}}}%
+ {\colorbox{\minted@get@opt{bgcolor}{}}{%
+ \minted@input{\minted@outputdir\minted@infile}}}%
}
\def\minted@inputpyg@block{%
+ \expandafter\let\expandafter\PYG%
+ \csname PYG\minted@get@opt{style}{default}\endcsname
\ifthenelse{\equal{\minted@get@opt{bgcolor}{}}{}}%
{\minted@input{\minted@outputdir\minted@infile}}%
{\begin{minted@colorbg}{\minted@get@opt{bgcolor}{}}%
@@ -992,7 +1273,7 @@
\gdef\minted@defwhitespace@retok{\def {\noexpand\FV@Space}\def^^I{\noexpand\FV@Tab}}%
\endgroup
\newcommand{\minted@writecmdcode}[1]{%
- \immediate\openout\minted@code\jobname.pyg\relax
+ \immediate\openout\minted@code\minted@jobname.pyg\relax
\immediate\write\minted@code{\detokenize{#1}}%
\immediate\closeout\minted@code}
\newrobustcmd{\mintinline}[2][]{%
@@ -1116,7 +1397,7 @@
\minted@configlang{#2}%
\setkeys{minted@opt@cmd}{#1}%
\minted@fvset
- \begin{VerbatimOut}[codes={\catcode`\^^I=12}]{\jobname.pyg}}%
+ \begin{VerbatimOut}[codes={\catcode`\^^I=12}]{\minted@jobname.pyg}}%
{\end{VerbatimOut}%
\minted@langlinenoson
\minted@pygmentize{\minted@lang}%
@@ -1125,7 +1406,7 @@
{\newcommand{\inputminted}[3][]{%
\begingroup
\minted@configlang{#2}%
- \setkeys{minted@optcmd}{#1}%
+ \setkeys{minted@opt@cmd}{#1}%
\minted@fvset
\VerbatimInput{#3}%
\endgroup}}%
@@ -1196,7 +1477,12 @@
{Pass the -shell-escape flag to LaTeX. Refer to the minted.sty
documentation for more information.}%
\fi
- \TestAppExists{pygmentize}
+ \setminted{style=default}%
+ }%
+}
+\AtEndPreamble{%
+ \ifthenelse{\boolean{minted@draft}}{}{%
+ \TestAppExists{pygmentize}%
\ifAppExists\else
\PackageError{minted}%
{You must have `pygmentize' installed
@@ -1204,17 +1490,16 @@
{Refer to the installation instructions in the minted
documentation for more information.}%
\fi
- \setminted{style=default}%
}%
}
\AtEndDocument{
\ifx\XeTeXinterchartoks\minted@undefined
\else
- \DeleteFile[\minted@outputdir]{\jobname.mintedcmd}%
- \DeleteFile[\minted@outputdir]{\jobname.mintedmd5}%
+ \DeleteFile[\minted@outputdir]{\minted@jobname.mintedcmd}%
+ \DeleteFile[\minted@outputdir]{\minted@jobname.mintedmd5}%
\fi
- \DeleteFile[\minted@outputdir]{\jobname.pyg}%
- \DeleteFile[\minted@outputdir]{\jobname.out.pyg}%
+ \DeleteFile[\minted@outputdir]{\minted@jobname.pyg}%
+ \DeleteFile[\minted@outputdir]{\minted@jobname.out.pyg}%
}
\endinput
%%