X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ftex2lyx%2FParser.cpp;h=20f5058901e163d9ab7f54eece6a73b0b31e1cd3;hb=8e72135a3f6a2a3dc043c9a4212e418dfaf12e0d;hp=c48301207a447ec0e5593c64fea0e2b39881a2c0;hpb=3f8a6154772080251d57ead184c5ccfcdb9d23ae;p=lyx.git diff --git a/src/tex2lyx/Parser.cpp b/src/tex2lyx/Parser.cpp index c48301207a..20f5058901 100644 --- a/src/tex2lyx/Parser.cpp +++ b/src/tex2lyx/Parser.cpp @@ -481,6 +481,49 @@ string const Parser::verbatimEnvironment(string const & name) } +string const Parser::plainEnvironment(string const & name) +{ + if (!good()) + return string(); + + ostringstream os; + for (Token t = get_token(); good(); t = get_token()) { + if (t.asInput() == "\\end") { + string const end = getArg('{', '}'); + if (end == name) + return os.str(); + else + os << "\\end{" << end << '}'; + } else + os << t.asInput(); + } + cerr << "unexpected end of input" << endl; + return os.str(); +} + + +string const Parser::plainCommand(char left, char right, string const & name) +{ + if (!good()) + return string(); + // check if first token is really the start character + Token tok = get_token(); + if (tok.character() != left) { + cerr << "first character does not match start character of command \\" << name << endl; + return string(); + } + ostringstream os; + for (Token t = get_token(); good(); t = get_token()) { + if (t.character() == right) { + return os.str(); + } else + os << t.asInput(); + } + cerr << "unexpected end of input" << endl; + return os.str(); +} + + void Parser::tokenize_one() { catInit();