commit d4d7cdf9a1d48150eec7dc0fd656488501dad4c0
Author: Enrico Forestieri <[email protected]>
Date:   Sat Jun 17 20:41:29 2017 +0200

    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.
---
 src/tex2lyx/text.cpp |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/src/tex2lyx/text.cpp b/src/tex2lyx/text.cpp
index e5180cf..2e7f08a 100644
--- a/src/tex2lyx/text.cpp
+++ b/src/tex2lyx/text.cpp
@@ -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);

Reply via email to