LaTeX is pretty standard for typesetting math/CS texts of any length. You can use your favorite version control system, and write a Makefile to build a PDF/PS document.
If you want to make it easily readable on a webpage (and not just a PDF download), you may want to use html.