diff options
author | Karl Berry <karl@freefriends.org> | 2016-11-01 20:14:54 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2016-11-01 20:14:54 +0000 |
commit | 2eb34cbc280474b94760588e88ed5a5dc7acaea0 (patch) | |
tree | e5794e908c82f0d9974c87bbeb77467010910489 /Master/texmf-dist/source/latex | |
parent | 14d2653fc014c2663e17017f23e79306e070a04c (diff) |
minted (1nov16)
git-svn-id: svn://tug.org/texlive/trunk@42418 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex')
-rw-r--r-- | Master/texmf-dist/source/latex/minted/minted.dtx | 43 |
1 files changed, 30 insertions, 13 deletions
diff --git a/Master/texmf-dist/source/latex/minted/minted.dtx b/Master/texmf-dist/source/latex/minted/minted.dtx index df47ea191cc..4cbc252fa30 100644 --- a/Master/texmf-dist/source/latex/minted/minted.dtx +++ b/Master/texmf-dist/source/latex/minted/minted.dtx @@ -31,7 +31,7 @@ %<package>\NeedsTeXFormat{LaTeX2e} %<package>\ProvidesPackage{minted} %<*package> - [2016/07/20 v2.4 Yet another Pygments shim for LaTeX] + [2016/10/31 v2.4.1 Yet another Pygments shim for LaTeX] %</package> %<*driver> \documentclass{ltxdoc} @@ -195,7 +195,7 @@ %</driver> % \fi % -% \CheckSum{2542} +% \CheckSum{2614} % % \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 @@ -216,9 +216,16 @@ % % % +% \begin{changelog}{v2.4.1}{2016/10/31} +% \item Single quotation marks in \texttt{\string\jobname} are now replaced with underscores in \texttt{\string\minted@jobname} to prevent quoting errors (\#137). +% \item The \texttt{autogobble} option now takes \texttt{firstline} and \texttt{lastline} into account (\#130). +% \item Fixed \texttt{numberblanklines}, which had been lost in the transition to v2.0+ (\#135). +% \end{changelog} +% +% % \begin{changelog}{v2.4}{2016/07/20} % \item Line breaking and all associated options are now completely delegated to \texttt{fvextra}. -% \item Fixed a bug from v2.2 that could cause the first command or environment to vanish when \texttt{caching=false} (related to work on \texttt{\string\MintedPygmentize}). +% \item Fixed a bug from v2.2 that could cause the first command or environment to vanish when \texttt{cache=false} (related to work on \texttt{\string\MintedPygmentize}). % \end{changelog} % % @@ -766,7 +773,7 @@ % % % \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. +% This allows the directory in which cached files are stored to be specified. Paths should use forward slashes, even under Windows. % % 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. % @@ -858,7 +865,7 @@ % \DescribeMacro{outputdir=\meta{directory} (default:~\meta{none})} % 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. 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. +% The output directory should be specified using an absolute path or a path relative to the document root directory. Paths should use forward slashes, 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} @@ -1582,11 +1589,12 @@ % % % \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. Single quotes are also replaced, since they can cause quoted string errors, or become double quotes in the process of being passed to the system through |\write18|. % \begin{macrocode} \StrSubstitute{\jobname}{ }{_}[\minted@jobname] \StrSubstitute{\minted@jobname}{*}{_}[\minted@jobname] \StrSubstitute{\minted@jobname}{"}{}[\minted@jobname] +\StrSubstitute{\minted@jobname}{'}{_}[\minted@jobname] % \end{macrocode} % \end{macro} % @@ -2567,6 +2575,7 @@ \minted@def@optfv{highlightcolor} \minted@def@optfv@switch{curlyquotes} \minted@def@optfv@switch{numberfirstline} +\minted@def@optfv@switch{numberblanklines} \minted@def@optfv@switch{stepnumberfromfirst} \minted@def@optfv@switch{stepnumberoffsetvalues} \minted@def@optfv@switch{showspaces} @@ -2782,7 +2791,7 @@ \ifx\XeTeXinterchartoks\minted@undefined \ifthenelse{\equal{\minted@get@opt{autogobble}{false}}{true}}% {\edef\minted@hash{\pdf@filemdfivesum{#1}% - \pdf@mdfivesum{\minted@cmd autogobble}}}% + \pdf@mdfivesum{\minted@cmd autogobble(\ifx\FancyVerbStartNum\z@ 0\else\FancyVerbStartNum\fi-\ifx\FancyVerbStopNum\z@ 0\else\FancyVerbStopNum\fi)}}}% {\edef\minted@hash{\pdf@filemdfivesum{#1}% \pdf@mdfivesum{\minted@cmd}}}% \else @@ -2790,7 +2799,7 @@ \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\write\minted@code{autogobble(\ifx\FancyVerbStartNum\z@ 0\else\FancyVerbStartNum\fi-\ifx\FancyVerbStopNum\z@ 0\else\FancyVerbStopNum\fi)}}{}% \immediate\closeout\minted@code \edef\minted@argone@esc{#1}% \StrSubstitute{\minted@argone@esc}{\@backslashchar}{\@backslashchar\@backslashchar}[\minted@argone@esc]% @@ -2818,7 +2827,7 @@ \else \ifthenelse{\equal{\minted@get@opt{autogobble}{false}}{true}}% {\edef\minted@hash{\mdfivesum file {#1}% - \mdfivesum{\minted@cmd autogobble}}}% + \mdfivesum{\minted@cmd autogobble(\ifx\FancyVerbStartNum\z@ 0\else\FancyVerbStartNum\fi-\ifx\FancyVerbStopNum\z@ 0\else\FancyVerbStopNum\fi)}}}% {\edef\minted@hash{\mdfivesum file {#1}% \mdfivesum{\minted@cmd}}}% \fi @@ -2838,10 +2847,14 @@ 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(); + t = f.readlines(); 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)); + fvstartnum = }\ifx\FancyVerbStartNum\z@ 0\else\FancyVerbStartNum\fi\detokenize{; + fvstopnum = }\ifx\FancyVerbStopNum\z@ 0\else\FancyVerbStopNum\fi\detokenize{; + s = fvstartnum-1 if fvstartnum != 0 else 0; + e = fvstopnum if fvstopnum != 0 else len(t); + [f.write(textwrap.dedent(\"\".join(x))) for x in (t[0:s], t[s:e], t[e:]) if x]; f.close();"}% }% \ShellEscape{\minted@autogobblecmd}}{}% @@ -2883,10 +2896,14 @@ 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(); + t = f.readlines(); 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)); + fvstartnum = }\ifx\FancyVerbStartNum\z@ 0\else\FancyVerbStartNum\fi\detokenize{; + fvstopnum = }\ifx\FancyVerbStopNum\z@ 0\else\FancyVerbStopNum\fi\detokenize{; + s = fvstartnum-1 if fvstartnum != 0 else 0; + e = fvstopnum if fvstopnum != 0 else len(t); + [f.write(textwrap.dedent(\"\".join(x))) for x in (t[0:s], t[s:e], t[e:]) if x]; f.close();"}% }% \ShellEscape{\minted@autogobblecmd}}{}% |