Browse Source

:sparkles: exercise 模版

visuddhinanda 3 years ago
parent
commit
245bd3ea06
2 changed files with 22 additions and 0 deletions
  1. 1 0
      app/Console/Commands/TestMdRender.php
  2. 21 0
      app/Http/Api/MdRender.php

+ 1 - 0
app/Console/Commands/TestMdRender.php

@@ -45,6 +45,7 @@ class TestMdRender extends Command
         $markdown .= "content **content**\n";
         $markdown .= "```\n\n";
         $markdown .= "{{168-916-10-37}}";
+        $markdown .= "{{exercise|1|((168-916-10-37))}}";
 
         echo MdRender::render($markdown,'00ae2c48-c204-4082-ae79-79ba2740d506');
         return 0;

+ 21 - 0
app/Http/Api/MdRender.php

@@ -113,6 +113,27 @@ class MdRender{
                             return $output;
                           });
                     break;
+                case 'exercise':
+                    $exeId = trim($param[1]);
+                    $exeContent = trim($param[2]);
+                    $props = Cache::remember("/quote/{$channelId}/{$exeId}",
+                          60,
+                          function() use($exeId,$channelId){
+                            $output = [
+                                "id" => $exeId,
+                                "channel" => $channelId,
+                                ];
+                            return $output;
+                          });
+                    #替换句子
+                    $pattern = "/\(\((.+?)\)\)/";
+                    $replacement = '{{sent|$1}}';
+                    Log::info("content{$exeContent}");
+
+                    $exeContent = preg_replace($pattern,$replacement,$exeContent);
+                    Log::info("content{$exeContent}");
+                    $innerString = MdRender::render($exeContent,$channelId);
+                    break;
                 default:
                     break;
             }