From 162a6548baf08e91c5a86bb90f256c6cc05145ee Mon Sep 17 00:00:00 2001 From: BlankEclair Date: Mon, 9 Dec 2024 22:18:55 +1100 Subject: [PATCH] T12969: Add requested hook for acuralegendwiki Closes T12969 --- LocalWiki.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/LocalWiki.php b/LocalWiki.php index 6fa17af195..767572fa33 100644 --- a/LocalWiki.php +++ b/LocalWiki.php @@ -10,6 +10,34 @@ // Per-wiki settings that are incompatible with LocalSettings.php switch ( $wi->dbname ) { + case 'acuralegendwiki': + /* The following code block is a [modification] of [Extension:IndentSections] + * and is licensed under the [MIT License]. + * + * [modification]: https://issue-tracker.miraheze.org/T12969 + * [Extension:IndentSections]: https://www.mediawiki.org/wiki/Extension:IndentSections + * [MIT License]: https://opensource.org/licenses/mit-license.php + */ + $wgHooks['BeforePageDisplay'][] = 'fnIndentSectionsBeforePageDisplay'; + + function fnIndentSectionsBeforePageDisplay( $out, $skin ) { + $text = $out->getHTML(); + + for ( $i = 6; $i >= 1; $i -= 1 ) { + $pattern = sprintf( '/(\s*?)(.*?)(?=(|\Z))/ms', $i, $i, $i ); + //$pattern = sprintf( '/(]+><\/a>\s*?.*?<\/h%d>)(.*?)(?=(]+><\/a>|\Z))/ms', $i, $i, $i ); + $text2 = preg_replace( $pattern, '$1
$2
', $text ); + if ( $text2 !== null ) { + $text = $text2; + } + } + + $out->clearHTML(); + $out->addHTML( $text ); + return true; + } + + break; case 'aieseattlewiki': $wgUploadWizardConfig = [ 'campaignExpensiveStatsEnabled' => false,