Added more conditions before unwrapping a span within a header after a command to make sure it doesn't unwrap spans that it shouldn't.