tex2lyx support for english quotes; revert the layout format change because we are not ready for that yet

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7422 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jean-Marc Lasgouttes 2003-07-28 15:45:41 +00:00
parent 2d558192af
commit 8ea43a75e2
7 changed files with 59 additions and 16 deletions

View File

@ -5,6 +5,8 @@
2003-07-28 Jean-Marc Lasgouttes <lasgouttes@lyx.org> 2003-07-28 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
* insetquotes.C: document a bit the format
* insettabular.C (write): remove extra space * insettabular.C (write): remove extra space
2003-07-28 Martin Vermeer <martin.vermeer@hut.fi> 2003-07-28 Martin Vermeer <martin.vermeer@hut.fi>

View File

@ -37,7 +37,15 @@ using std::auto_ptr;
namespace { namespace {
// codes used to read/write quotes to LyX files /* codes used to read/write quotes to LyX files
* e ``english''
* s ''spanish''
* g ,,german``
* p ,,polish''
* f <<french>>
* a >>danish<<
*/
char const * const language_char = "esgpfa"; char const * const language_char = "esgpfa";
char const * const side_char = "lr" ; char const * const side_char = "lr" ;
char const * const times_char = "sd"; char const * const times_char = "sd";

View File

@ -1,3 +1,11 @@
2003-07-28 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
* text.C:
* tex2lyx.C:
* preamble.C:
* table.C: \begin_layout -> \layout. We are not quite ready for
that yet
2003-07-28 José Matos <jamatos@lyx.org> 2003-07-28 José Matos <jamatos@lyx.org>
* text.C: * text.C:
@ -8,7 +16,10 @@
2003-07-28 Jean-Marc Lasgouttes <lasgouttes@lyx.org> 2003-07-28 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
* text.C (parse_text): read environment from layout file too. Now, * text.C (parse_text): read environment from layout file too. Now,
all layout entries are supported (but many hacks remain) all layout entries are supported (but many hacks remain); note
that the nesting support is broken and will have to be completely
redone
(parse_text): basic support for english double quotes
* table.C (handle_tabular): make the output more similar to LyX * table.C (handle_tabular): make the output more similar to LyX
and fix a little and fix a little

View File

@ -135,7 +135,7 @@ void handle_package(string const & name, string const & options)
void end_preamble(ostream & os, LyXTextClass const & textclass) void end_preamble(ostream & os, LyXTextClass const & /*textclass*/)
{ {
os << "# tex2lyx 0.0.3 created this file\n" os << "# tex2lyx 0.0.3 created this file\n"
<< "\\lyxformat 224\n" << "\\lyxformat 224\n"
@ -166,7 +166,7 @@ void end_preamble(ostream & os, LyXTextClass const & textclass)
<< "\\papersides " << h_papersides << "\n" << "\\papersides " << h_papersides << "\n"
<< "\\paperpagestyle " << h_paperpagestyle << "\n" << "\\paperpagestyle " << h_paperpagestyle << "\n"
<< "\\tracking_changes " << h_tracking_changes << "\n" << "\\tracking_changes " << h_tracking_changes << "\n"
<< "\\end_header\n\n\\begin_layout Standard\n"; << "\\end_header\n\n\\layout Standard\n";
} }

View File

@ -490,7 +490,7 @@ void handle_tabular(Parser & p, ostream & os,
os << " usebox=\"none\"" os << " usebox=\"none\""
<< ">" << ">"
<< "\n\\begin_inset Text" << "\n\\begin_inset Text"
<< "\n\n\\begin_layout Standard\n\n" << "\n\n\\layout Standard\n\n"
<< cell.content << cell.content
<< "\n\\end_inset \n" << "\n\\end_inset \n"
<< "</cell>\n"; << "</cell>\n";

View File

@ -121,7 +121,7 @@ void clean_layouts(istream & is, ostream & os)
bool eating = false; bool eating = false;
while (getline(is, line)) { while (getline(is, line)) {
string tline = trim(line, " "); string tline = trim(line, " ");
if (line.substr(0, 8) == "\\begin_layout ") { if (line.substr(0, 8) == "\\layout ") {
//cerr << "layout: " << line << "\n"; //cerr << "layout: " << line << "\n";
last = line; last = line;
eating = true; eating = true;

View File

@ -100,7 +100,7 @@ void skip_braces(Parser & p)
void handle_ert(ostream & os, string const & s) void handle_ert(ostream & os, string const & s)
{ {
begin_inset(os, "ERT"); begin_inset(os, "ERT");
os << "\nstatus Collapsed\n\n\\begin_layout Standard\n\n"; os << "\nstatus Collapsed\n\n\\layout Standard\n\n";
for (string::const_iterator it = s.begin(), et = s.end(); it != et; ++it) { for (string::const_iterator it = s.begin(), et = s.end(); it != et; ++it) {
if (*it == '\\') if (*it == '\\')
os << "\n\\backslash \n"; os << "\n\\backslash \n";
@ -115,7 +115,7 @@ void handle_par(ostream & os)
{ {
if (active_environments.empty()) if (active_environments.empty())
return; return;
os << "\n\\begin_layout "; os << "\n\\layout ";
string s = active_environment(); string s = active_environment();
if (s == "document" || s == "table") if (s == "document" || s == "table")
os << "Standard\n\n"; os << "Standard\n\n";
@ -156,19 +156,19 @@ void output_layout(ostream & os, LyXLayout_ptr const & layout_ptr,
Parser & p, bool outer, LyXTextClass const & textclass) Parser & p, bool outer, LyXTextClass const & textclass)
{ {
string name = layout_ptr->name(); string name = layout_ptr->name();
os << "\n\n\\begin_layout " << name << "\n\n"; os << "\n\n\\layout " << name << "\n\n";
if (layout_ptr->optionalargs > 0) { if (layout_ptr->optionalargs > 0) {
string s; string s;
if (p.next_token().character() == '[') { if (p.next_token().character() == '[') {
p.get_token(); // eat '[' p.get_token(); // eat '['
begin_inset(os, "OptArg\n"); begin_inset(os, "OptArg\n");
os << "collapsed true\n\n\\begin_layout Standard\n\n"; os << "collapsed true\n\n\\layout Standard\n\n";
parse_text(p, os, FLAG_BRACK_LAST, outer, textclass); parse_text(p, os, FLAG_BRACK_LAST, outer, textclass);
end_inset(os); end_inset(os);
} }
} }
parse_text(p, os, FLAG_ITEM, outer, textclass); parse_text(p, os, FLAG_ITEM, outer, textclass);
os << "\n\n\\begin_layout Standard\n\n"; os << "\n\n\\layout Standard\n\n";
} }
} // anonymous namespace } // anonymous namespace
@ -230,6 +230,28 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
else if (t.cat() == catSuper || t.cat() == catSub) else if (t.cat() == catSuper || t.cat() == catSub)
cerr << "catcode " << t << " illegal in text mode\n"; cerr << "catcode " << t << " illegal in text mode\n";
// Basic support for english quotes. This should be
// extended to other quotes, but is not so easy (a
// left english quote is the same as a right german
// quote...)
else if (t.asInput() == "`"
&& p.next_token().asInput() == "`") {
begin_inset(os, "Quotes ");
os << "eld";
end_inset(os);
p.get_token();
skip_braces(p);
}
else if (t.asInput() == "'"
&& p.next_token().asInput() == "'") {
begin_inset(os, "Quotes ");
os << "erd";
end_inset(os);
p.get_token();
skip_braces(p);
}
else if (t.cat() == catLetter || else if (t.cat() == catLetter ||
t.cat() == catSpace || t.cat() == catSpace ||
t.cat() == catOther || t.cat() == catOther ||
@ -327,7 +349,7 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
} }
os << "wide " << tostr(is_starred) os << "wide " << tostr(is_starred)
<< "\ncollapsed false\n\n" << "\ncollapsed false\n\n"
<< "\\begin_layout Standard\n"; << "\\layout Standard\n";
parse_text(p, os, FLAG_END, outer, parse_text(p, os, FLAG_END, outer,
textclass); textclass);
end_inset(os); end_inset(os);
@ -344,7 +366,7 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
|| s == "lyxlist"; || s == "lyxlist";
if (deeper) if (deeper)
os << "\n\\begin_deeper"; os << "\n\\begin_deeper";
os << "\n\\begin_layout " << layout_ptr->name() os << "\n\\layout " << layout_ptr->name()
<< "\n\n"; << "\n\n";
switch (layout_ptr->latextype) { switch (layout_ptr->latextype) {
case LATEX_LIST_ENVIRONMENT: case LATEX_LIST_ENVIRONMENT:
@ -438,7 +460,7 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
else if (t.cs() == "footnote") { else if (t.cs() == "footnote") {
begin_inset(os, "Foot\n"); begin_inset(os, "Foot\n");
os << "collapsed true\n\n\\begin_layout Standard\n\n"; os << "collapsed true\n\n\\layout Standard\n\n";
parse_text(p, os, FLAG_ITEM, false, textclass); parse_text(p, os, FLAG_ITEM, false, textclass);
end_inset(os); end_inset(os);
} }
@ -453,7 +475,7 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
else if (t.cs() == "marginpar") { else if (t.cs() == "marginpar") {
begin_inset(os, "Marginal\n"); begin_inset(os, "Marginal\n");
os << "collapsed true\n\n\\begin_layout Standard\n\n"; os << "collapsed true\n\n\\layout Standard\n\n";
parse_text(p, os, FLAG_ITEM, false, textclass); parse_text(p, os, FLAG_ITEM, false, textclass);
end_inset(os); end_inset(os);
} }
@ -523,7 +545,7 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
} }
else if (t.cs() == "bibitem") { else if (t.cs() == "bibitem") {
os << "\n\\begin_layout Bibliography\n\\bibitem "; os << "\n\\layout Bibliography\n\\bibitem ";
os << p.getOpt(); os << p.getOpt();
os << '{' << p.verbatim_item() << '}' << "\n"; os << '{' << p.verbatim_item() << '}' << "\n";
} }