evilstreak / markdown-js

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

. #51

Closed GHANONTEST closed 12 years ago

GHANONTEST commented 12 years ago

.

ashb commented 12 years ago

Do you want to do this offline or in a browser?

Both are in theory possible but in this instance it would actually be easier via a browser - load the script, use jquery to pull out the text of the div's, run it through the parser and set the innerHTML.

Its also possible using node.js but you'd have to parse the HTML yourself to pull out just the markdown. This would obviously involve learning some node.js and finding a suitable parser (I'm sure there is one but I don't know of any off the top of my head.)

ashb commented 12 years ago

The following bit of (untested) jQuery should work assuming you include the main js file from this project:

$("div.md_parse").each( function( div ) {
  $(div).html( markdown.toHTML( $(div).text() );
} );