views:

183

answers:

2

If any of you have ever used wmd markdown editor (which is like the editor that stackoverflow uses) then maybe you are able to help me out:

WMD by default assigns itself to the first textarea found on the page. However, I have a page with an arbitrary amount of textareas appearing before the one I need WMD assigned to. WMD provides options to create and destroy instances of itself but I have had no luck creating an instance and assigning it to a specific textarea (i.e. by 'id' or 'class'). Has anyone been able to do this? (the javascript code for wmd is obfuscated so looking through the source to figure this out would be a huge pain).

A: 

I cant recall who actually did it, but in the early days of SO - Jeff encountered similar problems to what your experiencing (well not exactly the same) but the desire for the non obfuscated source resulted in someone(s) reverse engineering a readable form. Lucky for Jeff he advertised it via the podcast and the work got done. I dont recall exactly where they put it but i think it was codeplex. Sorry i dont recall the exact details.

Google^h^h^hBing is your friend.

mP
The code you mention is here: http://github.com/derobins/wmd/tree/master, as advertised in this blog post: http://blog.stackoverflow.com/2009/01/wmd-editor-reverse-engineered/
Daan
+1  A: 

By default, wmd will grab the first textarea. If you want WMD to ignore a textarea, you can add the class 'wmd-ignore' to the tag.

for example:

<form>
    <textarea class="exampleOne wmd-ignore" ></textarea>
    <textarea class="exampleTwo wmd-ignore" ></textarea>
    <textarea class="exampleThree" ></textarea>
</form>

<div class="wmd-preview"></div>

from the WMD readme file:

Special class names
-------------------

You can use the following class names to control WMD's auto-start behavior:

`wmd-ignore` - Add to a textarea to prevent WMD from turning it into an editor.

`wmd-preview` - Add to a div to turn show a live preview.

`wmd-output` - Add to a textarea or div to turn show the HTML output.
Nick Sonneveld
don't know how I missed those class names. thank you!
es11