Просмотр исходного кода

支持 自定义显示内容和tag

visuddhinanda 1 неделя назад
Родитель
Сommit
6c5364b1cd
1 измененных файлов с 10 добавлено и 2 удалено
  1. 10 2
      api-v13/app/Http/Api/TemplateRender.php

+ 10 - 2
api-v13/app/Http/Api/TemplateRender.php

@@ -405,8 +405,16 @@ class TemplateRender
     private function render_term()
     {
         $word = $this->get_param($this->param, "word", 1);
-
-        $props = $this->getTermProps($word, '');
+        if (str_contains($word, '@')) {
+            [$wordHead, $tag] = explode('@', $word);
+        }
+        if (str_contains($word, '#')) {
+            [$wordHead, $display] = explode('#', $word);
+        }
+        $props = $this->getTermProps($wordHead ?? $word, $tag ?? '');
+        if (isset($display)) {
+            $props['meaning'] = $display;
+        }
 
         $output = $props['word'];
         switch ($this->format) {