Code covered by the BSD License  

Highlights from
publish2latex

image thumbnail

publish2latex

by

 

09 Apr 2013 (Updated )

Using full Latex markup in m-files to generate high quality documentation. Version 1.3

analyzeCellLines( cellLines )
function [preCodeLatex, codeLines, postCodeLatex] = analyzeCellLines( cellLines )
%
% Purpose : This function analyses a cell from the m file to determine the
% pre-m-code text, the m-code and the post-m-code text.
%
% Use (syntax):
%
% Input Parameters :
%   cellLines
%
% Return Parameters :
%   preCodeLatex
%   codeLines
%   postCodeLatex
%
% Author :  Matther Harker and Paul O'Leary
% Date :    29. Jan 2013
% Version : 1.0
%
% (c) 2013 Matther Harker and Paul O'Leary
% url: www.harkeroleary.org
% email: office@harkeroleary.org
%
% History:
%   Date:           Comment:
%
noLines = length( cellLines );
allLines = 1:noLines;
%
% the first non-comment is the start of code
%
at = 1;
line = cellLines{at};
while (strcmp( line(1) , '%' )) && (at < noLines );
    at = at + 1;
    line = cellLines{at};
end;
%
if strcmp( line(1) , '%' )
    preCodeLatex = [1:at];
else
    preCodeLatex = [1:at-1];
end
%
% Start from the bottom and work back to the first non comment line
%
bot = noLines;
line = cellLines{bot};
if (strcmp( line(1), '%')&&(bot > at))
    while (strcmp( line(1) , '%' )) && (bot > 1 );
        bot = bot - 1;
        line = cellLines{bot};
    end;
    postCodeLatex = [bot+1:noLines];
else
    postCodeLatex = [];
end;
%
nonCodeLines = unique(union(preCodeLatex,postCodeLatex));
codeLines = setdiff( allLines, nonCodeLines );
%
preCodeLatex = setdiff(preCodeLatex,1)';
codeLines = codeLines';
postCodeLatex = postCodeLatex';

Contact us