Calculate document headings on the client side