Bläddra i källkod

Merge pull request #155 from lilashih/master

增加陣列&物件的顯示
Jiang Qinghua 5 år sedan
förälder
incheckning
fd26d41f15
1 ändrade filer med 3 tillägg och 1 borttagningar
  1. 3 1
      src/Widgets/Code.php

+ 3 - 1
src/Widgets/Code.php

@@ -18,7 +18,9 @@ class Code extends Markdown
      */
     public function __construct($content = '', int $start = 1, int $end = 10)
     {
-        if (is_file($content)) {
+        if (is_array($content) || is_object($content)) {
+            $content = json_encode($content, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
+        } elseif (is_file($content)) {
             $this->read($content, $start, $end);
             $content = '';
         }