Bit of a refactor to allow some markup generation to be shared by plugins