| 12345678910111213141516171819202122232425262728293031 |
- <?php
- namespace App\Tools;
- use Illuminate\Support\Str;
- class Markdown
- {
- public static function render($text){
- return Markdown::marked($text);
- }
- public static function marked($text){
- $host = env('MORUS_RPC_SERVER');
- $client = new \Mint\Morus\V1\MarkdownClient($host, [
- 'credentials' => \Grpc\ChannelCredentials::createInsecure(),
- ]);
- $request = new \Mint\Morus\V1\MarkdownToHtmlRequest();
- $request->setPayload($text);
- $request->setSanitize(true);
- list($response, $status) = $client->ToHtml($request)->wait();
- if ($status->code !== \Grpc\STATUS_OK) {
- return "ERROR: " . $status->code . ", " . $status->details;
- }
- return $response->getPayload();
- }
- public static function parsedown($text){
- $Parsedown = new \Parsedown();
- return $Parsedown->text($text);
- }
- public static function strdown($text){
- return Str::markdown($text);
- }
- }
|