Failing test for gh-3246
Use new input transformation API in %paste

Closes gh-3246
Refactor paste magics and ipdoctest
Merge pull request #3390 from takluyver/i3246

Fix %paste with blank lines