\color may have an optional argument (part of bug #6567).

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40134 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Georg Baum 2011-11-04 21:24:05 +00:00
parent 292d4e3d5d
commit 7185c39fb1
2 changed files with 10 additions and 3 deletions

View 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 = "";

View 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