Boundedness and convergence of martingales in rearrangement-invariant function spaces