+
+ // The characters in chars_url[] need to be escaped in the url
+ // field because otherwise LaTeX will fail when the hyperlink is
+ // within an argument of another command, e.g. in a \footnote. It
+ // is important that they are escaped as "\#" and not as "\#{}".
+ // FIXME this is not necessary in outside of commands.
+ for (int k = 0; k < 2; k++)
+ for (size_t i = 0, pos;
+ (pos = url.find(chars_url[k], i)) != string::npos;
+ i = pos + 2)
+ url.replace(pos, 1, from_ascii("\\") + chars_url[k]);
+
+ // add "http://" when the type is web (type = empty)
+ // and no "://" or "run:" is given
+ docstring type = getParam("type");
+ if (url.find(from_ascii("://")) == string::npos
+ && url.find(from_ascii("run:")) == string::npos
+ && type.empty())
+ url = from_ascii("http://") + url;
+
+ } // end if (!url.empty())
+
+ if (!name.empty()) {
+ name = params().prepareCommand(runparams, name,
+ ParamInfo::HANDLING_LATEXIFY);
+ // replace the tilde by the \sim character as suggested in the
+ // LaTeX FAQ for URLs
+ if (getParam("literal") != from_ascii("true")) {
+ docstring const sim = from_ascii("$\\sim$");