S=whole sentence, T=text part (at least one letter), L=list content (at least one <li> text). Now we require that there must always be some text before beginning a new list. Number of nested lists is not limited.
Notice that your program should also check that the original file is legal (follows the grammar), otherwise you cannot translate the resulting latex file!
You can test the resulting latex files, if you replace <html>< body> in the beginning by \documentclass[a4paper,12pt]{article}\begin{document} and </body></html> by \end{document}.
If original file was test.html, then give it name test.tex, and run latex test.tex. The resulting file can be watched by xdvi test (in linux or unix). For printing, you can transform it to postscript by dvips test.dvi -o test.ps.