Skip to content

Commit b683913

Browse files
committed
working on #137
1 parent 66999d3 commit b683913

2 files changed

Lines changed: 10 additions & 7 deletions

File tree

source/minted.dtx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
%<package>\NeedsTeXFormat{LaTeX2e}
3232
%<package>\ProvidesPackage{minted}
3333
%<*package>
34-
[2016/08/09 v2.4.1dev Yet another Pygments shim for LaTeX]
34+
[2016/10/29 v2.4.1dev Yet another Pygments shim for LaTeX]
3535
%</package>
3636
%<*driver>
3737
\documentclass{ltxdoc}
@@ -195,7 +195,7 @@
195195
%</driver>
196196
% \fi
197197
%
198-
% \CheckSum{2611}
198+
% \CheckSum{2614}
199199
%
200200
% \CharacterTable
201201
% {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,7 +216,8 @@
216216
%
217217
%
218218
%
219-
% \begin{changelog}{v2.4.1}{2016/??/??}
219+
% \begin{changelog}{v2.4.1}{2016/10/??}
220+
% \item Single quotation marks in \texttt{\string\jobname} are now replaced with underscores in \texttt{\string\minted@jobname} to prevent quoting errors (\#137).
220221
% \item The \texttt{autogobble} option now takes \texttt{firstline} and \texttt{lastline} into account (\#130).
221222
% \item Fixed \texttt{numberblanklines}, which had been lost in the transition to 2.0+ (\#135).
222223
% \end{changelog}
@@ -772,7 +773,7 @@
772773
%
773774
%
774775
% \DescribeMacro{cachedir=\meta{directory} (def:~\_minted-\meta{jobname})}
775-
% This allows the directory in which cached files are stored to be specified. Paths should use forward spaces, even under Windows.
776+
% This allows the directory in which cached files are stored to be specified. Paths should use forward slashes, even under Windows.
776777
%
777778
% 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.
778779
%
@@ -864,7 +865,7 @@
864865
% \DescribeMacro{outputdir=\meta{directory} (default:~\meta{none})}
865866
% 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.
866867
%
867-
% 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.
868+
% 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.
868869
%
869870
%
870871
% \DescribeMacro{section}
@@ -1588,11 +1589,12 @@
15881589
%
15891590
%
15901591
% \begin{macro}{\minted@jobname}
1591-
% 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.
1592+
% 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|.
15921593
% \begin{macrocode}
15931594
\StrSubstitute{\jobname}{ }{_}[\minted@jobname]
15941595
\StrSubstitute{\minted@jobname}{*}{_}[\minted@jobname]
15951596
\StrSubstitute{\minted@jobname}{"}{}[\minted@jobname]
1597+
\StrSubstitute{\minted@jobname}{'}{__}[\minted@jobname]
15961598
% \end{macrocode}
15971599
% \end{macro}
15981600
%

source/minted.sty

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
%% and the derived file minted.sty.
2828
\NeedsTeXFormat{LaTeX2e}
2929
\ProvidesPackage{minted}
30-
[2016/08/09 v2.4.1dev Yet another Pygments shim for LaTeX]
30+
[2016/10/29 v2.4.1dev Yet another Pygments shim for LaTeX]
3131
\RequirePackage{keyval}
3232
\RequirePackage{kvoptions}
3333
\RequirePackage{fvextra}
@@ -57,6 +57,7 @@
5757
\StrSubstitute{\jobname}{ }{_}[\minted@jobname]
5858
\StrSubstitute{\minted@jobname}{*}{_}[\minted@jobname]
5959
\StrSubstitute{\minted@jobname}{"}{}[\minted@jobname]
60+
\StrSubstitute{\minted@jobname}{'}{__}[\minted@jobname]
6061
\newcommand{\minted@cachedir}{\detokenize{_}minted-\minted@jobname}
6162
\let\minted@cachedir@windows\minted@cachedir
6263
\define@key{minted}{cachedir}{%

0 commit comments

Comments
 (0)