change_font - change font and others in html file
tt = change_font(htmf,flag)
- htmf : string. path+name of the html file
- flag : string. a flag to set the type of the html man page :
- 'sci' : for scilab macro
- 'rout' : for routine function
- 'sce' : for script
- tt : vector of strings. the text of the html file
//change_font
//Fonction qui change les fontes
//d'une page d'aide html produits par latex2html
//aux "normes" des pages d'aides scilab
//produites par xmltohtml
//Entrée : htmf : un nom de fichier à modifier
// flag : 'block','pal','sci','scilib',....
//Sortie : tt le texte du fichier htm
function tt=change_font(htmf,flag)
if ~exists('flag') then flag='sci', end;
ok=%f
if fileinfo(htmf(1,1))<>[] then
tt=mgetl(htmf(1,1));
if tt<>[] then
printf("Font convertion... ");
//1ere analyse : ajuste le texte en gras
flagb='<SPAN CLASS=""textbf"">';
flage='</SPAN>';
flagf='</SPAN>0';
i=1;
while i<>size(tt,1)
a=strindex(tt(i),flagb);
if a<>[] then
tt(i)=strsubst(tt(i),flagb,'<b>')
b=strindex(tt(i),flage);
if size(b,2)==1 then
if strindex(tt(i),flagf)<>b then
ok=%t
d=b;
end
else
for j=1:size(b,2)
if(b(j))<>strindex(tt(i),flagf) then
ok=%t
d=b(j)
end
end
end
while ~ok
i=i+1
if i>size(tt,1) then
printf("Warning in %s : change font convertion error\n",htmf(1,1))
break
end
b=strindex(tt(i),flage);
if size(b,2)==1 then
if strindex(tt(i),flagf)<>b then
ok=%t
d=b;
end
else
for j=1:size(b,2)
if(b(j))<>strindex(tt(i),flagf) then
ok=%t
d=b(j)
end
end
end
end
tt(i)=part(tt(i),1:d-1)+strsubst(part(tt(i),d:length(tt(i))),flage,'</b>')
end
i=i+1;
end
printf("Done\n");
//2eme analyse : Change la 1ere ligne des fichiers d'aide
//type 'sci' et 'rout' - enlève le les délimiteurs <H1> </H1>
if flag=='sci'|flag=='rout'|flag=='sce' then
if flag=='sci' then
printf("Scilab function : change font of first line... ");
elseif flag=='rout' then
printf("Low level routine : change font of first line... ");
elseif flag=='sce' then
printf("Scilab script : change font of first line... ");
end
for i=1:size(tt,1)
tt(i)=strsubst(tt(i),'<H1>','<BR>');
tt(i)=strsubst(tt(i),'</H1>','');
end
printf("Done\n");
end
//3eme analyse : change la profondeur des titres et sous-titres
printf("Change level of subtitles... ")
for i=1:size(tt,1)
tt(i)=strsubst(tt(i),'<H2>','<H3>');
tt(i)=strsubst(tt(i),'</H2>','</H3>');
tt(i)=strsubst(tt(i),'<H1>','<H2>');
tt(i)=strsubst(tt(i),'</H1>','</H2>');
end
printf("Done\n");
//4eme analyse : enlève la ligne du bas et passe
//<BODY > en <BODY bgcolor="#FFFFFF">
printf("Change body color and remove address line... ")
for i=1:size(tt,1)
tt(i)=strsubst(tt(i),'<BODY>','<BODY bgcolor=""#FFFFFF"">');
tt(i)=strsubst(tt(i),'<BODY >','<BODY bgcolor=""#FFFFFF"">');
if strindex(tt(i),'<ADDRESS>')<>[] then
aa=i
if strindex(tt(i-1),'<HR>')<>[] then
tt(i-1)=strsubst(tt(i-1),'<HR>','');
end
end
if strindex(tt(i),'</ADDRESS>')<>[] then
bb=i
end
end
if exists('aa')&exists('bb') then
for i=aa:bb
tt(i)=""
end
end
printf("Done\n");
//5eme analyse : change les délimiteurs '<P><A' en '<A'
//et </A></P>
printf("Verification of labels... ")
for i=1:size(tt,1)
if strindex(tt(i),'<P><A')<>[] then
tt(i)=strsubst(tt(i),'<P><A','<A');
tt(i)=strsubst(tt(i),'</A></P>','');
end
end
printf("Done\n");
end
else
tt=[]
end
endfunction
IRCOM Group
Alan Layec