markup: centralize throwing of exceptions to simplify code

Signed-off-by: Peter Williams <pwil3058@gmail.com>
markup: move most functions into Context to declutter namespace

Signed-off-by: Peter Williams <pwil3058@gmail.com>