]> git.lyx.org Git - lyx.git/commitdiff
tex2lyx/text.cpp: - support for LyX 1.6's hyperlink inset (\href)
authorUwe Stöhr <uwestoehr@web.de>
Sat, 24 Nov 2007 20:07:05 +0000 (20:07 +0000)
committerUwe Stöhr <uwestoehr@web.de>
Sat, 24 Nov 2007 20:07:05 +0000 (20:07 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21765 a592a061-630c-0410-9148-cb99ea01b6c8

src/tex2lyx/text.cpp

index ccca73386c82c9ce884a3ffbd25badd075f7106b..f30c17ebd92dfe4162118123be3cffeccac9d23f 100644 (file)
@@ -33,7 +33,7 @@
 
 using std::cerr;
 using std::endl;
-
+using std::find;
 using std::map;
 using std::ostream;
 using std::ostringstream;
@@ -104,7 +104,7 @@ string parse_text_snippet(Parser & p, unsigned flags, const bool outer,
 }
 
 
-char const * const known_latex_commands[] = { "ref", "cite", "label", "href",
+char const * const known_latex_commands[] = { "ref", "cite", "label",
  "index", "printindex", "pageref", "url", "vref", "vpageref", "prettyref",
  "eqref", 0 };
 
@@ -2213,6 +2213,32 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
                        skip_braces(p); // eat {}
                }
 
+               else if (t.cs() == "href") {
+                       context.check_layout(os);
+                       begin_inset(os, "CommandInset ");
+                       os << t.cs() << "\n";
+                       os << "LatexCommand " << t.cs() << "\n";
+                       bool erase = false;
+                       size_t pos;
+                       // the first argument is "type:target", "type:" is optional
+                       // the second argument the name
+                       string href_target = subst(p.verbatim_item(), "\n", " ");
+                       string href_name = subst(p.verbatim_item(), "\n", " ");
+                       string href_type;
+                       // serach for the ":" to divide type from target
+                       if ((pos = href_target.find(":", 0)) != string::npos){
+                               href_type = href_target;
+                               href_type.erase(pos + 1, href_type.length());
+                               href_target.erase(0, pos + 1);
+                           erase = true;                                                                                       
+                       }
+                       os << "name " << '"' << href_name << '"' << "\n";
+                       os << "target " << '"' << href_target << '"' << "\n";
+                       if(erase)
+                               os << "type " << '"' << href_type << '"' << "\n";
+                       end_inset(os);
+               }
+
                else if (t.cs() == "input" || t.cs() == "include"
                         || t.cs() == "verbatiminput") {
                        string name = '\\' + t.cs();