How do you escape the fire pit in Portal?

Quick answer: Before the platform reaches the flames, put a portal on the wall above the metal ledge past the pit, then put the other portal on a nearby wall and jump through.
Show walkthrough (story spoilers)
When it happens
At the end of Test Chamber 19 the moving platform carries you into a fire pit. GLaDOS keeps talking calmly as it moves toward the flames. You have a few seconds to get off.
Find the ledge
Look ahead for a metal ledge high up beyond the pit. The wall above it takes portals. Shoot your first portal there as soon as it comes into view.
Get through
Turn to a side wall that takes portals and shoot the other color there, then jump into it. You come out next to the ledge. If you miss, you burn and restart from the last save.
Another way
You can also put one portal high on the wall across from the ledge and the other on the floor below you. Drop through the floor portal with speed to fling yourself onto the ledge. This is harder to time, so the side-wall method is easier.
