You can't change the shape of the markdown widget, but you could use a separate shape element and conditionally color it. The implementation of this would involve a similar technique to what I described above, only applied to the shape
function instead.
This thread may be of interest, as it is solving a very similar problem: Can't get shape to render with correct color