From 04eb1d59a21d905262ab7abab83691bad30de680 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Uwe=20St=C3=B6hr?= Date: Thu, 27 Oct 2011 12:49:29 +0000 Subject: [PATCH] backporting tex2lyx: the support for \href git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_2_0_X@40033 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/tex2lyx/TODO.txt | 1 - src/tex2lyx/text.cpp | 24 ++++++++++++++++++++++++ status.20x | 4 +++- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/tex2lyx/TODO.txt b/src/tex2lyx/TODO.txt index 5b40782073..42d62a31b1 100644 --- a/src/tex2lyx/TODO.txt +++ b/src/tex2lyx/TODO.txt @@ -32,7 +32,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 312 rotfloat.sty InsetFloat diff --git a/src/tex2lyx/text.cpp b/src/tex2lyx/text.cpp index 9bb5ae0a19..e707299402 100644 --- a/src/tex2lyx/text.cpp +++ b/src/tex2lyx/text.cpp @@ -2453,6 +2453,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) diff --git a/status.20x b/status.20x index b03d8cac41..f2d054cc62 100644 --- a/status.20x +++ b/status.20x @@ -46,7 +46,7 @@ What's new - the setting of the document-wide background color and text color (\color, \pagecolor), the background color of shaded boxes and the - text color of greyed-out notes is now recognized + text color of greyed-out notes are now recognized - phantom spaces are recognized (\phantom, \hphanton, \vphantom) @@ -56,6 +56,8 @@ What's new - all types of underlined or striked out text are recognized +- hyperlinks are recognized (\href) + * USER INTERFACE -- 2.39.5