我有WMD但是我无法学习如何获取生成的HTML \ Markdown代码....我想将它发送到DB ...这就是为什么我使用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";
}
?>
现在有人可以告诉我如何获取生成的HTML ...
答案 0 :(得分:2)
WMD编辑器只是一个客户端文本编辑器,支持输入markdown格式的文本。要将markdown转换为HTML,您需要一个markdown解析器。
快速谷歌告诉我至少有一个可用:http://michelf.com/projects/php-markdown/
答案 1 :(得分:0)
获取这些文件wmd.js
&amp; markdown.php
并使用以下代码
<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
}
?>