In a bowl, beat egg yolks with a fork to blend.
In a 3- to 4-quart pan, mix flour, cornstarch, and sugar. Gradually whisk in soy milk until smooth.
Add chopped chocolate. Stir over high heat until mixture comes to a full boil, 6 to 10 minutes. Boil, stirring, for 1 minute.
Stir about 1/2 cup hot pudding into egg yolks, then pour yolk mixture into pan. Cook, stirring, for 1 minute more. Remove from heat. Add margarine and vanilla and stir until margarine is melted.
Pour pudding into a serving dish or individual dishes. Serve warm, or cover pudding surface with plastic wrap and chill up to 24 hours