Skip to content
This repository was archived by the owner on Nov 23, 2026. It is now read-only.

Commit a4ea9f4

Browse files
committed
Remove blank lines left by contents directives
1 parent fe1664d commit a4ea9f4

1 file changed

Lines changed: 3 additions & 10 deletions

File tree

‎admin/filters/contents.php‎

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
11
<?php
22

3-
// Handle contents directive from RST - generates table of contents for current page
4-
function after_filter_contents($data, $folder) {
5-
// Look for HTML div elements with class="contents" (converted from RST by pandoc)
6-
// Since the sidebar already provides navigation, we'll remove contents directives
7-
// instead of generating redundant TOC lists within pages
8-
$pattern = '/<div class="contents"([^>]*)>\s*<\/div>/';
3+
declare(strict_types=1);
94

10-
return preg_replace_callback($pattern, function($matches) use ($data) {
11-
// Simply return empty string to remove the contents directive
12-
return '';
13-
}, $data);
5+
function after_filter_contents(string $data, string $folder): ?string {
6+
return preg_replace('/\n*<div class="contents"[^>]*>\s*<\/div>\n*/', "\n\n", $data);
147
}

0 commit comments

Comments
 (0)