]> git.lyx.org Git - lyx.git/blobdiff - src/tex2lyx/Parser.cpp
- tex2lyx/text.cpp:
[lyx.git] / src / tex2lyx / Parser.cpp
index 75eb5182033af6a2021df6972ddc18c4b035bf75..20f5058901e163d9ab7f54eece6a73b0b31e1cd3 100644 (file)
@@ -488,10 +488,7 @@ string const Parser::plainEnvironment(string const & name)
 
        ostringstream os;
        for (Token t = get_token(); good(); t = get_token()) {
-               if (t.cat() == catBegin) {
-                       putback();
-                       os << '{' << verbatim_item() << '}';
-               } else if (t.asInput() == "\\end") {
+               if (t.asInput() == "\\end") {
                        string const end = getArg('{', '}');
                        if (end == name)
                                return os.str();
@@ -505,6 +502,28 @@ string const Parser::plainEnvironment(string const & name)
 }
 
 
+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();