]> git.lyx.org Git - lyx.git/blobdiff - src/sgml.C
fix mathed crash
[lyx.git] / src / sgml.C
index 35b4b018dcad3f774a9cf62179ce7b5f3797b957..7ebaf187a694782a4d7f21052c1fc83b7372b79a 100644 (file)
@@ -1,36 +1,36 @@
 /**
  * \file sgml.C
- * Copyright 2002 the LyX Team
- * Read the file COPYING
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
  *
  * \author José Matos
- * \author John Levon <levon@movementarian.org>
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS.
  */
 
 #include <config.h>
-#include "support/LOstream.h"
+
+#include "support/std_ostream.h"
+
 #include "paragraph.h"
 #include "sgml.h"
-using std::pair;
+
+using std::endl;
 using std::make_pair;
+
 using std::ostream;
-using std::endl;
+using std::pair;
+using std::string;
+
+
 namespace sgml {
 
 pair<bool, string> escapeChar(char c)
 {
        string str;
+
        switch (c) {
-       case Paragraph::META_HFILL:
-               break;
-       case Paragraph::META_NEWLINE:
-               str = '\n';
-               break;
        case ' ':
                return make_pair(true, string(" "));
                break;
@@ -83,14 +83,18 @@ pair<bool, string> escapeChar(char c)
        return make_pair(false, str);
 }
 
+
 int openTag(ostream & os, Paragraph::depth_type depth,
-           bool mixcont, string const & latexname)
+           bool mixcont, string const & latexname,
+               string const & latexparam)
 {
        if (!latexname.empty() && latexname != "!-- --") {
                if (!mixcont)
-                       os << string(" ", depth);
-               os << "<" << latexname << ">";
+                       os << string(depth, ' ');
+               os << '<' << latexname;
+               if (!latexparam.empty())
+                       os << " " << latexparam;
+               os << '>';
        }
 
        if (!mixcont)
@@ -105,8 +109,8 @@ int closeTag(ostream & os, Paragraph::depth_type depth,
 {
        if (!latexname.empty() && latexname != "!-- --") {
                if (!mixcont)
-                       os << endl << string(" ", depth);
-               os << "</" << latexname << ">";
+                       os << endl << string(depth, ' ');
+               os << "</" << latexname << '>';
        }
 
        if (!mixcont)
@@ -115,4 +119,21 @@ int closeTag(ostream & os, Paragraph::depth_type depth,
        return !mixcont;
 }
 
+
+unsigned int closeEnvTags(ostream & os, bool mixcont,
+                       string const & environment_inner_depth,
+                       string const & itemtag,
+                       lyx::depth_type total_depth)
+{
+       unsigned int lines = 0;
+       if (environment_inner_depth != "!-- --") {
+               lines += closeTag(os, total_depth, mixcont, itemtag);
+               if (!environment_inner_depth.empty())
+                       lines += closeTag(os, total_depth, mixcont,
+                               environment_inner_depth);
+       }
+       return lines;
+}
+
+
 } // namespace sgml