开发者

WMD - How to get the generated\Markdown HTML Code

开发者 https://www.devze.com 2023-01-13 19:23 出处:网络
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....

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'] ) )
{
       $gener开发者_StackOverflowated_HTML = "How to get it here";
}
?>

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


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/


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
}
?>
0

精彩评论

暂无评论...
验证码 换一张
取 消