I downloaded markdown from http://code.google.com/p/wmd/ (well, in fact I cloned the hg repository), in order to have a client-side highlighter for static text, i.e. I don’t need the editor.
However, I tried to instantiate the converter, essentially like in the demo:
<script type="text/javascript">
(function () {
var conv = Markdown.getSanitizingConverter();
var ed = new Markdown.Editor(conv);
ed.run();
})();
</script>
However, if I run this, the JS error console tells me:
Error: text is undefined
Source File: http://bitmask.de/markdown_test/Markdown.Converter.js
Line: 149
Which I traced to the call of ed.run().
I put the whole minimal demo on http://bitmask.de/markdown_test/js.html
I didn’t modify the js files or anything (basically because I have very very limited js knowledge), just did what the demo does. What’s wrong here?
You can’t use
<div>element for the input, it has to be something editable (e.g.<textarea>or<input type="text">):Be also carefull about spaces in the HTML source. Your second sample has a line starting with more than four spaces, which means “code” in Markdown: