*** empty log message ***

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6126 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2003-02-12 14:32:17 +00:00
parent 6da832cd20
commit 789041753c
2 changed files with 50 additions and 19 deletions

View File

@ -55,7 +55,7 @@ const char * known_fontsizes[] = { "10pt", "11pt", "12pt", 0 };
const char * known_math_envs[] = {"equation", "eqnarray", "eqnarray*", const char * known_math_envs[] = {"equation", "eqnarray", "eqnarray*",
"align", 0}; "align", "align*", 0};
// some ugly stuff // some ugly stuff
@ -187,6 +187,7 @@ bool is_heading(string const & name)
bool is_latex_command(string const & name) bool is_latex_command(string const & name)
{ {
return return
name == "ref" ||
name == "cite" || name == "cite" ||
name == "label" || name == "label" ||
name == "index" || name == "index" ||
@ -276,7 +277,7 @@ void handle_package(string const & name, string const & options)
} }
void handle_table(Parser & p, ostream & os) void handle_table(Parser &, ostream &)
{ {
// \begin{table} has been read // \begin{table} has been read
//parse(end //parse(end
@ -554,9 +555,11 @@ void parse(Parser & p, ostream & os, unsigned flags, mode_type mode)
p.verbatimItem(); // swallow next arg p.verbatimItem(); // swallow next arg
handle_table(p, os); handle_table(p, os);
parse(p, os, FLAG_END, mode); parse(p, os, FLAG_END, mode);
} else { } else if (mode == MATH_MODE) {
os << "\\begin{" << name << "}"; os << "\\begin{" << name << "}";
parse(p, os, FLAG_END, mode); parse(p, os, FLAG_END, mode);
} else {
parse(p, os, FLAG_END, mode);
} }
} }
@ -568,22 +571,21 @@ void parse(Parser & p, ostream & os, unsigned flags, mode_type mode)
p.error("\\end{" + name + "} does not match \\begin{" p.error("\\end{" + name + "} does not match \\begin{"
+ curr_env() + "}"); + curr_env() + "}");
active_environments.pop(); active_environments.pop();
if (name == "document" || name == "abstract") if (is_math_env(name)) {
;
else if (name == "table")
;
else if (name == "thebibliography")
;
else if (is_math_env(name)) {
end_inset(os); end_inset(os);
os << "\\end{" << name << "}"; os << "\\end{" << name << "}";
} else } else if (mode == MATH_MODE) {
os << "\\end{" << name << "}"; os << "\\end{" << name << "}";
} else
;
return; return;
} }
p.error("found 'end' unexpectedly"); p.error("found 'end' unexpectedly");
} }
else if (t.cs() == "item")
handle_par(os);
else if (t.cs() == ")") { else if (t.cs() == ")") {
if (flags & FLAG_SIMPLE2) if (flags & FLAG_SIMPLE2)
return; return;
@ -681,10 +683,10 @@ void parse(Parser & p, ostream & os, unsigned flags, mode_type mode)
os << '}'; os << '}';
} }
else if (t.cs() == "emph" && mode == TEXT_MODE) { else if ((t.cs() == "emph" || t.cs() == "noun") && mode == TEXT_MODE) {
os << "\n\\emph on\n"; os << "\n\\" << t.cs() << " on\n";
parse(p, os, FLAG_ITEM, mode); parse(p, os, FLAG_ITEM, mode);
os << "\n\\emph default\n"; os << "\n\\" << t.cs() << " default\n";
} }
else if (is_latex_command(t.cs()) && mode == TEXT_MODE) { else if (is_latex_command(t.cs()) && mode == TEXT_MODE) {
@ -703,8 +705,33 @@ void parse(Parser & p, ostream & os, unsigned flags, mode_type mode)
os << '{' << p.getArg('{','}') << '}' << "\n\n"; os << '{' << p.getArg('{','}') << '}' << "\n\n";
} }
else else if (t.cs() == "textasciitilde")
(in_preamble ? h_preamble : os) << t.asInput(); os << '~';
else if (t.cs() == "_" && mode == TEXT_MODE)
os << '_';
else if (t.cs() == "&" && mode == TEXT_MODE)
os << '&';
else {
if (mode == MATH_MODE)
os << t.asInput();
else if (in_preamble)
h_preamble << t.asInput();
else {
// heuristic: read up to next non-nested space
string s = t.asInput();
string z = p.verbatimItem();
while (p.good() && z != " " && z.size()) {
//cerr << "read: " << z << endl;
s += z;
z = p.verbatimItem();
}
cerr << "found ERT: " << s << endl;
handle_ert(os, s + ' ');
}
}
if (flags & FLAG_LEAVE) { if (flags & FLAG_LEAVE) {
flags &= ~FLAG_LEAVE; flags &= ~FLAG_LEAVE;

View File

@ -302,9 +302,11 @@ string Parser::verbatimOption()
string Parser::verbatimItem() string Parser::verbatimItem()
{ {
string res; if (!good())
error("stream bad");
if (nextToken().cat() == catBegin) { if (nextToken().cat() == catBegin) {
Token t = getToken(); Token t = getToken(); // skip brace
string res;
for (Token t = getToken(); t.cat() != catEnd && good(); t = getToken()) { for (Token t = getToken(); t.cat() != catEnd && good(); t = getToken()) {
if (t.cat() == catBegin) { if (t.cat() == catBegin) {
putback(); putback();
@ -313,6 +315,8 @@ string Parser::verbatimItem()
else else
res += t.asInput(); res += t.asInput();
} }
return res;
} }
return res; return getToken().asInput();
} }