commit 42863eac9259fa656c0e8a068f5847743a216fb6
Author: Juergen Spitzmueller <[email protected]>
Date: Wed Mar 14 14:38:18 2018 +0100
tex2lyx: support for beamer text styles with overlays
E.g. things like \textbf<article>{foo} have to be imported as insets.
Part of #11068
(cherry picked from commit c74e3999812dfdff3cb6d20ef460dfca1f17c879)
---
src/tex2lyx/Parser.cpp | 4 ++--
src/tex2lyx/Parser.h | 2 +-
src/tex2lyx/text.cpp | 11 +++++++----
3 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/src/tex2lyx/Parser.cpp b/src/tex2lyx/Parser.cpp
index 6e29623..1d506a7 100644
--- a/src/tex2lyx/Parser.cpp
+++ b/src/tex2lyx/Parser.cpp
@@ -453,7 +453,7 @@ bool Parser::good()
}
-bool Parser::hasOpt()
+bool Parser::hasOpt(string const l)
{
// An optional argument can occur in any of the following forms:
// - \foo[bar]
@@ -479,7 +479,7 @@ bool Parser::hasOpt()
putback();
break;
}
- bool const retval = (next_token().asInput() == "[");
+ bool const retval = (next_token().asInput() == l);
pos_ = oldpos;
return retval;
}
diff --git a/src/tex2lyx/Parser.h b/src/tex2lyx/Parser.h
index 08d07c1..83fa1c7 100644
--- a/src/tex2lyx/Parser.h
+++ b/src/tex2lyx/Parser.h
@@ -214,7 +214,7 @@ public:
void dump() const;
/// Does an optional argument follow after the current token?
- bool hasOpt();
+ bool hasOpt(std::string const l = "[");
///
typedef std::pair<bool, std::string> Arg;
/*!
diff --git a/src/tex2lyx/text.cpp b/src/tex2lyx/text.cpp
index ac2bed1..f3617a8 100644
--- a/src/tex2lyx/text.cpp
+++ b/src/tex2lyx/text.cpp
@@ -3627,14 +3627,16 @@ void parse_text(Parser & p, ostream & os, unsigned
flags, bool outer,
continue;
}
- if ((where = is_known(t.cs(), known_text_font_series))) {
+ // beamer has a \textbf<overlay>{} inset
+ if (!p.hasOpt("<") && (where = is_known(t.cs(),
known_text_font_series))) {
parse_text_attributes(p, os, FLAG_ITEM, outer,
context, "\\series", context.font.series,
known_coded_font_series[where -
known_text_font_series]);
continue;
}
- if ((where = is_known(t.cs(), known_text_font_shapes))) {
+ // beamer has a \textit<overlay>{} inset
+ if (!p.hasOpt("<") && (where = is_known(t.cs(),
known_text_font_shapes))) {
parse_text_attributes(p, os, FLAG_ITEM, outer,
context, "\\shape", context.font.shape,
known_coded_font_shapes[where -
known_text_font_shapes]);
@@ -3713,9 +3715,10 @@ void parse_text(Parser & p, ostream & os, unsigned
flags, bool outer,
continue;
}
- if (t.cs() == "uuline" || t.cs() == "uwave"
+ // beamer has an \emph<overlay>{} inset
+ if ((t.cs() == "uuline" || t.cs() == "uwave"
|| t.cs() == "emph" || t.cs() == "noun"
- || t.cs() == "xout") {
+ || t.cs() == "xout") && !p.hasOpt("<")) {
context.check_layout(os);
os << "\n\\" << t.cs() << " on\n";
parse_text_snippet(p, os, FLAG_ITEM, outer, context);