Initial changes to support a shared context in HTML mode

At the moment the shared flag has no effect, but a context can be passed in.