views:

49

answers:

2

well i got WMD but i am unable to learn how to get the generated HTML\Markdown Code.... i want to send it to the DB... thats why i am using PHP....

<script src='wmd.js'></script>

<form name="formname" method='POST'>

<textarea id="myTextarea" style="width: 500px; height: 200px;">
*This* example sets WMD's options programmatically.
</textarea>

<input type="submit" name="sub" value="submit">

</form>

<!--Preview Can Be Seen Here-->
<div class="wmd-preview" id="wmd"></div>

<?php
if( isset( $_POST['sub'] ) )
{
       $generated_HTML = "How to get it here";
}
?>

now can anyone please tell me how to get the generated HTML...

+2  A: 

The WMD editor is just a client-side text editor that supports the input of markdown-formatted text. To convert markdown to HTML you'll need a markdown parser.

A quick google tells me there's at least one available: http://michelf.com/projects/php-markdown/

Paul Suart
got to WMD WebSite http://wmd-editor.com/examples/splitscreen and switch to Advanced Mode... then selct preview HTML from Slectbox\Combo Box... they are not using any parser...
Junaid Saeed
@Paul... can you gimme some Code Sample please
Junaid Saeed
I see that demo page is using a client-side markdown parser implemented in Javascript, called "Showdown" (notice a file called "showdown.js" gets downloaded). Try picking the demo apart and see if you can work out how it's done.
Paul Suart
@Paul Stuart you were right the first time... see my self posted answer
Junaid Saeed
A: 

get these files wmd.js & markdown.php

and use the follwing code

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

wmd_options = {output: "HTML",lineLength: 40,buttons: "bold italic | link image | ol ul heading hr",autostart: true};

</script>

<form name="formname" method="post" action="">
<textarea id="myTextarea" style="width: 500px; height: 200px;" name="TA"></textarea>
<br><input type="submit" name="KILL"     value="Submit">
</form>

<?php
if(  isset( $_POST['kil'] ) )
{
    $my_text = $_POST['tr'];
    include ('markdown.php');
    $my_html = Markdown($my_text);
    echo $my_html;
        //$send $myhtml to database or do something with
}
?>
Junaid Saeed
Yep, this is the approach I was getting at. The demo you sent clearly shows a way to invoke a client-side parser, although the page was pretty impenetrable.
Paul Suart
Junaid Saeed