No BSD License  

Highlights from
htmltool

htmltool

by

 

The HTML Toolbox (HT) stores various crosslink information about Matlab programs using HTML.

totxref(fid,mdir,htmldir,filename,refm,ext)
function [] = totxref(fid,mdir,htmldir,filename,refm,ext)
% [] = totxref(fid,mdir,htmldir,filename,refm,ext)
% Reads the TOTAL MATLAB code in an m-file and
% inserts HTML links in every location in the text to
% a m-file name it finds. 
%
% INPUT PARAMETERS
%
% fid          = file pointer to the current HTML file containing
%                the relevant information about the m-file "filename"
% mdir         = current directory containing the
%                m-files you want to crosslink
% htmldir      = directory name containing all the html
%                files under mdir. Assumes it exists!!
% filename     = name of file WITH extension!
% refm         = string matrix of all functions in mdir
% ext          = extension for the files in refm (usually .htm)
%
% Copyright (c) 1996 B.K. Alsberg
%

loc_nam = [mdir,'\',filename];

fid2 = fopen(loc_nam,'r');

%% Sets the upper limit of characters on a line in the
%% m-file:
n = 150;
U = blanks(n);

%%% Start reading into a matrix ALL the comment AND command
%%% lines in the m-file

k=1;
while feof(fid2) ~= 1,
 str = fgetl(fid2);
 q = min(n,length(str));
 if q>0 & isstr(str) ==1,
%   U(k,1:q) = str;
% This is to ensure we have a comparable case for the
% characters by keeping all names in lower case:
    U(k,1:q) = lower(str(1:q));
 else
   U(k,:) = blanks(n);
 end;
   k=k+1;
end;

fclose(fid2);

[n1,m1]=size(U);
[n2,m2]=size(refm);

%%%%% We go to the mdir since we assume the %%%%%%%%%%
%%%%% html directory is below it            %%%%%%%%%%

cdstr = ['cd ',mdir];
eval(cdstr);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


fprintf(fid,'%s \n','<pre>');

for i = 1:n1

 tmpstr = deblank(U(i,:));

 for j = 1:n2
  strtmp = deblank(refm(j,:));
  q = length(strtmp);
  %%%% Here we remove the extension     %%%%%%%%%
  pos = findstr(strtmp,'.');
  if length(pos) >0,
    refstring = strtmp(1:pos-1);
  else
    refstring = strtmp;
  end;
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  if length(htmldir) > 0,
     filepointer = [htmldir,'\',refstring,ext];
  else
     filepointer = [refstring,ext];
  end;
  %%% Here we construct the HTML string used in file links: %%
  href = ['<A HREF ="',filepointer,'">',refstring,'</A>'];
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  tmpstr = strrep(tmpstr,refstring,href);
  clear pos
 end;
  fprintf(fid,'%s \n',tmpstr);
  clear tmpstr
end;

fprintf(fid,'%s \n','</pre>');


Contact us