Do you set a one or two commas when using \mapsto?

I am currently revising a paper and I am completely confused about the commas. Is it correct English to write

1) "The canonical map $X \to Y$, $x \mapsto f(x)$, is injective."

or is it

2) "The canonical map $X \to Y$, $x \mapsto f(x)$ is injective." ,

i.e. is the second comma mandatory, optional or wrong?

-
It would be best to write "The canonical map $X\to Y$ given by $x\mapsto f(x)$ is injective". Neither 1) nor 2) sound like full sentences to my ear, and one should always avoid "(maths),(maths)"! –  Mark Grant May 6 '13 at 9:39
I believe 1) is grammatically correct as the part between the commas can be considered a parenthesis (in the syntactic sense of the word), but I agree that it is best avoided. –  Emil Jeřábek May 6 '13 at 10:02
In the case in question one can just write "The canonical map $f:X\rightarrow Y$ is injective". –  Andrea Mori May 6 '13 at 10:47
As this question seems completely unrelated to the software used to write the sentence, I removed the tag latex. –  quid May 6 '13 at 11:07