Prune white space after the separating comma of options

Both listings and minted allow for many complex options. So, a latex
source can be easily written as

\documentclass{article}
\usepackage{minted}
\usepackage{graphicx}
\usepackage{dingbat}
\begin{document}
\begin{minted}[breaklines=true,
               breakautoindent=false,
               breaksymbolleft=\raisebox{0.8ex}{
                   \small\reflectbox{\carriagereturn}},
               breaksymbolindentleft=0pt,
               breaksymbolsepleft=0pt,
               breaksymbolright=\small\carriagereturn,
               breaksymbolindentright=0pt,
               breaksymbolsepright=0pt]{Python}
def f(x):
    return 'Some text' + str(x) + 'some more text' + str(x) + 'even more text that goes on for a while'
\end{minted}
\end{document}

The used text editor can therefore add a mixture of tabs and spaces.
The white space after the options is not a problem and the imported
file compiles just fine, but the validator gets confused and doesn't
validate them. This would entail a difficult editing of the options
only to have them validated. So, better remove the white space.
This commit is contained in:
Enrico Forestieri 2017-06-17 20:41:29 +02:00
parent a1e65ad458
commit d4d7cdf9a1

View File

@ -1327,6 +1327,11 @@ void parse_listings(Parser & p, ostream & os, Context & parent_context,
parent_context.check_layout(os);
begin_inset(os, "listings\n");
string arg = p.hasOpt() ? subst(p.verbatimOption(), "\n", "") : string();
size_t i;
while ((i = arg.find(", ")) != string::npos
|| (i = arg.find(",\t")) != string::npos)
arg.erase(i + 1, 1);
if (use_minted) {
string const language = p.getArg('{', '}');
p.skip_spaces(true);