is valid?      

Text formatted with Texy:

Generated HTML code:

<script
type="text/javascript">
<!--
var x = document.getElementsByTagName('h2');
for (i=0;x && i < x.length; i++)
	{
	var odkaz = "<a href=\"#"+ x[i].id +"\">"+ x[i].innerHTML +"</a><br />";
   document.write(odkaz);
   }
-->
</script>

Verze Texy: 3.1.5 (konfigurace)