]> git.lyx.org Git - lyx.git/blobdiff - src/tex2lyx/text.cpp
The roundtrip of the math manual produces a compilable document now:
[lyx.git] / src / tex2lyx / text.cpp
index c3457fb8f14f264cf667c9d06d0c4457b42b86e6..7f633f4a04623915658616a44d54907a5e1a6dc8 100644 (file)
@@ -41,10 +41,15 @@ namespace lyx {
 
 
 void parse_text_in_inset(Parser & p, ostream & os, unsigned flags, bool outer,
-               Context const & context)
+               Context const & context, InsetLayout const * layout)
 {
+       bool const forcePlainLayout =
+               layout ? layout->forcePlainLayout() : false;
        Context newcontext(true, context.textclass);
-       newcontext.font = context.font;
+       if (forcePlainLayout)
+               newcontext.layout = &context.textclass.plainLayout();
+       else
+               newcontext.font = context.font;
        parse_text(p, os, flags, outer, newcontext);
        newcontext.check_end_layout(os);
 }
@@ -52,6 +57,17 @@ void parse_text_in_inset(Parser & p, ostream & os, unsigned flags, bool outer,
 
 namespace {
 
+void parse_text_in_inset(Parser & p, ostream & os, unsigned flags, bool outer,
+               Context const & context, string const & name)
+{
+       InsetLayout const * layout = 0;
+       DocumentClass::InsetLayouts::const_iterator it =
+               context.textclass.insetLayouts().find(from_ascii(name));
+       if (it != context.textclass.insetLayouts().end())
+               layout = &(it->second);
+       parse_text_in_inset(p, os, flags, outer, context, layout);
+}
+
 /// parses a paragraph snippet, useful for example for \\emph{...}
 void parse_text_snippet(Parser & p, ostream & os, unsigned flags, bool outer,
                Context & context)
@@ -2419,7 +2435,7 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
                        context.check_layout(os);
                        begin_inset(os, "Index\n");
                        os << "status collapsed\n";
-                       parse_text_in_inset(p, os, FLAG_ITEM, false, context);
+                       parse_text_in_inset(p, os, FLAG_ITEM, false, context, "Index");
                        end_inset(os);
                }
 
@@ -2457,14 +2473,6 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
                        skip_spaces_braces(p);
                }
 
-               else if (t.cs() == "url") {
-                       context.check_layout(os);
-                       begin_inset(os, "Flex URL\n");
-                       os << "status collapsed\n";
-                       parse_text_in_inset(p, os, FLAG_ITEM, false, context);
-                       end_inset(os);
-               }
-
                else if (LYX_FORMAT >= 408 &&
                         (t.cs() == "textsuperscript" || t.cs() == "textsubscript")) {
                        context.check_layout(os);
@@ -3149,7 +3157,7 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
                        begin_inset(os, "Flex ");
                        os << to_utf8(newinsetlayout->name()) << '\n'
                           << "status collapsed\n";
-                       parse_text_in_inset(p, os, FLAG_ITEM, false, context);
+                       parse_text_in_inset(p, os, FLAG_ITEM, false, context, newinsetlayout);
                        end_inset(os);
                }