#include "support/convert.h"
#include "support/docstream.h"
+#include "support/lassert.h"
#include "support/lstrings.h"
#include "support/textutils.h"
#include <map>
#include <functional>
#include <QThreadStorage>
-#include <support/lassert.h>
using namespace std;
using namespace lyx::support;
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();
}
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;
}
}
-docstring xml::cleanID(docstring const &orig)
+docstring xml::cleanID(docstring const & orig)
{
// The standard xml:id only allows letters,
// digits, '-' and '.' in a name.
if (mangle) {
int & mangleID = tMangleID.localData();
content += "-" + convert<docstring>(mangleID++);
- } else if (isDigitASCII(content[content.size() - 1]))
- content += ".";
+ }
mangledNames[orig] = content;