South Korea will revise a law banning abortion by the end of 2020, after a historic court decision.