WMD - Come ottenere la \ Markdown codice HTML generato
-
26-09-2019 - |
Domanda
Beh ho avuto WMD, ma io sono in grado di imparare come ottenere il codice HTML generato \ codice Markdown .... voglio inviarlo al DB ... ecco perché sto usando 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";
}
?>
Ora qualcuno può dirmi come ottenere il codice HTML generato ...
Soluzione
L'editor WMD è solo un editor di testo sul lato client che supporta l'input di testo Markdown-formattato. Per convertire markdown in HTML avrete bisogno di un parser Markdown.
Una rapida di Google mi dice che c'è almeno uno a disposizione: http://michelf.com/projects / php-mark-down /
Altri suggerimenti
ottenere questi file wmd.js
& markdown.php
e utilizzando questo codice follwing
<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
}
?>
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow