]> git.lyx.org Git - features.git/blobdiff - src/xml.cpp
Revert "Fix #11827"
[features.git] / src / xml.cpp
index 2c30f1548dfd8fbc9802fe7e8f370781ba2cedfd..16173d0949398d573002f0b84a47ce02fc8544fb 100644 (file)
@@ -24,6 +24,7 @@
 
 #include "support/convert.h"
 #include "support/docstream.h"
+#include "support/lassert.h"
 #include "support/lstrings.h"
 #include "support/textutils.h"
 
@@ -31,7 +32,6 @@
 #include <map>
 #include <functional>
 #include <QThreadStorage>
-#include <support/lassert.h>
 
 using namespace std;
 using namespace lyx::support;
@@ -185,7 +185,9 @@ bool XMLStream::closeFontTags() {
                tag_stack_.pop_back();
                // this shouldn't happen, since then the font tags
                // weren't in any other tag.
-               LASSERT(!tag_stack_.empty(), return true);
+//             LASSERT(!tag_stack_.empty(), return true);
+               if (tag_stack_.empty())
+                       return true;
                curtag = &tag_stack_.back();
        }
 
@@ -351,37 +353,44 @@ XMLStream &XMLStream::operator<<(xml::FontTag const &tag) {
 
 
 XMLStream &XMLStream::operator<<(xml::CR const &) {
+       clearTagDeque();
        os_ << from_ascii("\n");
        return *this;
 }
 
 
-bool XMLStream::isTagOpen(xml::StartTag const &stag) const {
+bool XMLStream::isTagOpen(xml::StartTag const &stag, int maxdepth) const {
        auto sit = tag_stack_.begin();
        auto sen = tag_stack_.cend();
-       for (; sit != sen; ++sit)
+       for (; sit != sen && maxdepth != 0; ++sit) {
                if (**sit == stag)
                        return true;
+               maxdepth -= 1;
+       }
        return false;
 }
 
 
-bool XMLStream::isTagOpen(xml::EndTag const &etag) const {
+bool XMLStream::isTagOpen(xml::EndTag const &etag, int maxdepth) const {
        auto sit = tag_stack_.begin();
        auto sen = tag_stack_.cend();
-       for (; sit != sen; ++sit)
+       for (; sit != sen && maxdepth != 0; ++sit) {
                if (etag == **sit)
                        return true;
+               maxdepth -= 1;
+       }
        return false;
 }
 
 
-bool XMLStream::isTagPending(xml::StartTag const &stag) const {
+bool XMLStream::isTagPending(xml::StartTag const &stag, int maxdepth) const {
        auto sit = pending_tags_.begin();
        auto sen = pending_tags_.cend();
-       for (; sit != sen; ++sit)
+       for (; sit != sen && maxdepth != 0; ++sit) {
                if (**sit == stag)
                        return true;
+               maxdepth -= 1;
+       }
        return false;
 }
 
@@ -550,7 +559,7 @@ docstring const xml::uniqueID(docstring const & label)
 }
 
 
-docstring xml::cleanID(docstring const &orig)
+docstring xml::cleanID(docstring const & orig)
 {
        // The standard xml:id only allows letters,
        // digits, '-' and '.' in a name.
@@ -604,8 +613,7 @@ docstring xml::cleanID(docstring const &orig)
        if (mangle) {
                int & mangleID = tMangleID.localData();
                content += "-" + convert<docstring>(mangleID++);
-       } else if (isDigitASCII(content[content.size() - 1]))
-               content += ".";
+       }
 
        mangledNames[orig] = content;