3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS.
15 #include "dispatchresult.h"
16 #include "funcrequest.h"
17 #include "LaTeXFeatures.h"
19 #include "outputparams.h"
21 #include "support/lstrings.h"
23 #include "support/std_ostream.h"
26 using lyx::support::subst;
32 InsetUrl::InsetUrl(InsetCommandParams const & p)
33 : InsetCommand(p, "url")
37 docstring const InsetUrl::getScreenLabel(Buffer const &) const
39 docstring const temp =
40 (getCmdName() == "url") ? _("Url: ") : _("HtmlUrl: ");
44 if (!getOptions().empty())
50 if (url.length() > 30) {
51 url = url.substr(0, 10) + "..."
52 + url.substr(url.length() - 17, url.length());
55 return temp + lyx::from_utf8(url);
59 int InsetUrl::latex(Buffer const &, ostream & os,
60 OutputParams const & runparams) const
62 if (!getOptions().empty())
63 os << getOptions() + ' ';
64 if (runparams.moving_arg)
66 os << "\\url{" << getContents() << '}';
71 int InsetUrl::plaintext(Buffer const &, lyx::odocstream & os,
72 OutputParams const &) const
75 os << '[' << lyx::from_utf8(getContents());
76 if (getOptions().empty())
80 os << "||" << lyx::from_utf8(getOptions()) << ']';
85 int InsetUrl::docbook(Buffer const &, ostream & os,
86 OutputParams const &) const
88 os << "<ulink url=\"" << subst(getContents(),"&","&")
89 << "\">" << getOptions() << "</ulink>";
94 int InsetUrl::textString(Buffer const & buf, lyx::odocstream & os,
95 OutputParams const & op) const
97 return plaintext(buf, os, op);
101 void InsetUrl::validate(LaTeXFeatures & features) const
103 features.require("url");