1Heat the oven to 350°F and arrange a rack in the middle. Line two 12-well (1/2 cup) muffin pans with paper liners; set aside.
2Sift the flour, cocoa powder, baking soda, baking powder, and salt into a medium bowl; set aside.
3Using a microwave or double boiler, melt the chocolate in a small bowl; set aside to cool slightly. In a medium, nonreactive bowl, combine the soy or rice milk and vinegar; set aside.
4In the bowl of a stand mixer fitted with a paddle attachment, beat the margarine and sugars on medium-high speed until fluffy and well combined, about 3 minutes, stopping as needed to scrape down the sides of the bowl. With the mixer on medium speed, add the melted chocolate and vanilla and beat until just combined. Scrape down the sides of the bowl. Reduce the speed to low, add a third of the flour mixture, and mix until just incorporated. Add a third of the soy milk mixture and mix until just incorporated. Continue with the remaining flour and soy milk mixtures, alternating between each and stopping to scrape down the sides of the bowl as needed, until all ingredients are just incorporated.
5Fill each muffin well about three-quarters full. Bake until a toothpick inserted into the center comes out clean, about 20 minutes. Remove from the oven and let the cupcakes cool in their pans on a rack for 10 minutes, then remove from the pans to cool completely.
For the frosting:
1Using a microwave or double boiler, melt the chocolate in a medium bowl; set aside to cool.
2In the bowl of a stand mixer fitted with a paddle attachment, beat the margarine on medium-high speed until fluffy, about 2 minutes, stopping to scrape down the sides of the bowl. Turn the mixer to low, add the sugar and salt, and mix until incorporated. Increase the speed to medium high and beat until fluffy, about 3 minutes, stopping to scrape down the sides of the bowl.
3With the mixer on low, gradually add the cooled melted chocolate and beat until incorporated. Stop the mixer and add the cocoa powder, soy or rice milk, and vanilla. Beat on low until incorporated, then beat on medium high until the frosting is airy and thoroughly mixed, about 1 minute, stopping once to scrape down the sides of the bowl.
1Using an offset spatula or wide butter knife, spread the frosting in a gentle swirling motion over the top of each cupcake. Decorate as you wish and serve.