From: Georg Baum Date: Fri, 7 Jan 2011 21:04:16 +0000 (+0000) Subject: Parse Flex insets defined in the layout. This is needed e.g. for X-Git-Tag: 2.0.0~1155 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=f49a526afcb9f37c7f3fa72c2e4cb6501543d79b;p=features.git Parse Flex insets defined in the layout. This is needed e.g. for lib/doc/Math.lyx, since tex2lyx swallows the LyX part of the preamble, and thus \shortcut would not be defined. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@37149 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/tex2lyx/text.cpp b/src/tex2lyx/text.cpp index be604629b3..113d9c5473 100644 --- a/src/tex2lyx/text.cpp +++ b/src/tex2lyx/text.cpp @@ -447,6 +447,19 @@ Layout const * findLayout(TextClass const & textclass, string const & name) } +InsetLayout const * findInsetLayout(TextClass const & textclass, string const & name, bool command) +{ + DocumentClass::InsetLayouts::const_iterator it = textclass.insetLayouts().begin(); + DocumentClass::InsetLayouts::const_iterator en = textclass.insetLayouts().end(); + for (; it != en; ++it) + if (it->second.latexname() == name && + ((command && it->second.latextype() == InsetLayout::COMMAND) || + (!command && it->second.latextype() == InsetLayout::ENVIRONMENT))) + return &(it->second); + return 0; +} + + void eat_whitespace(Parser &, ostream &, Context &, bool); @@ -1334,6 +1347,7 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer, Context & context) { Layout const * newlayout = 0; + InsetLayout const * newinsetlayout = 0; // Store the latest bibliographystyle and nocite{*} option // (needed for bibtex inset) string btprint; @@ -2976,6 +2990,17 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer, } } + // The single '=' is meant here. + else if ((newinsetlayout = findInsetLayout(context.textclass, t.cs(), true))) { + p.skip_spaces(); + context.check_layout(os); + begin_inset(os, "Flex "); + os << to_utf8(newinsetlayout->name()) << '\n' + << "status collapsed\n"; + parse_text_in_inset(p, os, FLAG_ITEM, false, context); + end_inset(os); + } + else { // try to see whether the string is in unicodesymbols // Only use text mode commands, since we are in text mode here,