]> git.lyx.org Git - features.git/commitdiff
\color may have an optional argument (part of bug #6567).
authorGeorg Baum <georg.baum@post.rwth-aachen.de>
Fri, 4 Nov 2011 21:24:05 +0000 (21:24 +0000)
committerGeorg Baum <georg.baum@post.rwth-aachen.de>
Fri, 4 Nov 2011 21:24:05 +0000 (21:24 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40134 a592a061-630c-0410-9148-cb99ea01b6c8

src/tex2lyx/Preamble.cpp
src/tex2lyx/test/box-color-size-space-align.tex

index f084ad33a3dd2ae3e7215613a5fb3d89a0b1337f..dace26f0e3b88ff6e65f8332097967c646b6dccb 100644 (file)
@@ -1003,17 +1003,22 @@ void Preamble::parse(Parser & p, string const & forceclass,
                }
 
                else if (t.cs() == "color") {
+                       string const space =
+                               (p.hasOpt() ? p.getArg('[', ']') : string());
                        string argument = p.getArg('{', '}');
                        // check the case that a standard color is used
-                       if (is_known(argument, known_basic_colors)) {
+                       if (space.empty() && is_known(argument, known_basic_colors)) {
                                h_fontcolor = rgbcolor2code(argument);
                                preamble.registerAutomaticallyLoadedPackage("color");
-                       } else if (argument == "document_fontcolor")
+                       } else if (space.empty() && argument == "document_fontcolor")
                                preamble.registerAutomaticallyLoadedPackage("color");
                        // check the case that LyX's document_fontcolor is defined
                        // but not used for \color
                        else {
-                               h_preamble << t.asInput() << '{' << argument << '}';
+                               h_preamble << t.asInput();
+                               if (!space.empty())
+                                       h_preamble << '[' << space << ']';
+                               h_preamble << '{' << argument << '}';
                                // the color might already be set because \definecolor
                                // is parsed before this
                                h_fontcolor = "";
index ef4dd8c8ee499c25f983621a33c41e64d892cf6e..094242804e6794dc8a8dc258928ebd2c1f62da7e 100644 (file)
@@ -38,6 +38,8 @@
 
 \definecolor{darkgreen}{cmyk}{0.5, 0, 1, 0.5}
 
+\color[rgb]{0,0,0}
+
 \usepackage{ifpdf} % part of the hyperref bundle
 \ifpdf % if pdflatex is used