]> git.lyx.org Git - features.git/commitdiff
tex2lyx: Fixes to the btUnit import
authorJuergen Spitzmueller <spitz@lyx.org>
Wed, 22 Aug 2018 06:39:13 +0000 (08:39 +0200)
committerJuergen Spitzmueller <spitz@lyx.org>
Wed, 22 Aug 2018 06:39:13 +0000 (08:39 +0200)
1. Do not attempt to mix diverging btUnits (e.g., chapters and sections).
2. use parse_text to properly parse the contents.

src/tex2lyx/Preamble.h
src/tex2lyx/text.cpp

index 725bf6740eee030c8bce30416c9b720b50101152..804e5caf0ccd59b28538dc9ec268df925b0deb25 100644 (file)
@@ -82,6 +82,8 @@ public:
        ///
        void citeEngine(std::string const & e) { h_cite_engine = e; }
        ///
+       std::string multibib() const { return h_multibib; }
+       ///
        void multibib(std::string const & s) { h_multibib = s; }
        ///
        bool titleLayoutFound() const { return title_layout_found; }
index c39f928f149cb1110b1452dfc811aad9c19e2675..5bc0e996d04d3d9dd05645b96f1a417696d41f6d 100644 (file)
@@ -1925,9 +1925,12 @@ void parse_environment(Parser & p, ostream & os, bool outer,
 
        else if (name == "btUnit") {
                string const nt = p.next_next_token().cs();
-               if (nt == "part" || nt == "chapter"
-                  || nt == "section" || nt == "subsection") {
-                       active_environments.push_back("btUnit");
+               // Do not attempt to overwrite a former diverging multibib.
+               // Those are output as ERT instead.
+               if ((nt == "part" || nt == "chapter"
+                    || nt == "section" || nt == "subsection")
+                  && (preamble.multibib().empty() || preamble.multibib() == nt)) {
+                       parse_text(p, os, FLAG_END, outer, parent_context);
                        preamble.multibib(nt);
                } else
                        parse_unknown_environment(p, name, os, FLAG_END, outer,