Fix bug #3036: font changes inside \markright do not escape outside their scope

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40186 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Georg Baum 2011-11-13 16:11:45 +00:00
parent 36f7ae1207
commit a1cef2d55a
4 changed files with 20 additions and 5 deletions

View File

@ -370,6 +370,9 @@ $$
% is some code that may occur in a .tex file created by LyX. The re-import
% works only because the first argument of \texorpdfstring is specified as
% translatable in this file.
% If a command puts the contents of an argument inside an own group, use
% "group" instead of "translate". Otherwise things like font changes would
% survive the end of the group in LyX (bug 3036).
\abstractname
\Acrobatmenu{}{} % from the hyperref package
@ -515,8 +518,8 @@ $$
\makelabels
\maketitle
\MakeShortVerb{} % from doc.sty, argument must be verbatim
\markboth{}{translate}
\markright{translate}
\markboth{group}{group}
\markright{group}
\mathversion{}
\mbox{translate}
\mddefault

View File

@ -355,6 +355,8 @@ void read_command(Parser & p, string command, CommandMap & commands)
string const arg = p.getArg('{', '}');
if (arg == "translate")
arguments.push_back(required);
else if (arg == "group")
arguments.push_back(req_group);
else if (arg == "item")
arguments.push_back(item);
else if (arg == "displaymath")
@ -362,8 +364,11 @@ void read_command(Parser & p, string command, CommandMap & commands)
else
arguments.push_back(verbatim);
} else {
p.getArg('[', ']');
arguments.push_back(optional);
string const arg = p.getArg('[', ']');
if (arg == "group")
arguments.push_back(opt_group);
else
arguments.push_back(optional);
}
}
commands[command] = arguments;

View File

@ -116,9 +116,11 @@ std::string active_environment();
enum ArgumentType {
required,
req_group,
verbatim,
item,
optional,
opt_group,
displaymath,
};

View File

@ -674,10 +674,14 @@ void parse_arguments(string const & command,
for (size_t i = 0; i < no_arguments; ++i) {
switch (template_arguments[i]) {
case required:
case req_group:
// This argument contains regular LaTeX
handle_ert(os, ert + '{', context);
eat_whitespace(p, os, context, false);
parse_text(p, os, FLAG_ITEM, outer, context);
if (template_arguments[i] == required)
parse_text(p, os, FLAG_ITEM, outer, context);
else
parse_text_snippet(p, os, FLAG_ITEM, outer, context);
ert = "}";
break;
case item:
@ -695,6 +699,7 @@ void parse_arguments(string const & command,
ert += '{' + p.verbatim_item() + '}';
break;
case optional:
case opt_group:
// true because we must not eat whitespace
// if an optional arg follows we must not strip the
// brackets from this one