From 650c2a816cb6f04bb6b77d331b1e0df1f21dd0b8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Uwe=20St=C3=B6hr?= Date: Sat, 24 Nov 2007 20:07:05 +0000 Subject: [PATCH] tex2lyx/text.cpp: - support for LyX 1.6's hyperlink inset (\href) git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21765 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/tex2lyx/text.cpp | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/src/tex2lyx/text.cpp b/src/tex2lyx/text.cpp index ccca73386c..f30c17ebd9 100644 --- a/src/tex2lyx/text.cpp +++ b/src/tex2lyx/text.cpp @@ -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(); -- 2.39.2