A while back @Andrew shared a solution for this, their solution uses the heading markup and doesn’t need a custom function.