In the name of Allah, most merciful, most Kind.
There are differences of opinions in this matter if the women who is pregnant wants to marry the man that impregnated her. If she wants to marry a man other than the one who impregnated her, then this is not allowed by consensus until she has given birth to the child.
When a woman married the man she committed zina with, Sheikh Muhammad al-Munajjid says:
"With regard to istibra' (determining that the woman is not pregnant) or 'iddah, this is also a matter concerning which the fuqaha' differed. The Hanafis and Shaafa'is are of the view that it is not necessary. (And this is the more opinion)
What we advise you to do is to do a new marriage contract, without telling the wali the real reason for it. That is in order to be on the safe side. But if it is not possible to do a new marriage contract without telling people of the haram relationship, then we hope that you do not have to do that, and your marriage remains as it is, based on the majority view that this marriage is valid"
This opinion is also adopted by Sheikhul Islam Ibn Taymiyyah.
With regards to the Hanbali and Maalki madhhab and their A'immah saying this type of nikah is invalid, then is is a weak opinion but good to stay on the safe side, because a woman who fornicates with a man may fornicate with another and attribute the child to the wrong man. But if one is sure of the attribution of the child, then a woman may marry the man she committed fornication with.
And Allah knows best.