0001 function [caption_list, url_list] = vb_users_manual_info_get
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 vbmeg_dir = vb_get_file_parts(which('vbmeg.m'));
0012 help_file = fullfile(vbmeg_dir, 'functions', 'doc', 'html', 'static', 'vbmeg_users_manual.html');
0013
0014 caption_list = cell(0);
0015 url_list = cell(0);
0016
0017
0018
0019
0020 fid = fopen(help_file, 'rt');
0021 if fid == -1
0022 error('Can not open users manual.');
0023 end
0024
0025 contents = cell(0);
0026 l = 1;
0027 while(feof(fid) ~= 1)
0028 line = fgetl(fid);
0029 if is_toc_line(line);
0030 contents{l} = line;
0031 l = l+1;
0032 end
0033 end
0034 fclose(fid);
0035
0036 for k=1:length(contents)
0037 line = contents{k};
0038 [word, toc_id, add_line] = toc_get_info(line);
0039 if add_line
0040 line = [line, contents{k+1}];
0041 [word, toc_id, add_line] = toc_get_info(line);
0042 k = k+1;
0043 end
0044 caption_list{k} = word;
0045 url_list{k} = [help_file, toc_id];
0046
0047 end
0048 caption_list = caption_list';
0049 url_list = url_list';
0050
0051 function [word, toc_id, add_line] = toc_get_info(line)
0052 word = '';
0053 toc_id = '';
0054 if is_toc_line(line) == false
0055 return;
0056 end
0057 add_line = false;
0058
0059 try
0060 pat = '.*href="(.*)"';
0061 [tmp, tokens] = regexp(line, pat, 'match', 'tokens');
0062 toc_id = tokens{1}{1};
0063
0064 pat = '[!>]*>[!<](*)<';
0065 [tmp, tokens] = regexp(line, '.*href.*?>(.*?)<', 'match', 'tokens');
0066 word = tokens{1}{1};
0067 catch
0068 add_line = true;
0069 end
0070
0071 function bool_value = is_toc_line(line)
0072
0073 cond1 = strfind(line, 'href');
0074 cond2 = strfind(line, '#');
0075 cond3 = strfind(lower(line), 'toc');
0076 if ~isempty(cond1) && ~isempty(cond2) && ~isempty(cond3)
0077 bool_value = true;
0078 else
0079 bool_value = false;
0080 end