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"
25 using lyx::support::subst;
31 InsetUrl::InsetUrl(InsetCommandParams const & p)
32 : InsetCommand(p, "url")
36 string const InsetUrl::getScreenLabel(Buffer const &) const
39 if (getCmdName() == "url")
42 temp = _("HtmlUrl: ");
46 if (!getOptions().empty())
52 if (url.length() > 30) {
53 url = url.substr(0, 10) + "..."
54 + url.substr(url.length() - 17, url.length());
60 int InsetUrl::latex(Buffer const &, ostream & os,
61 OutputParams const & runparams) const
63 if (!getOptions().empty())
64 os << getOptions() + ' ';
65 if (runparams.moving_arg)
67 os << "\\url{" << getContents() << '}';
72 int InsetUrl::plaintext(Buffer const &, ostream & os,
73 OutputParams const &) const
75 if (getOptions().empty())
76 os << '[' << getContents() << ']';
78 os << '[' << getContents() << "||" << getOptions() << ']';
83 int InsetUrl::docbook(Buffer const &, ostream & os,
84 OutputParams const &) const
86 os << "<ulink url=\"" << subst(getContents(),"&","&")
87 << "\">" << getOptions() << "</ulink>";
92 int InsetUrl::textString(Buffer const & buf, ostream & os,
93 OutputParams const & op) const
95 return plaintext(buf, os, op);
99 void InsetUrl::validate(LaTeXFeatures & features) const
101 features.require("url");