Skip to content

Commit 0a56781

Browse files
committed
fix bug
1 parent 7c3a10f commit 0a56781

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

Plugin.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@ public static function create_toc($content)
149149
$anchor = $anchor_base . $anchor;
150150
}
151151

152-
153152
// 如果相同,则入数组递增输出
154153
if (!in_array($anchor, $anchors)) {
155154
$anchors[] = $anchor;
@@ -224,7 +223,7 @@ public static function create_toc($content)
224223

225224
public static function create_toc_with_dom($content)
226225
{
227-
require_once 'simple_html_dom.php';
226+
class_exists('simple_html_dom') || require_once 'simple_html_dom.php';
228227

229228
$html = str_get_html($content, 1, 1, 'UTF-8', false);
230229

@@ -249,7 +248,6 @@ public static function create_toc_with_dom($content)
249248

250249
$h->innertext = $innerTEXT; // add id attribute so we can jump to this element
251250

252-
253251
if ($level > $last_level)
254252
// add class
255253
$toc .= '<ul>';
@@ -270,6 +268,7 @@ public static function create_toc_with_dom($content)
270268
$toc .= str_repeat('</li></ul>', $last_level);
271269
$toc .= '</div></div>';
272270

271+
273272
return $toc . "\n\n\n\n<!- toc end ->\n\n<hr>" . $html->save();
274273

275274
}

0 commit comments

Comments
 (0)