]> git.lyx.org Git - features.git/commitdiff
Handle properly insets which have the PassThru property
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Tue, 12 Feb 2013 17:36:25 +0000 (18:36 +0100)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Tue, 19 Feb 2013 11:04:41 +0000 (12:04 +0100)
This fixes in particular bug 5312:
  % escape in \url{} treated as TeX comment start by importer

src/tex2lyx/text.cpp

index f9888df654a14b192351c6d6bdedbb3303c71f06..855ac28e990cb016c9c9421e0a1f378cda60e5f6 100644 (file)
@@ -1698,7 +1698,14 @@ void parse_environment(Parser & p, ostream & os, bool outer,
                begin_inset(os, "Flex ");
                os << to_utf8(newinsetlayout->name()) << '\n'
                   << "status collapsed\n";
-               parse_text_in_inset(p, os, FLAG_END, false, parent_context, newinsetlayout);
+               if (newinsetlayout->isPassThru()) {
+                       string const arg = p.verbatimEnvironment(name);
+                       Context context(true, parent_context.textclass, 
+                                       &parent_context.textclass.plainLayout(),
+                                       parent_context.layout);
+                       output_ert(os, arg, parent_context);
+               } else
+                       parse_text_in_inset(p, os, FLAG_END, false, parent_context, newinsetlayout);
                end_inset(os);
        }
 
@@ -4476,7 +4483,20 @@ 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, newinsetlayout);
+                       if (newinsetlayout->isPassThru()) {
+                               // set catcodes to verbatim early, just in case.
+                               p.setCatcodes(VERBATIM_CATCODES);
+                               string delim = p.get_token().asInput();
+                               if (delim != "{")
+                                       cerr << "Warning: bad delimiter for command " << t.asInput() << endl;
+                               string const arg = p.verbatimStuff("}");
+                               Context newcontext(true, context.textclass);
+                               if (newinsetlayout->forcePlainLayout())
+                                       newcontext.layout = &context.textclass.plainLayout();
+                               output_ert(os, arg, newcontext);
+                       } else
+                               
+                               parse_text_in_inset(p, os, FLAG_ITEM, false, context, newinsetlayout);
                        end_inset(os);
                }