]> git.lyx.org Git - features.git/commitdiff
tex2lyx: support for hyperlinks
authorUwe Stöhr <uwestoehr@web.de>
Wed, 26 Oct 2011 05:02:37 +0000 (05:02 +0000)
committerUwe Stöhr <uwestoehr@web.de>
Wed, 26 Oct 2011 05:02:37 +0000 (05:02 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40005 a592a061-630c-0410-9148-cb99ea01b6c8

src/tex2lyx/TODO.txt
src/tex2lyx/test/test-insets.tex
src/tex2lyx/text.cpp

index 39d78665d013fd690b136db7920fd0b5bf82bfeb..5ee9a922ac294cd09431fcb475437247b7484ef9 100644 (file)
@@ -31,7 +31,6 @@ Format LaTeX feature                        LyX feature
 290    wrapped tables                       InsetWrap
 292    japanese                             japanese-plain
 293    ?                                    InsetInfo
-299    hyperlink types                      InsetHyperlink
 309    \nocite                              InsetCitation
 310    \nocite{*}                           InsetBibtex
 316    subfig.sty (subfloats)               InsetFloat
index 040bd8c6291b1395173209982670c286ef529268..0aa90c45e9832ce7a2a4465b11375a27d3518790 100644 (file)
@@ -121,10 +121,21 @@ If you prefer verbatim input, you can choose
 between~\verbatiminput{foo} or~\verbatiminput*{foo}.
 
 
-\section{URL\index{URL}\nomenclature[www]{URL}{uniform resource locator}}
+\section{URLs and Hyperlinks\index{URL}\nomenclature[www]{URL}{uniform resource locator}}
 
-An URL: \url{http://www.lyx.org}
-\nomenclature{URL2}{uniform resource locator}
+An URL: \url{http://www.lyx.org} \nomenclature{URL2}{uniform resource locator}
+
+link:\href{http://www.test.test}{www.test.test}
+
+link2:\href{http://www.test.test}{http://www.test.test}
+
+mail:\href{mailto:www.test.test}{name}
+
+file:\href{file:www.test.test}{www.test.test}
+
+ftp:\href{ftp://www.test.test}{ftp://www.test.test}
+
+ftp2:\href{ftp://www.test.test}{www.test.test}
 
 
 \section{Lists\index{Lists}}
index 8a9951d3c713acad8f59ff05cb7c5987de10deee..db91970fb538c442d360b9994133ad6accdb067f 100644 (file)
@@ -2478,6 +2478,30 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
                        parse_text_in_inset(p, os, FLAG_ITEM, outer, context);
                        end_inset(os);
                }
+
+               else if (t.cs() == "href") {
+                       context.check_layout(os);
+                       string target = p.getArg('{', '}');
+                       string name = p.getArg('{', '}');
+                       string type;
+                       size_t i = target.find(':');
+                       if (i != string::npos) {
+                               type = target.substr(0, i + 1);
+                               if (type == "mailto:" || type == "file:")
+                                       target = target.substr(i + 1);
+                               // handle the case that name is equal to target, except of "http://"
+                               else if (target.substr(i + 3) == name && type == "http:")
+                                       target = name;
+                       }
+                       begin_command_inset(os, "href", "href");
+                       if (name != target)
+                               os << "name \"" << name << "\"\n";
+                       os << "target \"" << target << "\"\n";
+                       if (type == "mailto:" || type == "file:")
+                               os << "type \"" << type << "\"\n";
+                       end_inset(os);
+                       skip_spaces_braces(p);
+               }
                
                else if (t.cs() == "lyxline") {
                        // swallow size argument (it is not used anyway)