0

I am using WMD Editor and I want to add wmd_options = {"output": "Markdown"};

I have following line before tag.

<script type="text/javascript" src="../wmd/wmd.js"></script>

I want to understand how can i add this line.

wmd_options = {"output": "Markdown"}; 

I am not very good at using javascript please help me to use this.

Thanks

Jordon Willis
  • 4,851
  • 7
  • 27
  • 34

2 Answers2

4
<script type="text/javascript">
wmd_options = {"output": "Markdown"}; 
</script>
<script type="text/javascript" src="../wmd/wmd.js"></script>

Javascript executes code in the order it is included on the page (from top to bottom). So you need to set the wmd_options first before the code in the wmd.js file is executed.

Neil
  • 8,925
  • 10
  • 44
  • 49
  • I have tried this but unfortunately it is not working. I am refering to this thread solution http://stackoverflow.com/questions/122108/how-do-you-store-the-markdown-using-wmd-in-asp-net, wherein want to convert html tag into markdown tag in order to edit content – Jordon Willis Jan 28 '11 at 20:04
  • So you want to convert HTML into Markdown? The WMD editor doesn't work like that. It only converts Markdown into HTML. The option you mentioned allows you to choose what format gets sent back to the server when you submit the form. You probably want to save the contents of the form in your database as Markdown so you can edit it again. Use this http://michelf.com/projects/php-markdown/ to covert Markdown to HTML on your server. – Neil Jan 28 '11 at 20:12
0

Open up wmd.js.

Look for this section:

// -------------------------------------------------------------------
//  YOUR CHANGES GO HERE
//
// I've tried to localize the things you are likely to change to 
// this area.
// -------------------------------------------------------------------

// The text that appears on the upper part of the dialog box when
// entering links.
var imageDialogText = "<p style='margin-top: 0px'><b>Enter the image URL.</b></p><p>You can also add a title, which will be displayed as a tool tip.</p><p>Example:<br />http://wmd-editor.com/images/cloud1.jpg   \"Optional title\"</p>";
var linkDialogText = "<p style='margin-top: 0px'><b>Enter the web address.</b></p><p>You can also add a title, which will be displayed as a tool tip.</p><p>Example:<br />http://wmd-editor.com/   \"Optional title\"</p>";

// The default text that appears in the dialog input box when entering
// links.
var imageDefaultText = "http://";
var linkDefaultText = "http://";

// The location of your button images relative to the base directory.
var imageDirectory = "images/";

// Some intervals in ms.  These can be adjusted to reduce the control's load.
var previewPollInterval = 500;
var pastePollInterval = 100;

// The link and title for the help button
var helpLink = "http://wmd-editor.com/";
var helpHoverTitle = "WMD website";
var helpTarget = "_blank";

var wmd_options = {"output": "Markdown"};  //ADD IT HERE
// -------------------------------------------------------------------
//  END OF YOUR CHANGES
// -------------------------------------------------------------------

This will send all of your output to the database as Markdown text.

If you want to convert HTML to Markdown text for editing, because you are storing your input in HTML form, then you will need something like this: http://milianw.de/projects/markdownify/

So when your user clicks on their 'edit' button. You run the query as you normally would, but you run the display text through Markdownify.

bitbandit
  • 409
  • 5
  • 10