0001 function citeme(fname)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031 if ischar(fname) && strcmp(fname, 'UNIT_TEST')
0032 citeme(mfilename);
0033 return;
0034 end
0035 cm = warning('query','EIDORS:CITEME');
0036 cf = warning('query',sprintf('EIDORS:CITEME:%s',fname));
0037 if strcmp(cm.state, 'off') || strcmp(cf.state, 'off');
0038 return
0039 end
0040 h = help(fname);
0041 s = strfind(h,'CITATION_REQUEST:');
0042 if isempty(s), return, end;
0043 T = textscan(h(s:end),'%s','delimiter','\n');
0044 T = T{1};
0045 line = 2;
0046 lastfld = [];
0047 cite = empty_cite;
0048 while line <= numel(T) && ~isempty(strtrim(T{line}))
0049 [tok rest] = strtok(T{line});
0050 if strfind(tok,':');
0051 fld = lower(tok(1:end-1));
0052 cite.(fld) = strtrim(rest);
0053 lastfld = fld;
0054 elseif ~isempty(lastfld)
0055 cite.(lastfld) = sprintf('%s %s%s', cite.(lastfld), tok, rest);
0056 else
0057 error('Error processing citation request of file %s',fname);
0058 end
0059 line = line + 1;
0060 end
0061 flds = {'link','pdf','pubmed','arxiv','doi'};
0062 for i = 1:numel(flds)
0063 cite.(flds{i})(isspace(cite.(flds{i}))) = [];
0064 end
0065 pretty_print(cite,fname);
0066
0067 function str = pretty_print(cite, fname)
0068 str = sprintf('%s (%s) "%s"',...
0069 cite.author,cite.year,cite.title);
0070
0071 if ~isempty(cite.link)
0072 str = sprintf('%s <a href="matlab: web %s -browser">%s</a>%s', str, cite.link, cite.journal);
0073 else
0074 str = sprintf('%s %s',str, cite.journal);
0075 end
0076
0077 if ~isempty(cite.vol)
0078 str = sprintf('%s %s',str,cite.vol);
0079 end
0080 if ~isempty(cite.num)
0081 if ~isempty(cite.vol)
0082 str = sprintf('%s(%s)',str, cite.num);
0083 else
0084 str = sptrinf('%s %s',str, cite.num);
0085 end
0086 end
0087 if ~isempty(cite.page)
0088 str = sprintf('%s: %s',str, cite.page);
0089 end
0090 if ~isempty(cite.pdf)
0091 str = sprintf('%s <a href="matlab: web %s -browser">PDF</a>',str, cite.pdf);
0092 end
0093 if ~isempty(cite.doi)
0094 str = sprintf('%s DOI:<a href="matlab: web http://dx.doi.org/%s -browser">%s</a>',...
0095 str, cite.doi,cite.doi);
0096 end
0097 if ~isempty(cite.pubmed)
0098 str = sprintf('%s PubMed:<a href="matlab: web http://www.ncbi.nlm.nih.gov/pubmed/%s -browser">%s</a>',...
0099 str, cite.doi,cite.doi);
0100 end
0101
0102 if ~isempty(cite.arxiv)
0103 str = sprintf('%s arXiv:<a href="matlab: web http://arxiv.org/abs/%s -browser">%s</a>',...
0104 str, cite.doi,cite.doi);
0105 end
0106
0107 str = strtrim(str);
0108 sp = strfind(str,' ');
0109 tp1 = strfind(str,'<');
0110 tp2 = strfind(str,'>');
0111 sp = [sp length(str)];
0112
0113 rsp = sp;
0114 idx = false(size(sp));
0115 for i = 1:length(tp1)
0116 nidx = rsp>tp1(i) & rsp<tp2(i);
0117 idx = idx | nidx;
0118 sp(rsp>tp1(i)) = sp(rsp>tp1(i)) - (tp2(i) + 2- tp1(i));
0119 end
0120 sp(idx) = [];
0121 rsp(idx) = [];
0122
0123 [jnk, nl] = unique(floor(sp/82),'last');
0124 nl = rsp(nl);
0125 nl(nl==length(str)) = [];
0126 str(nl) = sprintf('\n');
0127
0128 ws = warning('off', 'backtrace');
0129 idstr = sprintf('EIDORS:CITEME:%s',fname);
0130 stars(1:80) = '=';
0131 msg = sprintf('\n%s\nIf you use %s in a publication, please cite:\n', stars,upper(fname));
0132 warning(idstr,[msg str '\n' stars]);
0133 if 0
0134 disp('Press any key to continue...');
0135 pause
0136 else
0137 fprintf('Continuing in ');
0138 for i = 2:-1:1
0139 fprintf('\b%d',i);
0140 pause(1);
0141 end
0142 fprintf('\b0\n');
0143 end
0144 warning(ws.state, 'backtrace');
0145 if ~strcmp(fname,'citeme')
0146 warning('off',idstr);
0147 end
0148
0149 function cite = empty_cite
0150 cite.author = [];
0151 cite.year = [];
0152 cite.journal= [];
0153 cite.title = [];
0154 cite.vol = [];
0155 cite.num = [];
0156 cite.page = [];
0157 cite.link = [];
0158 cite.pdf = [];
0159 cite.doi = [];
0160 cite.pubmed = [];
0161 cite.arxiv = [];