\n".
"$title\n".
'\n".
"\n\n".
''."\n".
conv_text($p4);
endif;
return conv_head($p4);
}
function conv_text ($pole)
{ global $zasobnik;
if (!Count($pole)): return ""; endif;
if (prikaz($pole,$p1,$p2,$p3,$p4)): chyba(2); endif;
if ($p1=="\\text"): return spoj($p3).conv_text($p4); endif; //obycajny text
if ($p1=="\\end" AND spoj($p3)=="document"): return "
\n\n"; endif; //koniec dokumentu
if ($p1=="\\temp" AND spoj($p3)=="odstavec"): return "\n".conv_text($p4); endif; //koniec odstavca
if ($p1=="\\newline"): return "
\n".conv_text($p4); endif; //novy riadok
if ($p1=="\\break"): return "
\n".conv_text($p4); endif; //novy riadok
if ($p1=="\\bf"): return "".conv_text($p3)."".conv_text($p4); endif; //tucne
if ($p1=="\\it"): return "".conv_text($p3)."".conv_text($p4); endif; //kurziva
if ($p1=="\\underline"): return "".conv_text($p3)."".conv_text($p4); endif; //podciarknute
if ($p1=="\\tiny"): return "".conv_text($p3)."".conv_text($p4); endif;
if ($p1=="\\scriptsize"): return "".conv_text($p3)."".conv_text($p4); endif;
if ($p1=="\\footnotesize"): return "".conv_text($p3)."".conv_text($p4); endif;
if ($p1=="\\small"): return "".conv_text($p3)."".conv_text($p4); endif;
if ($p1=="\\large"): return "".conv_text($p3)."".conv_text($p4); endif;
if ($p1=="\\Large"): return "".conv_text($p3)."".conv_text($p4); endif;
if ($p1=="\\LARGE"): return "".conv_text($p3)."".conv_text($p4); endif;
if ($p1=="\\huge"): return "".conv_text($p3)."".conv_text($p4); endif;
if ($p1=="\\Huge"): return "".conv_text($p3)."".conv_text($p4); endif;
if ($p1=="\\section"): return "\n
".conv_text($p3)."
\n".conv_text($p4); endif; //nadpisy
if ($p1=="\\subsection"): return "\n".conv_text($p3)."
\n".conv_text($p4); endif;
if ($p1=="\\subsubsection"): return "\n".conv_text($p3)."
\n".conv_text($p4); endif;
if ($p1=="\\begin" AND spoj($p3)=="center"): //center zarovnanie
$zasobnik[]=array("\\end","","center","\n");
return "".conv_text($p4);
endif;
if ($p1=="\\begin" AND spoj($p3)=="flushleft"): //left zarovnanie
$zasobnik[]=array("\\end","","flushleft","
\n");
return "".conv_text($p4);
endif;
if ($p1=="\\begin" AND spoj($p3)=="flushright"): //right zarovnanie
$zasobnik[]=array("\\end","","flushright","
\n");
return "".conv_text($p4);
endif;
if ($p1=="\\begin" AND spoj($p3)=="itemize"): //odrazky bodove
$zasobnik[]=array("\\end","","itemize","\n");
return "
".conv_text($p4);
endif;
if ($p1=="\\begin" AND spoj($p3)=="enumerate"): //odrazky ciselne
$zasobnik[]=array("\\end","","enumerate","\n");
return "".conv_text($p4);
endif;
if ($p1=="\\item"): return "- ".conv_text($p4); endif; //jednotlive polozky
/* if ($p1=="\\begin" AND spoj($p3)=="tabular"): //odrazky ciselne
unset($tmpp4);
$tmpp4[]="\\tabspec
for i
return conv_tab($p4);
endif;
*/
if ($p1=="\\alpha"): return "α".conv_text($p4); endif; //grecka abeceda
if ($p1=="\\beta"): return "β".conv_text($p4); endif;
if ($p1=="\\gamma"): return "γ".conv_text($p4); endif;
if ($p1=="\\delta"): return "δ".conv_text($p4); endif;
if ($p1=="\\epsilon"): return "ε".conv_text($p4); endif;
if ($p1=="\\zeta"): return "ζ".conv_text($p4); endif;
if ($p1=="\\eta"): return "η".conv_text($p4); endif;
if ($p1=="\\theta"): return "θ".conv_text($p4); endif;
if ($p1=="\\iota"): return "ι".conv_text($p4); endif;
if ($p1=="\\kappa"): return "κ".conv_text($p4); endif;
if ($p1=="\\lambda"): return "λ".conv_text($p4); endif;
if ($p1=="\\mu"): return "μ".conv_text($p4); endif;
if ($p1=="\\nu"): return "ν".conv_text($p4); endif;
if ($p1=="\\xi"): return "ξ".conv_text($p4); endif;
if ($p1=="\\pi"): return "π".conv_text($p4); endif;
if ($p1=="\\rho"): return "ρ".conv_text($p4); endif;
if ($p1=="\\sigma"): return "σ".conv_text($p4); endif;
if ($p1=="\\tau"): return "τ".conv_text($p4); endif;
if ($p1=="\\upsilon"): return "υ".conv_text($p4); endif;
if ($p1=="\\phi"): return "φ".conv_text($p4); endif;
if ($p1=="\\chi"): return "χ".conv_text($p4); endif;
if ($p1=="\\psi"): return "ψ".conv_text($p4); endif;
if ($p1=="\\omega"): return "ω".conv_text($p4); endif;
if ($p1=="\\Gamma"): return "Γ".conv_text($p4); endif;
if ($p1=="\\Delta"): return "Δ".conv_text($p4); endif;
if ($p1=="\\Theta"): return "Θ".conv_text($p4); endif;
if ($p1=="\\Lambda"): return "Λ".conv_text($p4); endif;
if ($p1=="\\Xi"): return "Ξ".conv_text($p4); endif;
if ($p1=="\\Pi"): return "Π".conv_text($p4); endif;
if ($p1=="\\Sigma"): return "Σ".conv_text($p4); endif;
if ($p1=="\\Upsilon"): return "Υ".conv_text($p4); endif;
if ($p1=="\\Phi"): return "Φ".conv_text($p4); endif;
if ($p1=="\\Psi"): return "Ψ".conv_text($p4); endif;
if ($p1=="\\Omega"): return "Ω".conv_text($p4); endif;
if ($p1==$zasobnik[Count($zasobnik)-1][0]): //ukoncovacie prikazy v zasobniku
if (spoj($p2)==$zasobnik[Count($zasobnik)-1][1]):
if (spoj($p3)==$zasobnik[Count($zasobnik)-1][2]):
return $zasobnik[Count($zasobnik)-1][3].conv_text($p4);
unset($zasobnik2);
for ($i=1; $i<(Count($zasobnik)); $i++): $zasobnik2[]=$zasobnik[$i-1]; endfor;
$zasobnik=$zasobnik2;
endif; endif; endif;
return conv_text($p4);
}
function conv_math ($pole)
{
return $data;
}
/*
*/
$input = StripSlashes($input);
$data = $input; // $data - pracovna premmena s textom, ktory treba konvertovat
// zrusenie dvojmedzier a dvojkoncoriadkov
$data = $data."\n";
$data = str_replace("\r\n","\n",$data); // zjednodusenie koncov riadkov
$data = str_replace("\r","\n",$data);
$data = str_replace("\\%","\\temp{percenta}",$data); // specialne znaky
$data = str_replace("\\$","\\temp{dolar}",$data);
$data = str_replace("\\&","\\temp{and}",$data);
$data = str_replace("\\#","\\temp{mreza}",$data);
$data = str_replace("\\_","\\temp{podtrzitko}",$data);
$data = str_replace("\\{","\\temp{kucerava1}",$data);
$data = str_replace("\\}","\\temp{kucerava2}",$data);
$data = str_replace("\\\\","\\break",$data);
$data = str_replace("\\ ","\\temp{medzera}",$data);
$data = ereg_replace("%[^\n]*","",$data); // zrusenie komentarov
$data = str_replace("\t"," ",$data); // tab na medzery
$data = My_replace(" "," ",$data); // kompresia dvojmedzier
$data = str_replace(" \n","\n",$data); // medzera pred koncom riadku
$data = My_replace("\n\n\n","\n\n",$data); // zrusenie dvoch prazdnych riadkov
$data = str_replace("\n\n","\\temp{odstavec}",$data);
$data = str_replace("\n"," ",$data);
$data = Trim($data);
//lexikalna analyza do $pole
while (StrLen($data)):
if (EReg("^\\\\([a-zA-Z]*)(.*)$",$data,$cast)): // hlada prikazy
$pole[]="\\$cast[1]";
$data = $cast[2];
if ($data[0]==" "): // rusi medzeru za prikazom
$data=SubStr($data,1,StrLen($data)-1);
// $pole[]="{";
// $pole[]="}";
endif;
elseif ($data[0]=="["): $data=SubStr($data,1,StrLen($data)-1); $pole[]="["; // hlada {}[]
elseif ($data[0]=="]"): $data=SubStr($data,1,StrLen($data)-1); $pole[]="]";
elseif ($data[0]=="{"): $data=SubStr($data,1,StrLen($data)-1); $pole[]="{";
elseif ($data[0]=="}"): $data=SubStr($data,1,StrLen($data)-1); $pole[]="}";
else: // obycajny text
$pod = 1;
$s="";
do
{ if ($data[0]=="\\"): $pod=0;
elseif ($data[0]=="["): $pod=0;
elseif ($data[0]=="]"): $pod=0;
elseif ($data[0]=="{"): $pod=0;
elseif ($data[0]=="}"): $pod=0;
else:
$s = $s.$data[0];
$data=SubStr($data,1,StrLen($data)-1);
endif;
if (!strlen($data)): $pod=0; endif;
} while($pod);
// if ($s[0]==" "): $s=SubStr($s,1,StrLen($s)); endif; // zapis obycajneho text
$pole[]=$s;
endif;
endwhile;
for ($i=0; $i"; endfor;
// zaciatok dokumentu
if (prikaz($pole,$p1,$p2,$p3,$p4)): chyba(3); endif;
if ($p1=="\\documentclass"):
$s="";
$p2 = spoj($p2);
Ereg(",([0-9]{1,2}pt)",$p2,$s); //velkost textu;
if (strlen($s[1])): $textsize = $s[1]; endif;
Ereg("^([0-9]{1,2}pt)",$p2,$s);
if (strlen($s[1])): $textsize = $s[1]; endif;
else: chyba(4);
endif;
$html = "\n". conv_head($p4) ."\n"; // $html - obsahuje skonvertovany text do html
?>
html preview
echo nl2br(HTMLSpecialChars($html)); ?>
lexikalna analyza
echo $lexikalna_analyza; ?>
syntakticka analyza
echo $syntakticka_analyza; ?>