evilstreak / markdown-js

A Markdown parser for javascript
7.7k stars 863 forks source link

renderJsonML mutates its argument #216

Closed sneakertack closed 10 years ago

sneakertack commented 10 years ago

Upon running a JsonML tree through markdown.renderJsonML the tree gets trimmed down into nothingness. This means that the following code will not work as expected:

// Assume we already have a JsonML tree myTree.
doSomeProcessingOn(myTree);
var intermediate = markdown.renderJsonML(myTree);
doSomeOtherProcessingOn(myTree);
var finished = markdown.renderJsonML(myTree);

finished ends up being empty.

This pull request fixes the issue by doing a clone at the start of renderJsonML.

ashb commented 10 years ago

Thanks!