Replace :ref: and :math: markup syntax