mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-07 12:32:26 +00:00
e506fc5915
stick to LyX naming convention git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8120 a592a061-630c-0410-9148-cb99ea01b6c8
136 lines
2.2 KiB
C
136 lines
2.2 KiB
C
/**
|
|
* \file sgml.C
|
|
* This file is part of LyX, the document processor.
|
|
* Licence details can be found in the file COPYING.
|
|
*
|
|
* \author José Matos
|
|
* \author John Levon
|
|
*
|
|
* Full author contact details are available in file CREDITS.
|
|
*/
|
|
|
|
#include <config.h>
|
|
|
|
#include "support/std_ostream.h"
|
|
|
|
#include "paragraph.h"
|
|
#include "sgml.h"
|
|
|
|
using std::endl;
|
|
using std::make_pair;
|
|
|
|
using std::ostream;
|
|
using std::pair;
|
|
using std::string;
|
|
|
|
|
|
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;
|
|
}
|
|
|
|
|
|
unsigned int closeEnvTags(ostream & os, bool mixcont,
|
|
string const & environment_inner_depth,
|
|
lyx::depth_type total_depth)
|
|
{
|
|
unsigned int lines = 0;
|
|
if (environment_inner_depth != "!-- --") {
|
|
string item_name= "listitem";
|
|
lines += closeTag(os, total_depth, mixcont, item_name);
|
|
if (environment_inner_depth == "varlistentry")
|
|
lines += closeTag(os, total_depth, mixcont,
|
|
environment_inner_depth);
|
|
}
|
|
return lines;
|
|
}
|
|
|
|
|
|
} // namespace sgml
|