tex2lyx: support for hyperlinks

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40005 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Uwe Stöhr 2011-10-26 05:02:37 +00:00
parent f68b287be6
commit e8c0344791
3 changed files with 38 additions and 4 deletions

View 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

View 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}}

View 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)