mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-23 10:18:50 +00:00
47432f0259
JMarc, I haven't moved those latex bits into the ::latex method yet though. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6471 a592a061-630c-0410-9148-cb99ea01b6c8
114 lines
1.6 KiB
C
114 lines
1.6 KiB
C
/**
|
|
* \file sgml.C
|
|
* Copyright 2002 the LyX Team
|
|
* Read the file COPYING
|
|
*
|
|
* \author José Matos
|
|
* \author John Levon <levon@movementarian.org>
|
|
*/
|
|
|
|
#include <config.h>
|
|
|
|
#include "support/LOstream.h"
|
|
|
|
#include "paragraph.h"
|
|
#include "sgml.h"
|
|
|
|
using std::pair;
|
|
using std::make_pair;
|
|
using std::ostream;
|
|
using std::endl;
|
|
|
|
namespace sgml {
|
|
|
|
pair<bool, string> escapeChar(char c)
|
|
{
|
|
string str;
|
|
|
|
switch (c) {
|
|
case ' ':
|
|
return make_pair(true, string(" "));
|
|
break;
|
|
case '\0': // Ignore :-)
|
|
str.erase();
|
|
break;
|
|
case '&':
|
|
str = "&";
|
|
break;
|
|
case '<':
|
|
str = "<";
|
|
break;
|
|
case '>':
|
|
str = ">";
|
|
break;
|
|
case '$':
|
|
str = "$";
|
|
break;
|
|
case '#':
|
|
str = "#";
|
|
break;
|
|
case '%':
|
|
str = "%";
|
|
break;
|
|
case '[':
|
|
str = "[";
|
|
break;
|
|
case ']':
|
|
str = "]";
|
|
break;
|
|
case '{':
|
|
str = "{";
|
|
break;
|
|
case '}':
|
|
str = "}";
|
|
break;
|
|
case '~':
|
|
str = "˜";
|
|
break;
|
|
case '"':
|
|
str = """;
|
|
break;
|
|
case '\\':
|
|
str = "\";
|
|
break;
|
|
default:
|
|
str = c;
|
|
break;
|
|
}
|
|
return make_pair(false, str);
|
|
}
|
|
|
|
|
|
int openTag(ostream & os, Paragraph::depth_type depth,
|
|
bool mixcont, string const & latexname)
|
|
{
|
|
if (!latexname.empty() && latexname != "!-- --") {
|
|
if (!mixcont)
|
|
os << string(depth, ' ');
|
|
os << '<' << latexname << '>';
|
|
}
|
|
|
|
if (!mixcont)
|
|
os << endl;
|
|
|
|
return !mixcont;
|
|
}
|
|
|
|
|
|
int closeTag(ostream & os, Paragraph::depth_type depth,
|
|
bool mixcont, string const & latexname)
|
|
{
|
|
if (!latexname.empty() && latexname != "!-- --") {
|
|
if (!mixcont)
|
|
os << endl << string(depth, ' ');
|
|
os << "</" << latexname << '>';
|
|
}
|
|
|
|
if (!mixcont)
|
|
os << endl;
|
|
|
|
return !mixcont;
|
|
}
|
|
|
|
} // namespace sgml
|