visuddhinanda 2 years ago
parent
commit
ae5cb6e7ee
2 changed files with 32 additions and 0 deletions
  1. 11 0
      rpc/morus/morus/index.html
  2. 21 0
      rpc/morus/morus/morus.php

+ 11 - 0
rpc/morus/morus/index.html

@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html>
+  <head></head>
+  <body>
+    <form action="morus.php" method="post">
+      <div>markdown text:</div>
+      <textarea type="text" name="text">test **markdown** render</textarea>
+      <div><input type="submit" value="Submit" /></div>
+    </form>
+  </body>
+</html>

+ 21 - 0
rpc/morus/morus/morus.php

@@ -0,0 +1,21 @@
+<?php
+require dirname(__FILE__) . '/vendor/autoload.php';
+
+
+if(isset($_POST['text'])){
+    $input = $_POST['text'];
+}else{
+    $json = file_get_contents('php://input');
+    $data = json_decode($json,true);
+    $input = $data['text'];
+}
+
+$Parsedown = new Parsedown();
+
+header('Content-Type: application/json; charset=utf-8');
+echo json_encode([
+            'ok'=>true,
+            'data'=>$Parsedown->text($input),
+            'message'=>'',
+        ],
+     JSON_UNESCAPED_UNICODE) ;