MediaWiki:Common.js: Difference between revisions

No edit summary
No edit summary
Line 1,441: Line 1,441:


/*----------------------------------08-07-2026----------------------------------*/
/*----------------------------------08-07-2026----------------------------------*/
/* Remove blank <p><br></p> after Author template */
/* Remove blank <p><br></p> after Author template without removing TemplateStyles */
$(function () {
$(function () {


Line 1,448: Line 1,448:
         var $p = $(this);
         var $p = $(this);


         // Remove <br> first
         // Move TemplateStyles outside the paragraph
         $p.find('br').remove();
         $p.children('style[data-mw-deduplicate]').each(function () {
            $(this).insertBefore($p);
        });


         // If only <style> (or nothing) remains, remove the paragraph
         // Remove only <br>
        $p.children('br').remove();
 
        // Remove the paragraph only if it is now empty
         if (
         if (
             $p.children().length === 0 ||
             $.trim($p.text()) === '' &&
            (
            $p.children().length === 0
                $p.children().length === 1 &&
                $p.children('style[data-mw-deduplicate]').length === 1
            )
         ) {
         ) {
             $p.remove();
             $p.remove();