ParaMonte MATLAB 3.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation.
hyperlink.m
Go to the documentation of this file.
1function str = hyperlink(url, label, msg)
2%HYPERLINK create a string that is displayable as hyperlink in Matlab console
3%
4% Usage examples:
5% fprintf('Search on %s\n', hyperlink('http://google.com','Google'));
6% fprintf(hyperlink('http://google.com','Google','Search on Google\n'));
7%
8% HYPERLINK converts the specified URL and text label into a string that is
9% displayed as a hyperlink in the Matlab console (Command Window).
10% In a deployed (compiled) program, the URL and text label (if different
11% from the URL) are displayed in a non-hyperlinked plain-text manner.
12% If the optional 3rd input argument (msg) is specified, then all instances of
13% the specified label within msg will be handled as above (hyperlinked etc.)
14%
15% IN:
16% url - (mandatory) URL of webpage or Matlab command (e.g., 'matlab:which(...')
17% label - (optional) text label of the hyperlink. Default: url
18% msg - (optional) string in which all label instances should be hyperlinked
19%
20% OUT:
21% str - string output
22
23% Copyright: Yair Altman 2020-
24%{
25% 15/01/20 - Initial version
26%}
27
28 error(nargchk(1,3,nargin)); %#ok<NCHKN> narginchk is only available in R2011b+
29 if nargin > 2 % msg was specified
30 % replace all instances of label within msg with corresponding hyperlink
31 str = strrep(msg, label, hyperlink(url,label));
32 return
33 end
34 if nargin < 2, label = url; end
35 isWebpage = strncmpi(url,'http',4);
36
37 % Only hyperlink in interactive Matlab sessions, not in a deployed program
38 if ~isdeployed % interactive Matlab session
39 if isWebpage % open in a web browser
40 str = ['<a href="matlab:web(''-browser'',''' url ''');">' label '</a>'];
41 else % Matlab command e.g. 'matlab:which(...'
42 str = ['<a href="' url '">' label '</a>'];
43 end
44 else % deployed (compiled)
45 if isWebpage && ~strcmp(label,url) % display label next to url
46 str = [label ' (' url ')'];
47 elseif isWebpage % text==url - display only the url
48 str = url;
49 else % Matlab command (not a webpage) - just display the label
50 str = label;
51 end
52 end
53end
function version(in silent)
Return a scalar MATLAB string containing the latest available ParaMonte MATLAB version newer than the...
function which(in vendor)
Return the a MATLAB string containing the path to the first mpiexec executable binary found in system...