evilstreak / markdown-js

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

patch to make lib work in IE7/8 #37

Closed somebox closed 12 years ago

somebox commented 12 years ago

Just sharing a patch... markdown.js was failing in IE7/8 on a project I've been working on. I had to quickly make some patches for IE7/8 users because a js error was being thrown: http://dl.dropbox.com/u/385855/Screenshots/8k3z.png

Please note that the following tests are not passing (mostly edge cases). I've not yet had the time to fix but I could try. Please let me know if you have any suggestions as to how I could refactor to get everything green again?

https://gist.github.com/5cddc20d3bb395698a84

Thanks for the great library!

alexwhitman commented 12 years ago

+1 for this.

ashb commented 12 years ago

Pushed in 69c5107. Had to change a few things to get test passing. Turns out my [^] in regex was a short hand to say match anything including new lines. Dirty hack on my part - [\s\S] is the slightly clearer version.

The forEach replacement needed index and the array iterating over passed in too, which I've pulled out into a helper method in c360714

Jinjiang commented 12 years ago

line: 563 var found = stack.some(function(s, i) { also has problem in IE 7/8. method some is not supported

ashb commented 12 years ago

Thanks - fixed the one too. Should really test this in IE's myself at some point :/