summaryrefslogtreecommitdiff
path: root/Master/texmf-dist
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2016-06-09 22:52:48 +0000
committerKarl Berry <karl@freefriends.org>2016-06-09 22:52:48 +0000
commit630a0032b5287429446b8ed9f02af719e9aa563e (patch)
tree94f3804bded9ec345c473a6fc00d17bd8f317eb2 /Master/texmf-dist
parent0da7899076450108cd78b6c32594806ad926873a (diff)
minted (8jun16)
git-svn-id: svn://tug.org/texlive/trunk@41329 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist')
-rw-r--r--Master/texmf-dist/doc/latex/minted/README2
-rw-r--r--Master/texmf-dist/doc/latex/minted/minted.pdfbin675082 -> 715677 bytes
-rw-r--r--Master/texmf-dist/source/latex/minted/minted.dtx804
-rw-r--r--Master/texmf-dist/source/latex/minted/minted.ins2
-rw-r--r--Master/texmf-dist/tex/latex/minted/minted.sty584
-rw-r--r--Master/texmf-dist/tex/latex/minted/minted1.sty2
6 files changed, 1056 insertions, 338 deletions
diff --git a/Master/texmf-dist/doc/latex/minted/README b/Master/texmf-dist/doc/latex/minted/README
index 9364f4ed335..2aeb42f497d 100644
--- a/Master/texmf-dist/doc/latex/minted/README
+++ b/Master/texmf-dist/doc/latex/minted/README
@@ -1,4 +1,4 @@
-minted — highlighted source code for LaTeX
+minted - highlighted source code for LaTeX
minted is a package that facilitates expressive syntax highlighting in LaTeX
using the Pygments library. The package also provides options to customize
diff --git a/Master/texmf-dist/doc/latex/minted/minted.pdf b/Master/texmf-dist/doc/latex/minted/minted.pdf
index 15ed8369a7f..fbc05ca2385 100644
--- a/Master/texmf-dist/doc/latex/minted/minted.pdf
+++ b/Master/texmf-dist/doc/latex/minted/minted.pdf
Binary files differ
diff --git a/Master/texmf-dist/source/latex/minted/minted.dtx b/Master/texmf-dist/source/latex/minted/minted.dtx
index e0db8bd3bd5..48c45077068 100644
--- a/Master/texmf-dist/source/latex/minted/minted.dtx
+++ b/Master/texmf-dist/source/latex/minted/minted.dtx
@@ -1,6 +1,6 @@
% \iffalse meta-comment
%
-% Copyright (C) 2013-2015 by Geoffrey M. Poore <gpoore@gmail.com>
+% Copyright (C) 2013-2016 by Geoffrey M. Poore <gpoore@gmail.com>
% Copyright (C) 2010-2011 by Konrad Rudolph <konrad_rudolph@madrat.net>
% ---------------------------------------------------------------------------
% This work may be distributed and/or modified under the
@@ -31,7 +31,7 @@
%<package>\NeedsTeXFormat{LaTeX2e}
%<package>\ProvidesPackage{minted}
%<*package>
- [2015/09/09 v2.1 Yet another Pygments shim for LaTeX]
+ [2016/06/08 v2.2 Yet another Pygments shim for LaTeX]
%</package>
%<*driver>
\documentclass{ltxdoc}
@@ -40,7 +40,6 @@
%\DisableCrossrefs
%\RecordChanges
%\OnlyDescription
-\usepackage{fixltx2e}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
@@ -171,7 +170,7 @@
%</driver>
% \fi
%
-% \CheckSum{3283}
+% \CheckSum{3835}
%
% \CharacterTable
% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
@@ -191,6 +190,24 @@
%
%
%
+%
+% \begin{changelog}{v2.2}{2016/06/08}
+% \item All uses of \texttt{\string\ShellEscape} (\texttt{\string\write18}) no longer wrap file names and paths with double quotes. This allows a cache directory to be specified relative to a user's home directory, for example, \texttt{\string~/minted\_cache}. \texttt{cachedir} and \texttt{outputdir} paths containing spaces will now require explicit quoting of the parts of the paths that contain spaces, since \texttt{minted} no longer supplies quoting. See the updated documentation for examples (\#89).
+% \item Added \texttt{breakbefore}, \texttt{breakbeforegroup}, \texttt{breakbeforesymbolpre}, and \texttt{breakbeforesymbolpost}. These parallel \texttt{breakafter*}. It is possible to use \texttt{breakbefore} and \texttt{breakafter} for the same character, so long as \texttt{breakbeforegroup} and \texttt{breakaftergroup} have the same setting (\#117).
+% \item Added package options \texttt{finalizecache} and \texttt{frozencache}. These allow the cache to be prepared for (\texttt{finalizecache}) and then used (\texttt{frozencache}) in an environment in which \texttt{-shell-escape}, Python, and/or Pygments are not available. Note that this only works if \texttt{minted} content does not need to be modified, and if no settings that depend on Pygments or Python need to be changed (\#113).
+% \item Style names containing hyphens and underscores (\texttt{paraiso-light}, \texttt{paraiso-dark}, \texttt{algol\_nu}) now work (\#111).
+% \item The \texttt{shellesc} package is now loaded, when available, for compatibility with \texttt{luatex} 0.87+ (TeX Live 2016+, etc.). \texttt{\string\ShellEscape} is now used everywhere instead of \texttt{\string\immediate\string\write18}. If \texttt{shellesc} is not available, then a \texttt{\string\ShellEscape} macro is created. When \texttt{shellesc} is loaded, there is a check for versions before v0.01c to patch a bug in v0.01b (present in TeX Live 2015) (\#112).
+% \item The \texttt{bgcolor} option now uses the \texttt{snugshade*} environment from the \texttt{framed} package, so \texttt{bgcolor} is now compatible with page breaks. When \texttt{bgcolor} is in use, immediately preceding text will no longer push the \texttt{minted} environment into the margin, and there is now adequate spacing from surrounding text (\#121).
+% \item Added missing support for \texttt{fancyvrb}'s \texttt{labelposition} (\#102).
+% \item Improved fix for TikZ externalization, thanks to Patrick Vogt (\#73).
+% \item Fixed \texttt{breakautoindent}; it was disabled in version 2.1 due to a bug in \texttt{breakanywhere}.
+% \item Properly fixed handling of \texttt{\string\MintedPygmentize} (\#62).
+% \item Added note on incompatibility of \texttt{breaklines} and \texttt{obeytabs} options. Trying to use these together will now result in a package error (\#99). Added note on issues with \texttt{obeytabs} and multiline comments (\#88). Due to the various \texttt{obeytabs} issues, the docs now discourage using \texttt{obeytabs}.
+% \item Added note to FAQ on \texttt{fancybox} and \texttt{fancyvrb} conflict (\#87).
+% \item Added note to docs on the need for \texttt{\string\VerbatimEnvironment} in environment definitions based on \texttt{minted} environments.
+% \end{changelog}
+%
+%
% \begin{changelog}{v2.1}{2015/09/09}
% \item Changing the highlighting style now no longer involves re-highlighing code. Style may be changed with almost no overhead.
% \item Improved control of automatic line breaks. New option \texttt{breakanywhere} allows line breaks anywhere when \texttt{breaklines=true}. The pre-break and post-break symbols for these types of breaks may be set with \texttt{breakanywheresymbolpre} and \texttt{breakanywheresymbolpost} (\#79). New option \texttt{breakafter} allows specifying characters after which line breaks are allowed. Breaks between adjacent, identical characters may be controlled with \texttt{breakaftergroup}. The pre-break and post-break symbols for these types of breaks may be set with \texttt{breakaftersymbolpre} and \texttt{breakaftersymbolpost}.
@@ -449,6 +466,8 @@
% \item xstring
% \item xcolor
% \item lineno
+% \item framed
+% \item shellesc (for luatex 0.87+)
% \end{list}
% \endgroup
% \end{multicols}
@@ -715,7 +734,33 @@
% \DescribeMacro{cachedir=\meta{directory} (def:~\_minted-\meta{jobname})}
% This allows the directory in which cached files are stored to be specified. Paths should use forward spaces, even under Windows.
%
-% Note that this directory is relative to the |outputdir|, if an |outputdir| is specified.
+% Special characters must be escaped. For example, |cachedir=~/mintedcache| would not work because the tilde |~| would be converted into the \LaTeX\ commands for a non-breaking space, rather than being treated literally. Instead, use |\string~/mintedcache|, |\detokenize{~/mintedcache}|, or an equivalent solution.
+%
+% Paths may contain spaces, but only if the entire \meta{directory} is wrapped in curly braces |{}|, and only if the spaces are quoted. For example,
+%\begin{Verbatim}
+%cachedir = {\detokenize{~/"minted cache"/"with spaces"}}
+%\end{Verbatim}
+%
+% Note that the cache directory is relative to the |outputdir|, if an |outputdir| is specified.
+%
+%
+% \DescribeMacro{finalizecache=\meta{boolean} (default: false)}
+% In some cases, it may be desirable to use \pkg{minted} in an environment in which |-shell-escape| is not allowed. A document might be submitted to a publisher or preprint server or used with an online service that does not support |-shell-escape|. This is possible as long as \pkg{minted} content does not need to be modified.
+%
+% Compiling with the |finalizecache| option prepares the cache for use in an environment without |-shell-escape|.\footnote{Ordinarily, cache files are named using an MD5 hash of highlighting settings and highlighted text. \texttt{finalizecache} renames cache files using a \texttt{listing<number>.pygtex} scheme. This makes it simpler to match up document content and cache files, and is also necessary for the \texttt{XeTeX} engine since it lacks the built-in MD5 capabilities that \texttt{pdfTeX} and \texttt{LuaTeX} have.} Once this has been done, the |finalizecache| option may be swapped for the |frozencache| option, which will then use the frozen (static) cache in the future, without needing |-shell-escape|.
+%
+%
+% \DescribeMacro{frozencache=\meta{boolean} (default: false)}
+% Use a frozen (static) cache created with the |finalizecache| option. When |frozencache| is on, |-shell-escape| is not needed, and Python and Pygments are not required. In addition, any external files accessed through |\inputminted| are no longer necessary.
+%
+% \textbf{This option must be used with care. A document \emph{must} be in final form, as far as \pkg{minted} is concerned, \emph{before} \texttt{frozencache} is turned on, and the document \emph{must} have been compiled with \texttt{finalizecache}. When this option is on, \pkg{minted} content cannot be modified, except by editing the cache files directly. Changing any \pkg{minted} settings that require Pygments or Python is not possible. If \pkg{minted} content is incorrectly modified after \texttt{frozencache} is turned on, \pkg{minted} \emph{cannot} detect the modification.}
+%
+% If you are using |frozencache|, and want to verify that \pkg{minted} settings or content have not been modified in an invalid fashion, you can test the cache using the following procedure.
+% \begin{enumerate}
+% \item Obtain a copy of the cache used with |frozencache|.
+% \item Compile the document in an environment that supports |-shell-escape|, with |finalizecache=true| and |frozencache=false|. This essentially regenerates the frozen (static) cache.
+% \item Compare the original cache with the newly generated cache. Under Linux and OS X, you could use |diff|; under Windows, you probably want |fc|. If \pkg{minted} content and settings have not been modified in an invalid fashion, all files will be identical (assuming that compatible versions of Pygments are used for both caches).
+% \end{enumerate}
%
%
% \DescribeMacro{draft=\meta{boolean} (default: false)}
@@ -777,9 +822,9 @@
%
%
% \DescribeMacro{outputdir=\meta{directory} (default: \meta{none})}
-% The |-output-directory| and |-aux-directory| (MiKTeX) command-line options for \LaTeX\ causes problems for \pkg{minted}, because the \pkg{minted} temporary files are saved in |<outputdir>|, but \pkg{minted} still looks for them in the document root directory. There is no way to access the value of the command-line option so that \pkg{minted} can automatically look in the right place. But it is possible to allow the output directory to be specified manually as a package option.
+% The |-output-directory| and |-aux-directory| (MiKTeX) command-line options for \LaTeX\ cause problems for \pkg{minted}, because the \pkg{minted} temporary files are saved in |<outputdir>|, but \pkg{minted} still looks for them in the document root directory. There is no way to access the value of the command-line option so that \pkg{minted} can automatically look in the right place. But it is possible to allow the output directory to be specified manually as a package option.
%
-% The output directory should be specified using an absolute path or a path relative to the document root directory. Paths should use forward spaces, even under Windows. Paths that include spaces are not allowed.
+% The output directory should be specified using an absolute path or a path relative to the document root directory. Paths should use forward spaces, even under Windows. Special characters must be escaped, while spaces require quoting and need the entire \meta{directory} to be wrapped in curly braces |{}|. See |cachedir| above for examples of escaping and quoting.
%
%
% \DescribeMacro{section}
@@ -875,6 +920,8 @@
% \item[breakafter (string) (+\meta{none}+)]
% Break lines after specified characters, not just at spaces, when \texttt{breaklines=true}. For example, \texttt{breakafter=-/} would allow breaks after any hyphens or slashes. Special characters given to \texttt{breakafter} should be backslash-escaped (usually \texttt{\hashchar}, \texttt{\{}, \texttt{\}}, \texttt{\%}, \texttt{[}, \texttt{]}; the backslash \texttt{\textbackslash} may be obtained via \texttt{\textbackslash\textbackslash}).
%
+% For an alternative, see \texttt{breakbefore}. When \texttt{breakbefore} and \texttt{breakafter} are used for the same character, \texttt{breakbeforegroup} and \texttt{breakaftergroup} must both have the same setting.
+%
% \begin{longexample}
% \begin{minted}[breaklines, breakafter=d]{python}
% some_string = 'SomeTextThatGoesOnAndOnForSoLongThatItCouldNeverFitOnOneLine'
@@ -882,7 +929,7 @@
% \end{longexample}
%
% \item[breakaftergroup] (boolean) (+true+)
-% When \texttt{breakafter} is used, group all adjacent identical characters together, and only allow a break after the last character.
+% When \texttt{breakafter} is used, group all adjacent identical characters together, and only allow a break after the last character. When \texttt{breakbefore} and \texttt{breakafter} are used for the same character, \texttt{breakbeforegroup} and \texttt{breakaftergroup} must both have the same setting.
%
% \item[breakaftersymbolpre (string) (+\string\,\string\footnotesize\string\ensuremath\{\_\string\rfloor\}, \,\footnotesize\ensuremath{_\rfloor}+)]
% The symbol inserted pre-break for breaks inserted by \texttt{breakafter}.
@@ -907,6 +954,27 @@
%
% \item[breakautoindent (boolean) (+true+)]
% When a line is broken, automatically indent the continuation lines to the indentation level of the first line. When \texttt{breakautoindent} and \texttt{breakindent} are used together, the indentations add. This indentation is combined with \texttt{breaksymbolindentleft} to give the total actual left indentation. Does not apply to \texttt{\string\mintinline}.
+%
+% \item[breakbefore (string) (+\meta{none}+)]
+% Break lines before specified characters, not just at spaces, when \texttt{breaklines=true}. For example, \texttt{breakbefore=A} would allow breaks before capital A's. Special characters given to \texttt{breakbefore} should be backslash-escaped (usually \texttt{\hashchar}, \texttt{\{}, \texttt{\}}, \texttt{\%}, \texttt{[}, \texttt{]}; the backslash \texttt{\textbackslash} may be obtained via \texttt{\textbackslash\textbackslash}).
+%
+% For an alternative, see \texttt{breakafter}. When \texttt{breakbefore} and \texttt{breakafter} are used for the same character, \texttt{breakbeforegroup} and \texttt{breakaftergroup} must both have the same setting.
+%
+% \begin{longexample}
+% \begin{minted}[breaklines, breakbefore=A]{python}
+% some_string = 'SomeTextThatGoesOnAndOnForSoLongThatItCouldNeverFitOnOneLine'
+% \end{minted}
+% \end{longexample}
+%
+% \item[breakbeforegroup] (boolean) (+true+)
+% When \texttt{breakbefore} is used, group all adjacent identical characters together, and only allow a break before the first character. When \texttt{breakbefore} and \texttt{breakafter} are used for the same character, \texttt{breakbeforegroup} and \texttt{breakaftergroup} must both have the same setting.
+%
+% \item[breakbeforesymbolpre (string) (+\string\,\string\footnotesize\string\ensuremath\{\_\string\rfloor\}, \,\footnotesize\ensuremath{_\rfloor}+)]
+% The symbol inserted pre-break for breaks inserted by \texttt{breakbefore}.
+%
+% \item[breakbeforesymbolpost (string) (+\meta{none}+)]
+% The symbol inserted post-break for breaks inserted by \texttt{breakbefore}.
+%
% \item[breakbytoken (boolean) (+false+)]
% Only break lines at locations that are not within tokens; prevent tokens from being split by line breaks. By default, \texttt{breaklines} causes line breaking at the space nearest the margin. While this minimizes the number of line breaks that are necessary, it can be inconvenient if a break occurs in the middle of a string or similar token.
%
@@ -917,7 +985,11 @@
% \item[breakindent (dimension) (+0pt+)]
% When a line is broken, indent the continuation lines by this amount. When \texttt{breakautoindent} and \texttt{breakindent} are used together, the indentations add. This indentation is combined with \texttt{breaksymbolindentleft} to give the total actual left indentation. Does not apply to \texttt{\string\mintinline}.
% \item[breaklines (boolean) (+false+)]
-% Automatically break long lines in \texttt{minted} environments and \texttt{\string\mint} commands, and wrap longer lines in \texttt{\string\mintinline}. By default, automatic breaks occur at space characters. Use \texttt{breakanywhere} to enable breaking anywhere; use \texttt{breakbytoken}, \texttt{breakbytokenanywhere}, and \texttt{breakafter} for more fine-tuned breaking. Using \texttt{escapeinside} to escape to \LaTeX\ and then insert a manual break is also an option. For example, use \texttt{escapeinside=||}, and then insert \texttt{|\textbackslash\textbackslash|} at the appropriate point. (Note that \texttt{escapeinside} does not work within strings.)
+% Automatically break long lines in \texttt{minted} environments and \texttt{\string\mint} commands, and wrap longer lines in \texttt{\string\mintinline}.
+%
+% \textbf{This is not compatible with the option \texttt{obeytabs}.} Additional information about the incompatibility is on \href{https://github.com/gpoore/minted/issues/99}{GitHub}.
+%
+% By default, automatic breaks occur at space characters. Use \texttt{breakanywhere} to enable breaking anywhere; use \texttt{breakbytoken}, \texttt{breakbytokenanywhere}, and \texttt{breakafter} for more fine-tuned breaking. Using \texttt{escapeinside} to escape to \LaTeX\ and then insert a manual break is also an option. For example, use \texttt{escapeinside=||}, and then insert \texttt{|\textbackslash\textbackslash|} at the appropriate point. (Note that \texttt{escapeinside} does not work within strings.)
%
% \begin{example}
% ...text.
@@ -998,9 +1070,9 @@
% The separation between the \texttt{breaksymbolright} and the adjacent code.
%
% \item[bgcolor (string) (\meta{none})]
-% Background color of the listing.
-% Notice that the value of this option must \emph{not} be a color command. Instead, it must be a color
-% \emph{name}, given as a string, of a previously-defined color:
+% Background color of the listing. Be aware that this option has several limitations (described below); see ``Framing alternatives'' below for more powerful alternatives.
+%
+% The value of this option must \emph{not} be a color command. Instead, it must be a color \emph{name}, given as a string, of a previously-defined color:
%
% \begin{example}
% \definecolor{bg}{rgb}{0.95,0.95,0.95}
@@ -1011,11 +1083,15 @@
% \end{minted}
% \end{example}
%
-% This option puts \texttt{minted} environments and \texttt{\string\mint} commands in a minipage with a colored background. It puts \texttt{\string\mintinline} inside a \texttt{\string\colorbox}. If you want to use \texttt{\string\setminted} to set background colors, and only want background colors on \texttt{minted} and \texttt{\string\mint}, you may use \texttt{\string\setmintedinline\{bgcolor=\{\}\}} to turn off the coloring for inline commands.
+% This option puts \texttt{minted} environments and \texttt{\string\mint} commands in a \texttt{snugshade*} environment from the \pkg{framed} package, which supports breaks across pages. (Prior to \pkg{minted} 2.2, a \texttt{minipage} was used, which prevented page breaks and gave undesirable spacing from surrounding text.) Be aware that if \texttt{bgcolor} is used with \texttt{breaklines=true}, and a line break occurs just before a page break, then text may extend below the colored background in some instances. It is best to use a more advanced framing package in those cases; see ``Framing alternatives'' below.
+%
+% This option puts \texttt{\string\mintinline} inside a \texttt{\string\colorbox}, which \textbf{does not allow line breaks}. If you want to use \texttt{\string\setminted} to set background colors, and only want background colors on \texttt{minted} and \texttt{\string\mint}, you may use \texttt{\string\setmintedinline\{bgcolor=\{\}\}} to turn off the coloring for inline commands.
+%
+% ~
%
-% \textbf{This option will prevent \texttt{breaklines} from working with \texttt{\string\mintinline}.} A \texttt{\string\colorbox} cannot break across lines.
+% \textbf{Framing alternatives}
%
-% \textbf{This option will prevent environments from breaking across pages.} If you want support for page breaks and advanced options, you should consider a framing package such as \pkg{framed}, \pkg{mdframed}, or \pkg{tcolorbox}. It is easy to add framing to \pkg{minted} commands and environments using the \pkg{etoolbox} package. For example, using \pkg{mdframed}:
+% If you want more reliable and advanced options for background colors and framing, you should consider a more advanced framing package such as \pkg{mdframed} or \pkg{tcolorbox}. It is easy to add framing to \pkg{minted} commands and environments using the \pkg{etoolbox} package, which is automatically loaded by \pkg{minted}. For example, using \pkg{mdframed}:
%\begin{Verbatim}
%\BeforeBeginEnvironment{minted}{\begin{mdframed}}
%\AfterEndEnvironment{minted}{\end{mdframed}}
@@ -1024,7 +1100,16 @@
%\begin{Verbatim}
%\surroundwithmdframed{minted}
%\end{Verbatim}
-% \pkg{tcolorbox} even provides a built-in framing environment with \pkg{minted} support.
+% \pkg{tcolorbox} even provides a built-in framing environment with \pkg{minted} support. Simply use \texttt{\string\tcbuselibrary\{minted\}} in the preamble, and then put code within a \texttt{tcblisting} environment:
+%\begin{Verbatim}
+%\begin{tcblisting}{<tcb options>,
+% minted language=<language>,
+% minted style=<style>,
+% minted options={<option list>} }
+%<code>
+%\end{tcblisting}
+%\end{Verbatim}
+% \pkg{tcolorbox} provides other commands and environments for fine-tuning listing appearance and for working with external code files.
%
% \item[codetagify (list of strings) (highlight +XXX+, +TODO+, +BUG+, and +NOTE+)]
% Highlight special code tags in comments and docstrings.
@@ -1113,7 +1198,15 @@
% \item[numbersep (dimension) (+12pt+)]
% Gap between numbers and start of line.
% \item[obeytabs (boolean) (+false+)]
+% \textbf{\textcolor{red}{Due to the many issues with \pkg{fancyvrb}'s implementation of \texttt{obeytabs}, this option should be avoided if possible.}}
+%
% Treat tabs as tabs instead of converting them to spaces.
+%
+% \textbf{This is not compatible with the option \texttt{breaklines}.}
+%
+% \textbf{This will cause errors with tabbed indentation inside multiline comments.}
+%
+% There is a \href{https://github.com/gpoore/minted/issues/99}{GitHub issue} with additional technical details.
% \item[outencoding (string) (system-specific)]
% Sets the file encoding that \app{Pygments} uses for highlighted output. Overrides any encoding previously set via +encoding+.
% \item[python3 (boolean) (+false+)] \appliesto{PythonConsoleLexer}
@@ -1198,6 +1291,12 @@
% If this name clashes with another environment or if you want to choose an own name for another reason, you may
% do so by specifying it as the first argument: \cmd\newminted\oarg{environment name}\marg{language}\marg{options}.
%
+% Like normal \pkg{minted} environments, environments created with |\newminted| may be used within other environment definitions. Since the \pkg{minted} environments use \pkg{fancyvrb} internally, any environment based on them must include the \pkg{fancyvrb} command |\VerbatimEnvironment|. This allows \pkg{fancyvrb} to determine the name of the environment that is being defined, and correctly find its end. It is best to include this command at the beginning of the definition. For example,
+%\begin{Verbatim}
+%\newminted{cpp}{gobble=2,linenos}
+%\newenvironment{env}{\VerbatimEnvironment\begin{cppcode}}{\end{cppcode}}
+%\end{Verbatim}
+%
% \DescribeMacro{\newmint}
% The above macro only defines shortcuts for the |minted| environment.
% The main reason is that the short command form |\mint| often needs different options---at the very least, it
@@ -1236,7 +1335,9 @@
% In some cases, \pkg{minted} may not give the desired result due to other document settings that it cannot control. Common issues are described below, with workarounds or solutions. You may also wish to search \href{http://tex.stackexchange.com/}{tex.stackexchange.com} or ask a question there, if you are working with \pkg{minted} in a non-typical context.
%
% \begin{itemize}
+% \item \textbf{I receive a ``Font Warning: Some font shapes were not available'' message, or bold or italic seem to be missing.} This due to a limitation in the font that is currently in use for typesetting code. In some cases, the default font shapes that \LaTeX\ substitutes are perfectly adequate, and the warning may be ignored. In other cases, the font substitutions may not clearly indicate bold or italic text, and you will want to switch to a different font. See The \LaTeX\ Font Catalogue's section on \href{http://www.tug.dk/FontCatalogue/typewriterfonts.html}{Typewriter Fonts} for alternatives. If you like the default \LaTeX\ fonts, the \pkg{lmodern} package is a good place to start. The \pkg{beramono} and \pkg{courier} packages may also be good options.
% \item \textbf{I receive a ``Too many open files'' error under OS X when using caching.} See the note on OS X under Section~\ref{sec:basic:preliminary}.
+% \item \textbf{Weird things happen when I use the \pkg{fancybox} package.} \pkg{fancybox} conflicts with \pkg{fancyvrb}, which \pkg{minted} uses internally. When using \pkg{fancybox}, make sure that it is loaded before \pkg{minted} (or before \pkg{fancyvrb}, if \pkg{fancyvrb} is not loaded by \pkg{minted}).
% \item \textbf{When I use \pkg{minted} with KOMA-Script document classes, I get warnings about \texttt{\string\float@addtolists}.} \pkg{minted} uses the \pkg{float} package to produce floated listings, but this conflicts with the way KOMA-Script does floats. Load the package \pkg{scrhack} to resolve the conflict. Or use \pkg{minted}'s |newfloat| package option.
% \item \textbf{Tilde characters \texttt{\string~} are raised, almost like superscripts.}
% This is a font issue. You need a different font encoding, possibly with a different font. Try |\usepackage[T1]{fontenc}|, perhaps with |\usepackage{lmodern}|, or something similar.
@@ -1306,6 +1407,7 @@
%
% \item \textbf{I want extended characters in frame labels, but am getting errors.} This can happen with \pkg{minted} <2.0 and Python 2.7, due to a \href{https://bitbucket.org/birkenfeld/pygments-main/issue/801/python-2-fails-to-detect-terminal-encoding}{terminal encoding issue with Pygments}. It should work with any version of Python with \pkg{minted} 2.0+, which processes labels internally and does not send them to Python.
% \item \textbf{\texttt{minted} environments have extra vertical space inside \texttt{tabular}.} It is possible to \href{https://github.com/gpoore/minted/issues/82}{create a custom environment} that eliminates the extra space. However, a general solution that behaves as expected in the presence of adjacent text remains to be found.
+% \item \textbf{I'm receiving a warning from \texttt{lineno.sty} that ``Command \texttt{\string\@parboxrestore} has changed.''} This can happen when \pkg{minted} is loaded after \pkg{csquotes}. Try loading \pkg{minted} first. If you receive this message when you are not using \pkg{csquotes}, you may want to experiment with the order of loading packages and might also open an issue.
% \end{itemize}
%
%
@@ -1315,7 +1417,7 @@
%
% Konrad Rudolph: Special thanks to Philipp Stephani and the rest of the guys from \texttt{comp.text.tex} and \texttt{tex.stackexchange.com}.
%
-% Geoffrey Poore: Thanks to Marco Daniel for the code on \url{tex.stackexchange.com} that inspired automatic line breaking.
+% Geoffrey Poore: Thanks to Marco Daniel for the code on \url{tex.stackexchange.com} that inspired automatic line breaking. Thanks to Patrick Vogt for improving TikZ externalization compatibility.
%
% \PrintChangelog
%
@@ -1343,6 +1445,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 }}
% \end{macrocode}
%
% Make sure that either |color| or |xcolor| is loaded by the beginning of the document.
@@ -1387,7 +1496,7 @@
%
%
% \begin{macro}{\minted@jobname}
-% At various points, temporary files and directories will need to be named after the main |.tex| file. The typical way to do this is to use |\jobname|. However, if the file name contains spaces, then |\jobname| will contain the name wrapped in quotes (older versions of MiKTeX replace spaces with asterisks instead, and \texttt{XeTeX} apparently \href{http://tex.stackexchange.com/a/93829/10742}{allows double quotes within file names}, in which case names are wrapped in single quotes}). While that is perfectly fine for working with \LaTeX\ internally, it causes problems with |\write18|, since quotes will end up in unwanted locations in shell commands. It would be possible to strip the wrapping quotation marks when they are present, and maintain any spaces in the file name. But it is simplest to create a ``sanitized'' version of |\jobname| in which spaces and asterisks are replaced by underscores, and double quotes are stripped.
+% At various points, temporary files and directories will need to be named after the main |.tex| file. The typical way to do this is to use |\jobname|. However, if the file name contains spaces, then |\jobname| will contain the name wrapped in quotes (older versions of MiKTeX replace spaces with asterisks instead, and \texttt{XeTeX} apparently \href{http://tex.stackexchange.com/a/93829/10742}{allows double quotes within file names}, in which case names are wrapped in single quotes). While that is perfectly fine for working with \LaTeX\ internally, it causes problems with |\write18|, since quotes will end up in unwanted locations in shell commands. It would be possible to strip the wrapping quotation marks when they are present, and maintain any spaces in the file name. But it is simplest to create a ``sanitized'' version of |\jobname| in which spaces and asterisks are replaced by underscores, and double quotes are stripped.
% \begin{macrocode}
\StrSubstitute{\jobname}{ }{_}[\minted@jobname]
\StrSubstitute{\minted@jobname}{*}{_}[\minted@jobname]
@@ -1408,6 +1517,22 @@
% \end{macro}
%
%
+% \begin{macro}{finalizecache}
+% Define an option that switches the naming of cache files from an MD5-based system to a |listing<number>| scheme. Compiling with this option is a prerequisite to turning on |frozencache|.
+% \begin{macrocode}
+\DeclareBoolOption{finalizecache}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{frozencache}
+% Define an option that uses a fixed set of cache files, using |listing<number>| file naming with |\write18| disabled. This is convenient for working with a document in an environment in which |\write18| support is disabled and \pkg{minted} content does not need to be modified.
+% \begin{macrocode}
+\DeclareBoolOption{frozencache}
+% \end{macrocode}
+% \end{macro}
+%
+%
% \begin{macro}{\minted@outputdir}
% The |-output-directory| command-line option for \LaTeX\ causes problems for \pkg{minted}, because the \pkg{minted} temporary files are saved in the output directory, but \pkg{minted} still looks for them in the document root directory. There is no way to access the value of the command-line option. But it is possible to allow the output directory to be specified manually as a package option. A trailing slash is automatically appended to the |outputdir|, so that it may be directly joined to |cachedir|. This may be redundant if the user-supplied value already ends with a slash, but doubled slashes are ignored under *nix and Windows, so it isn't a problem.
% \begin{macrocode}
@@ -1452,18 +1577,32 @@
% \end{macro}
%
%
-% Process package options. Proceed with everything that immediately relies upon them. If PGF/Ti\textit{k}Z externalization is in use, switch on |draft| mode and turn off |cache|. Externalization involves compiling the \emph{entire} document; all parts not related to the current image are ``silently thrown away.'' \pkg{minted} needs to cooperate with that by not writing any temp files or creating any directories.
+% Process package options. Proceed with everything that immediately relies upon them. If PGF/Ti\textit{k}Z externalization is in use, switch on |draft| mode and turn off |cache|. Externalization involves compiling the \emph{entire} document; all parts not related to the current image are ``silently thrown away.'' \pkg{minted} needs to cooperate with that by not writing any temp files or creating any directories. Two checks are done for externalization. The first, using |\tikzifexternalizing|, works if externalization is set before \pkg{minted} is loaded. The second, using |\tikzexternalrealjob|, works if externalization is set after \pkg{minted} is loaded.
%
% \begin{macrocode}
\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}}}}%
+ {}
% \end{macrocode}
%
%
@@ -1480,11 +1619,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.}}%
}
% \end{macrocode}
% \end{macro}
@@ -1558,14 +1698,20 @@
% At the end of the document, save the list of cache files and clean the cache. If in draft mode, don't clean up the cache and save the old cache file list for next time. This allows draft mode to be switched on and off without requiring that all highlighted content be regenerated. The saving and cleaning operations may be called without conditionals, since their definitions already contain all necessary checks for their correct operation.
% \begin{macrocode}
\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}}}%
% \end{macrocode}
%
%
@@ -1582,15 +1728,15 @@
\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
% \end{macrocode}
% \end{macro}
@@ -1604,10 +1750,10 @@
\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
% \end{macrocode}
% \end{macro}
@@ -1639,9 +1785,9 @@
%
% \begin{macrocode}
\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}
@@ -1659,7 +1805,7 @@
% On Unix-like systems, we do a straightforward |which| test and create a file upon success, whose existence we can then check.
%
% \begin{macrocode}
- \immediate\write18{which "#1" && touch "\minted@jobname.aex"}
+ \ShellEscape{which #1 && touch \minted@jobname.aex}
\IfFileExists{\minted@jobname.aex}
{\AppExiststrue
\DeleteFile{\minted@jobname.aex}}
@@ -1824,7 +1970,7 @@
% \end{macrocode}
% \end{macro}
%
-% This covers the typical options that must be passed to Pygments. But some, particularly |escapeinside|, need more work. Since their arguments may contain escaped characters, expansion rather than detokenization is needed. Getting expansion to work as desired in a |\write18| context requires the redefinition of some characters
+% This covers the typical options that must be passed to Pygments. But some, particularly |escapeinside|, need more work. Since their arguments may contain escaped characters, expansion rather than detokenization is needed. Getting expansion to work as desired in a |\write18| context requires the redefinition of some characters.
%
% \begin{macro}{\minted@escchars}
% We need to define versions of common escaped characters that will work correctly under expansion for use in |\write18|.
@@ -2128,7 +2274,7 @@
% \begin{macro}{\minted@checkstyle}
% Make sure that style macros exist.
%
-% We have to do some tricks with |\endlinechar| to prevent |\input| from inserting unwanted whitespace. That is primarily for inline commands, where it would introduce a line break. There is also the very unorthodox |\let\def\gdef| to make sure that macros are defined globally.
+% We have to do some tricks with |\endlinechar| to prevent |\input| from inserting unwanted whitespace. That is primarily for inline commands, where it would introduce a line break. There is also the very unorthodox |\let\def\gdef| to make sure that macros are defined globally. The catcodes for |-| and |_| must be changed during macro definition to accomodate style names like |paraiso-light|, |paraiso-dark|, and |algol_nu|.
%
% If a style is not given, then revert to the |default| style, but create macros with prefix |PYG|, and create |default-pyg-prefix.pygstyle| if caching is on. This allows a graceful fallback in the event that style is empty. It is also purposefully used to create a complete set of macros with prefix |PYG|, so that the symbol macros may be used, as described next.
%
@@ -2139,42 +2285,51 @@
\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}%
@@ -2184,9 +2339,9 @@
% \end{macrocode}
% \end{macro}
%
-% At the beginning of the document, create the symbol macros with |PYG| prefix. This must wait until |\AtBeginDocument|, because the existence of |pygmentize| isn't tested and may not be final until |\AtEndPreamble|.
+% At the beginning of the document, create the symbol macros with |PYG| prefix and generate the |default| style. This must wait until |\AtBeginDocument|, because the existence of |pygmentize| isn't tested and may not be final until |\AtEndPreamble|.
% \begin{macrocode}
-\AtBeginDocument{\minted@checkstyle{}}
+\AtBeginDocument{\minted@checkstyle{}\setminted{style=default}}
% \end{macrocode}
%
%
@@ -2344,6 +2499,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}
@@ -2363,6 +2519,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}
@@ -2380,7 +2540,7 @@
\minted@def@opt@switch{breakbytokenanywhere}
% \end{macrocode}
%
-% |bgcolor|: The old |bgcolor| is retained for compatibility. A dedicated framing package will often be preferable.
+% |bgcolor|. The original, |minipage|- and |\colorbox|-based solution was replaced with a |framed|-based solution in version 2.2. A dedicated framing package will often be preferable.
% \begin{macrocode}
\minted@def@opt{bgcolor}
% \end{macrocode}
@@ -2584,6 +2744,64 @@
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}{\FV@BreakBefore}
+% Allow line breaking (almost) anywhere, but only before specified characters.
+% \begin{macrocode}
+\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={}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{FV@BreakBeforeGroup}
+% Determine whether breaking before specified characters is always allowed before each individual character, or is only allowed before the first in a group of identical characters.
+% \begin{macrocode}
+\newboolean{FV@BreakBeforeGroup}
+\define@booleankey{FV}{breakbeforegroup}%
+ {\FV@BreakBeforeGrouptrue}%
+ {\FV@BreakBeforeGroupfalse}%
+\fvset{breakbeforegroup=true}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\FV@BreakBeforePrep}
+% We need a way to break before characters if they have been specified as breaking characters. It would be possible to do that via a nested conditional, but that would be messy. It is much simpler to create an empty macro whose name contains the character, and test for the existence of this macro. This needs to be done inside a |\begingroup...\endgroup| so that the macros do not have to be cleaned up manually. A good place to do this is in |\FV@FormattingPrep|, which is inside a group and before processing starts. The macro is added to |\FV@FormattingPrep| below, after |\FV@BreakAfterPrep| is defined.
+%
+% The procedure here is a bit roundabout. We need to use |\FV@EscChars| to handle character escapes, but the character redefinitions need to be kept local, requiring that we work within a |\begingroup...\endgroup|. So we loop through the breaking tokens and assemble a macro that will itself define character macros. Only this defining macro is declared global, and it contains \emph{expanded} characters so that there is no longer any dependence on |\FV@EscChars|.
+% \begin{macrocode}
+\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
+}
+% \end{macrocode}
+% \end{macro}
+%
% \begin{macro}{\FV@BreakAfter}
% Allow line breaking (almost) anywhere, but only after specified characters.
% \begin{macrocode}
@@ -2595,7 +2813,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={}}
% \end{macrocode}
@@ -2630,6 +2848,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}}{}}%
}%
@@ -2639,11 +2871,16 @@
\FV@BreakAfter@Def
\fi
}
-\expandafter\def\expandafter\FV@FormattingPrep\expandafter{%
- \expandafter\FV@BreakAfterPrep\FV@FormattingPrep}
% \end{macrocode}
% \end{macro}
%
+% Now that |\FV@BreakBeforePrep| and |\FV@BreakAfterPrep| are defined, add them to |\FV@FormattingPrep|. The ordering here is important, since |\FV@BreakAfterPrep| contains compatibility checks with |\FV@BreakBeforePrep|, and thus must be used after it.
+% \begin{macrocode}
+\expandafter\def\expandafter\FV@FormattingPrep\expandafter{%
+ \expandafter\FV@BreakBeforePrep\expandafter\FV@BreakAfterPrep\FV@FormattingPrep}
+% \end{macrocode}
+%
+%
% \begin{macro}{\FancyVerbBreakAnywhereSymbolPre}
% The pre-break symbol for breaks introduced by |breakanywhere|. That is, the symbol before breaks that occur between characters, rather than at spaces.
% \begin{macrocode}
@@ -2666,6 +2903,28 @@
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}{\FancyVerbBreakBeforeSymbolPre}
+% The pre-break symbol for breaks introduced by |breakbefore|.
+% \begin{macrocode}
+\define@key{FV}{breakbeforesymbolpre}{%
+ \ifstrempty{#1}%
+ {\def\FancyVerbBreakBeforeSymbolPre{}}%
+ {\def\FancyVerbBreakBeforeSymbolPre{\hbox{#1}}}}
+\fvset{breakbeforesymbolpre={\,\footnotesize\ensuremath{_\rfloor}}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\FancyVerbBreakBeforeSymbolPost}
+% The post-break symbol for breaks introduced by |breakbefore|.
+% \begin{macrocode}
+\define@key{FV}{breakbeforesymbolpost}{%
+ \ifstrempty{#1}%
+ {\def\FancyVerbBreakBeforeSymbolPost{}}%
+ {\def\FancyVerbBreakBeforeSymbolPost{\hbox{#1}}}}
+\fvset{breakbeforesymbolpost={}}
+% \end{macrocode}
+% \end{macro}
+%
% \begin{macro}{\FancyVerbBreakAfterSymbolPre}
% The pre-break symbol for breaks introduced by |breakafter|.
% \begin{macrocode}
@@ -2700,6 +2959,15 @@
% \end{macro}
%
%
+% \begin{macro}{\FancyVerbBreakBeforeBreak}
+% The macro governing breaking for |breakbefore=true|.
+% \begin{macrocode}
+\newcommand{\FancyVerbBreakBeforeBreak}{%
+ \discretionary{\FancyVerbBreakBeforeSymbolPre}%
+ {\FancyVerbBreakBeforeSymbolPost}{}}
+% \end{macrocode}
+% \end{macro}
+%
% \begin{macro}{\FancyVerbBreakAfterBreak}
% The macro governing breaking for |breakafter=true|.
% \begin{macrocode}
@@ -2759,13 +3027,14 @@
% \end{macro}
%
%
-% Define the macros that actually perform |breakanywhere|.
+% Define the macros that actually perform |breakanywhere|, |breakbefore|, and |breakafter|.
%
% \begin{macro}{\FV@Break}
-% The entry macro for breaking lines, either anywhere or after specified characters. The current line (or argument) will be scanned token by token/group by group, and accumulated (with added potential breaks) in |\FV@Tmp|. After scanning is complete, |\FV@Tmp| will be inserted. It would be possible to insert each token/group into the document immediately after it is scanned, instead of accumulating them in a ``buffer.'' But that would interfere with macros. Even in the current approach, macros that take optional arguments are problematic.\footnote{Through a suitable definition that tracks the current state and looks for square brackets, this might be circumvented. Then again, in verbatim contexts, macro use should be minimal, so the restriction to macros without optional arguments should generally not be an issue.}
+% The entry macro for breaking lines, either anywhere or before/after specified characters. The current line (or argument) will be scanned token by token/group by group, and accumulated (with added potential breaks) in |\FV@Tmp|. After scanning is complete, |\FV@Tmp| will be inserted. It would be possible to insert each token/group into the document immediately after it is scanned, instead of accumulating them in a ``buffer.'' But that would interfere with macros. Even in the current approach, macros that take optional arguments are problematic.\footnote{Through a suitable definition that tracks the current state and looks for square brackets, this might be circumvented. Then again, in verbatim contexts, macro use should be minimal, so the restriction to macros without optional arguments should generally not be an issue.}
% \begin{macrocode}
\def\FV@Break{%
\def\FV@Tmp{}%
+ \let\FV@LastToken\minted@undefined
\FV@Break@Scan
}
% \end{macrocode}
@@ -2809,6 +3078,7 @@
\catcode`\$=3%
\gdef\FV@Break@Math$#1${%
\g@addto@macro{\FV@Tmp}{$#1$}%
+ \let\FV@LastToken\minted@undefined
\FV@Break@Scan}
\endgroup
% \end{macrocode}
@@ -2819,12 +3089,13 @@
% \begin{macrocode}
\def\FV@Break@Group#1{%
\g@addto@macro{\FV@Tmp}{{#1}}%
+ \ifstrempty{#1}{}{\let\FV@LastToken\minted@undefined}%
\FV@Break@Scan}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\FV@Break@Token}
-% This macro is |\let| to |\FV@Break@AnyToken| or |\FV@Break@AfterToken| by the |breakanywhere| and |breakafter| options, so it is not explicitly defined.
+% This macro is |\let| to |\FV@Break@AnyToken| or |\FV@Break@BeforeAfterToken| by the |breakanywhere| and |breakbefore|/|breakafter| options, so it is not explicitly defined.
% \end{macro}
%
% \begin{macro}{\FV@Break@AnyToken}
@@ -2851,23 +3122,63 @@
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}{\FV@Break@AfterToken}
+% \begin{macro}{\FV@Break@BeforeAfterToken}
% Deal with breaking around only specified tokens. This is a bit trickier. We only break if a macro corresponding to the token exists. We also need to check whether the specified token should be grouped, that is, whether breaks are allowed between identical characters. All of this has to be written carefully so that nothing is accidentally inserted into the stream for future scanning.
%
% Dealing with tokens followed by empty groups (for example, |\x{}|) is particularly challenging when we want to avoid breaks between identical characters. When a token is followed by a group, we need to save the current token for later reference (|\x| in the example), then capture and save the following group, and then---only if the group was empty---see if the following token is identical to the old saved token.
% \begin{macrocode}
-\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}}%
@@ -2877,7 +3188,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}%
@@ -2892,10 +3202,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}}
@@ -2953,7 +3263,8 @@
\ifthenelse{\boolean{FV@BreakAutoIndent}}%
{\hspace*{-\wd\FV@LineIndentBox}}%
{}%
- \strut#1\nobreak\strut
+ \strut\FancyVerbFormatText{%
+ \FancyVerbBreakStart#1\FancyVerbBreakStop}\nobreak\strut
\end{internallinenumbers*}
}%
\ifdefempty{\FancyVerbBreakSymbolRight}{}%
@@ -2976,6 +3287,10 @@
% If a line is too wide, then it is passed to |\FV@SaveLineBox|. If there is no right-hand break symbol, then the saved result in |\FV@LineBox| may be used immediately. If there is a right-hand break symbol, then the line must be processed a second time, so that the right-hand break symbol may be removed from the final segment of the broken line (since it does not continue). During the first use of |\FV@SaveLineBox|, the counter |FancyVerbLineBreakLast| is set to the internal line number of the last segment of the broken line. During the second use of |\FV@SaveLineBox|, we disable this (|\let\FV@SetLineBreakLast\relax|) so that the value of |FancyVerbLineBreakLast| remains fixed and thus may be used to determine when a right-hand break symbol should be inserted.
% \begin{macrocode}
\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{%
@@ -2990,12 +3305,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}}%
@@ -3044,18 +3357,19 @@
\newsavebox{\minted@bgbox}
% \end{macrocode}
%
-% Now we can define the environment that captures a code fragment inside a minipage and applies a background color.
+% Now we can define the environment that applies a background color. Prior to \pkg{minted} 2.2, this involved a |minipage|. However, that approach was problematic because it did not allow linebreaks, would be pushed into the margin by immediately preceding text, and had very different whitespace separation from preceding and following text compared to no background color. In version 2.2, this was replaced with an approach based on \pkg{framed}. |\FV@NumberSep| is adjusted by |\fboxsep| to ensure that line numbers remain in the same location in the margin regardless of whether |bgcolor| is used.
%
% \begin{macrocode}
-\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}
% \end{macrocode}
% \end{environment}
%
@@ -3129,6 +3443,14 @@
% \end{macro}
%
%
+% \begin{macro}{minted@pygmentizecounter}
+% We need a counter to keep track of how many files have been pygmentized. This is primarily used with |finalizecache| for naming cache files sequentially in |listing<number>.pygtex| form.
+% \begin{macrocode}
+\newcounter{minted@pygmentizecounter}
+% \end{macrocode}
+% \end{macro}
+%
+%
% \begin{macro}{\minted@pygmentize}
%
% Pygmentize a file (default: |\minted@outputdir\minted@jobname.pyg|) using the options provided.
@@ -3143,6 +3465,7 @@
%
% \begin{macrocode}
\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}}%
@@ -3157,87 +3480,128 @@
-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}%
}
% \end{macrocode}
@@ -3249,6 +3613,62 @@
% At the last possible moment, |\PYG| is |\let| to |\PYG<style>|. All modifications to the style macro for breaking are made to |\PYG<style>| rather than |\PYG|, so that the |\let|ing that must ultimately take place will indeed do what is intended.
% \begin{macrocode}
\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}}{}%
@@ -3306,6 +3726,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}%
@@ -3318,12 +3741,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}}%
@@ -3826,27 +4257,32 @@
%
% \begin{macrocode}
\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}%
}%
}
% \end{macrocode}
@@ -3857,14 +4293,20 @@
%
% Clean up temp files. What actually needs to be done depends on caching and engine.
% \begin{macrocode}
-\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}%
+ }%
+ }%
}
% \end{macrocode}
%
diff --git a/Master/texmf-dist/source/latex/minted/minted.ins b/Master/texmf-dist/source/latex/minted/minted.ins
index 0e9249c1c53..ce99f75f53f 100644
--- a/Master/texmf-dist/source/latex/minted/minted.ins
+++ b/Master/texmf-dist/source/latex/minted/minted.ins
@@ -3,7 +3,7 @@
\askforoverwritefalse
\preamble
-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
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