mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 01:59:02 +00:00
tex2lyx: towards beamer overlay argument support.
Implemented: Overlay and standard overlay arguments for commands and environments. Still missing: * List item overlay * itemcommand overlay (\overprint) * overlay via LatexParam (e.g., Flex:ArticleMode) Needs fixing: * General list argument (\begin{itemize}[arg]) * nested content in a frame with no title (empty par)
This commit is contained in:
parent
8725614e3f
commit
949de66956
@ -67,7 +67,8 @@ enum {
|
|||||||
FLAG_OPTION = 1 << 11, // read [...] style option
|
FLAG_OPTION = 1 << 11, // read [...] style option
|
||||||
FLAG_BRACED = 1 << 12, // read {...} style argument
|
FLAG_BRACED = 1 << 12, // read {...} style argument
|
||||||
FLAG_CELL = 1 << 13, // read table cell
|
FLAG_CELL = 1 << 13, // read table cell
|
||||||
FLAG_TABBING = 1 << 14 // We are inside a tabbing environment
|
FLAG_TABBING = 1 << 14, // We are inside a tabbing environment
|
||||||
|
FLAG_RDELIM = 1 << 15, // next right delimiter ends the parsing
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -52,10 +52,6 @@ Format LaTeX feature LyX feature
|
|||||||
415 automatic undertilde loading \use_package undertilde
|
415 automatic undertilde loading \use_package undertilde
|
||||||
443 unicode-math.sty InsetMath*
|
443 unicode-math.sty InsetMath*
|
||||||
448
|
448
|
||||||
451 beamer overlay arguments InsetArgument
|
|
||||||
\command<arg>, \begin{env}<arg>
|
|
||||||
452 beamer block arguments InsetArgument
|
|
||||||
\begin{block}<overlay>{title}
|
|
||||||
453 automatic stmaryrd loading \use_package stmaryrd
|
453 automatic stmaryrd loading \use_package stmaryrd
|
||||||
454 beamer overprint environment InsetArgument, layout Overprint
|
454 beamer overprint environment InsetArgument, layout Overprint
|
||||||
\begin{overprint}[maxlength]
|
\begin{overprint}[maxlength]
|
||||||
@ -64,9 +60,6 @@ Format LaTeX feature LyX feature
|
|||||||
455 beamer frametitle command \begin_layout FrameTitle
|
455 beamer frametitle command \begin_layout FrameTitle
|
||||||
\frametitle<overlay>[short]{long}
|
\frametitle<overlay>[short]{long}
|
||||||
457 automatic stackrel loading \use_package stackrel
|
457 automatic stackrel loading \use_package stackrel
|
||||||
459 beamer: \begin{frame}, \begin_layout Frame
|
|
||||||
\begin{frame}[plain], \begin_layout PlainFrame
|
|
||||||
\begin{frame}[fragile] \begin_layout FragileFrame
|
|
||||||
466 Powerdot updates:
|
466 Powerdot updates:
|
||||||
\pause[] layout Pause
|
\pause[] layout Pause
|
||||||
\onslide{}{} InsetFlex, InsetArgument
|
\onslide{}{} InsetFlex, InsetArgument
|
||||||
|
@ -48,7 +48,7 @@ extern std::string rgbcolor2code(std::string const & name);
|
|||||||
std::string translate_len(std::string const &);
|
std::string translate_len(std::string const &);
|
||||||
|
|
||||||
void parse_text(Parser & p, std::ostream & os, unsigned flags, bool outer,
|
void parse_text(Parser & p, std::ostream & os, unsigned flags, bool outer,
|
||||||
Context & context);
|
Context & context, std::string const rdelim = std::string());
|
||||||
void check_comment_bib(std::ostream & os, Context & context);
|
void check_comment_bib(std::ostream & os, Context & context);
|
||||||
|
|
||||||
void fix_child_filename(std::string & name);
|
void fix_child_filename(std::string & name);
|
||||||
@ -67,7 +67,8 @@ std::string find_file(std::string const & name, std::string const & path,
|
|||||||
*/
|
*/
|
||||||
void parse_text_in_inset(Parser & p, std::ostream & os, unsigned flags,
|
void parse_text_in_inset(Parser & p, std::ostream & os, unsigned flags,
|
||||||
bool outer, Context const & context,
|
bool outer, Context const & context,
|
||||||
InsetLayout const * layout = 0);
|
InsetLayout const * layout = 0,
|
||||||
|
std::string const rdelim = std::string());
|
||||||
|
|
||||||
/// Guess document language from \p p if CJK is used.
|
/// Guess document language from \p p if CJK is used.
|
||||||
/// \p lang is used for all non-CJK contents.
|
/// \p lang is used for all non-CJK contents.
|
||||||
|
@ -54,7 +54,8 @@ void output_arguments(ostream &, Parser &, bool, bool, bool, Context &,
|
|||||||
|
|
||||||
|
|
||||||
void parse_text_in_inset(Parser & p, ostream & os, unsigned flags, bool outer,
|
void parse_text_in_inset(Parser & p, ostream & os, unsigned flags, bool outer,
|
||||||
Context const & context, InsetLayout const * layout)
|
Context const & context, InsetLayout const * layout,
|
||||||
|
string const rdelim)
|
||||||
{
|
{
|
||||||
bool const forcePlainLayout =
|
bool const forcePlainLayout =
|
||||||
layout ? layout->forcePlainLayout() : false;
|
layout ? layout->forcePlainLayout() : false;
|
||||||
@ -66,7 +67,7 @@ void parse_text_in_inset(Parser & p, ostream & os, unsigned flags, bool outer,
|
|||||||
if (layout)
|
if (layout)
|
||||||
output_arguments(os, p, outer, false, false, newcontext,
|
output_arguments(os, p, outer, false, false, newcontext,
|
||||||
layout->latexargs());
|
layout->latexargs());
|
||||||
parse_text(p, os, flags, outer, newcontext);
|
parse_text(p, os, flags, outer, newcontext, rdelim);
|
||||||
if (layout)
|
if (layout)
|
||||||
output_arguments(os, p, outer, false, true, newcontext,
|
output_arguments(os, p, outer, false, true, newcontext,
|
||||||
layout->postcommandargs());
|
layout->postcommandargs());
|
||||||
@ -77,14 +78,15 @@ void parse_text_in_inset(Parser & p, ostream & os, unsigned flags, bool outer,
|
|||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
void parse_text_in_inset(Parser & p, ostream & os, unsigned flags, bool outer,
|
void parse_text_in_inset(Parser & p, ostream & os, unsigned flags, bool outer,
|
||||||
Context const & context, string const & name)
|
Context const & context, string const & name,
|
||||||
|
string const rdelim = string())
|
||||||
{
|
{
|
||||||
InsetLayout const * layout = 0;
|
InsetLayout const * layout = 0;
|
||||||
DocumentClass::InsetLayouts::const_iterator it =
|
DocumentClass::InsetLayouts::const_iterator it =
|
||||||
context.textclass.insetLayouts().find(from_ascii(name));
|
context.textclass.insetLayouts().find(from_ascii(name));
|
||||||
if (it != context.textclass.insetLayouts().end())
|
if (it != context.textclass.insetLayouts().end())
|
||||||
layout = &(it->second);
|
layout = &(it->second);
|
||||||
parse_text_in_inset(p, os, flags, outer, context, layout);
|
parse_text_in_inset(p, os, flags, outer, context, layout, rdelim);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// parses a paragraph snippet, useful for example for \\emph{...}
|
/// parses a paragraph snippet, useful for example for \\emph{...}
|
||||||
@ -764,7 +766,15 @@ void output_arguments(ostream & os, Parser & p, bool outer, bool need_layout, bo
|
|||||||
if (lait->second.mandatory) {
|
if (lait->second.mandatory) {
|
||||||
if (p.next_token().cat() != catBegin)
|
if (p.next_token().cat() != catBegin)
|
||||||
break;
|
break;
|
||||||
p.get_token(); // eat '{'
|
string ldelim = to_utf8(lait->second.ldelim);
|
||||||
|
string rdelim = to_utf8(lait->second.rdelim);
|
||||||
|
if (ldelim.empty())
|
||||||
|
ldelim = "{";
|
||||||
|
if (rdelim.empty())
|
||||||
|
rdelim = "}";
|
||||||
|
p.get_token(); // eat ldelim
|
||||||
|
if (ldelim.size() > 1)
|
||||||
|
p.get_token(); // eat ldelim
|
||||||
if (need_layout) {
|
if (need_layout) {
|
||||||
context.check_layout(os);
|
context.check_layout(os);
|
||||||
need_layout = false;
|
need_layout = false;
|
||||||
@ -773,13 +783,24 @@ void output_arguments(ostream & os, Parser & p, bool outer, bool need_layout, bo
|
|||||||
if (post)
|
if (post)
|
||||||
os << "post:";
|
os << "post:";
|
||||||
os << i << "\nstatus collapsed\n\n";
|
os << i << "\nstatus collapsed\n\n";
|
||||||
parse_text_in_inset(p, os, FLAG_BRACE_LAST, outer, context);
|
parse_text_in_inset(p, os, FLAG_RDELIM, outer, context, 0, rdelim);
|
||||||
end_inset(os);
|
end_inset(os);
|
||||||
} else {
|
} else {
|
||||||
if (p.next_token().cat() == catEscape ||
|
string ldelim = to_utf8(lait->second.ldelim);
|
||||||
p.next_token().character() != '[')
|
string rdelim = to_utf8(lait->second.rdelim);
|
||||||
|
if (ldelim.empty())
|
||||||
|
ldelim = "[";
|
||||||
|
if (rdelim.empty())
|
||||||
|
rdelim = "]";
|
||||||
|
string tok = p.next_token().asInput();
|
||||||
|
// we only support delimiters with max 2 chars for now.
|
||||||
|
if (ldelim.size() > 1)
|
||||||
|
tok += p.next_next_token().asInput();
|
||||||
|
if (p.next_token().cat() == catEscape || tok != ldelim)
|
||||||
continue;
|
continue;
|
||||||
p.get_token(); // eat '['
|
p.get_token(); // eat ldelim
|
||||||
|
if (ldelim.size() > 1)
|
||||||
|
p.get_token(); // eat ldelim
|
||||||
if (need_layout) {
|
if (need_layout) {
|
||||||
context.check_layout(os);
|
context.check_layout(os);
|
||||||
need_layout = false;
|
need_layout = false;
|
||||||
@ -788,7 +809,7 @@ void output_arguments(ostream & os, Parser & p, bool outer, bool need_layout, bo
|
|||||||
if (post)
|
if (post)
|
||||||
os << "post:";
|
os << "post:";
|
||||||
os << i << "\nstatus collapsed\n\n";
|
os << i << "\nstatus collapsed\n\n";
|
||||||
parse_text_in_inset(p, os, FLAG_BRACK_LAST, outer, context);
|
parse_text_in_inset(p, os, FLAG_RDELIM, outer, context, 0, rdelim);
|
||||||
end_inset(os);
|
end_inset(os);
|
||||||
}
|
}
|
||||||
eat_whitespace(p, os, context, false);
|
eat_whitespace(p, os, context, false);
|
||||||
@ -2060,10 +2081,11 @@ void parse_environment(Parser & p, ostream & os, bool outer,
|
|||||||
}
|
}
|
||||||
context.check_deeper(os);
|
context.check_deeper(os);
|
||||||
// handle known optional and required arguments
|
// handle known optional and required arguments
|
||||||
// Unfortunately LyX can't handle arguments of list arguments (bug 7468):
|
// FIXME: for item environments, this is currently
|
||||||
// It is impossible to place anything after the environment name,
|
// placed wrongly (in an empty paragraph). It has to go to
|
||||||
// but before the first \\item.
|
// the first \item par instead.
|
||||||
if (context.layout->latextype == LATEX_ENVIRONMENT)
|
if (context.layout->latextype == LATEX_ENVIRONMENT
|
||||||
|
|| context.layout->latextype == LATEX_ITEM_ENVIRONMENT)
|
||||||
output_arguments(os, p, outer, false, false, context,
|
output_arguments(os, p, outer, false, false, context,
|
||||||
context.layout->latexargs());
|
context.layout->latexargs());
|
||||||
parse_text(p, os, FLAG_END, outer, context);
|
parse_text(p, os, FLAG_END, outer, context);
|
||||||
@ -2583,7 +2605,7 @@ void fix_child_filename(string & name)
|
|||||||
|
|
||||||
|
|
||||||
void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
|
void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
|
||||||
Context & context)
|
Context & context, string const rdelim)
|
||||||
{
|
{
|
||||||
Layout const * newlayout = 0;
|
Layout const * newlayout = 0;
|
||||||
InsetLayout const * newinsetlayout = 0;
|
InsetLayout const * newinsetlayout = 0;
|
||||||
@ -2660,6 +2682,16 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
|
|||||||
return;
|
return;
|
||||||
if (t.cat() == catEnd && (flags & FLAG_BRACE_LAST))
|
if (t.cat() == catEnd && (flags & FLAG_BRACE_LAST))
|
||||||
return;
|
return;
|
||||||
|
string tok = t.asInput();
|
||||||
|
// we only support delimiters with max 2 chars for now.
|
||||||
|
if (rdelim.size() > 1)
|
||||||
|
tok += p.next_token().asInput();
|
||||||
|
if (t.cat() != catEscape && !rdelim.empty()
|
||||||
|
&& tok == rdelim && (flags & FLAG_RDELIM)) {
|
||||||
|
if (rdelim.size() > 1)
|
||||||
|
p.get_token(); // eat rdelim
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// If there is anything between \end{env} and \begin{env} we
|
// If there is anything between \end{env} and \begin{env} we
|
||||||
// don't need to output a separator.
|
// don't need to output a separator.
|
||||||
|
Loading…
Reference in New Issue
Block a user