docstring InsetHyperlink::screenLabel() const
{
+ // TODO: replace with unicode hyperlink character = U+1F517
docstring const temp = _("Hyperlink: ");
docstring url;
url += getParam("name");
- if (url.empty())
+ if (url.empty()) {
url += getParam("target");
- // elide if long
- if (url.length() > 30) {
- docstring end = url.substr(url.length() - 17, url.length());
- support::truncateWithEllipsis(url, 13);
- url += end;
+ // elide if long and no name was provided
+ if (url.length() > 30) {
+ docstring end = url.substr(url.length() - 17, url.length());
+ support::truncateWithEllipsis(url, 13);
+ url += end;
+ }
+ } else {
+ // elide if long (approx number of chars in line of article class)
+ if (url.length() > 80) {
+ docstring end = url.substr(url.length() - 67, url.length());
+ support::truncateWithEllipsis(url, 13);
+ url += end;
+ }
}
return temp + url;
}
if (!url.empty()) {
// Use URI/URL-style percent-encoded string (hexadecimal).
// We exclude some characters that must not be transformed
- // in hrefs (% # / :) or that we need to treat manually (\).
- url = to_percent_encoding(url, from_ascii("%#\\/:"));
+ // in hrefs: % # / : ? = & ! * ' ( ) ; @ + $ , [ ]
+ // or that we need to treat manually: \.
+ url = to_percent_encoding(url, from_ascii("%#\\/:?=&!*'();@+$,[]"));
// We handle \ manually since \\ is valid
for (size_t i = 0, pos;
(pos = url.find('\\', i)) != string::npos;