shortcode causes broken paragraph tags

I worked around my problem by minifying my html in my plugin. So I made a function called wl_minify_html(String $htmlString) (which I found some another stack overflow answer somewhere). So here’s what my plugin looks like now:

<?php

function wl_minify_html($htmlString) {

    $search = array(
        '/\>(\s)+\</s',     // strip white space between tags
        '/\>[^\S ]+/s',     // strip whitespaces after tags, except space
        '/[^\S ]+\</s',     // strip whitespaces before tags, except space
        '/(\s)+/s',         // shorten multiple whitespace sequences
        '/<!--(.|\s)*?-->/' // Remove HTML comments
    );

    $replace = array(
        '><',
        '>',
        '<',
        '\\1',
        ''
    );

    $buffer = preg_replace($search, $replace, $htmlString);

    return $buffer;
}


function wl_event_head($att) {
  return wl_minify_html('<section>
  <div>
    <h1>Hello WP</h1>
  </div>
</section>');
}

deneme bonusu veren sitelerbahis siteleripulibet girişdeneme bonusutürkçe altyazılı pornocanlı bahis casinocanlı bahis casino siteleriOnwin Güncel Girişholiganbetholiganbet girişholiganbet güncel giriş