From a1cef2d55a255a8fba9a4e1f5a7d5d35f2d00d3e Mon Sep 17 00:00:00 2001 From: Georg Baum Date: Sun, 13 Nov 2011 16:11:45 +0000 Subject: [PATCH] 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 --- lib/syntax.default | 7 +++++-- src/tex2lyx/tex2lyx.cpp | 9 +++++++-- src/tex2lyx/tex2lyx.h | 2 ++ src/tex2lyx/text.cpp | 7 ++++++- 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/lib/syntax.default b/lib/syntax.default index 67d25bd07c..9bfed3faba 100644 --- a/lib/syntax.default +++ b/lib/syntax.default @@ -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 diff --git a/src/tex2lyx/tex2lyx.cpp b/src/tex2lyx/tex2lyx.cpp index addfe3f8c7..49892b0a95 100644 --- a/src/tex2lyx/tex2lyx.cpp +++ b/src/tex2lyx/tex2lyx.cpp @@ -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; diff --git a/src/tex2lyx/tex2lyx.h b/src/tex2lyx/tex2lyx.h index ce201c2cec..bff05191a8 100644 --- a/src/tex2lyx/tex2lyx.h +++ b/src/tex2lyx/tex2lyx.h @@ -116,9 +116,11 @@ std::string active_environment(); enum ArgumentType { required, + req_group, verbatim, item, optional, + opt_group, displaymath, }; diff --git a/src/tex2lyx/text.cpp b/src/tex2lyx/text.cpp index 1fb0e18aa4..7babea1650 100644 --- a/src/tex2lyx/text.cpp +++ b/src/tex2lyx/text.cpp @@ -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 -- 2.39.5