<commit_before><?php
$filename = $args[0];
// Get the content of the temporary file
$content = file_get_contents( $filename );
$content = wpautop( $content );
// Save the new content inside temporary file
file_put_contents($filename, $content);
?><commit_msg>not call autop when gallery block<commit_after><?php

$filename = $args[0];

// Get the content of the temporary file
$content = file_get_contents( $filename );

// Find pattern <!-- wp:gallery { ....   <!-- /wp:gallery -->
$index_start = strpos($content, "<!-- wp:gallery");
$index_end = strpos($content, "<!-- /wp:gallery -->") + strlen("<!-- /wp:gallery -->");
$length_gallery = $index_end - $index_start;

if ($index_start != FALSE) {
    // Keep gallery HTML
    $gallery_content = substr($content, $index_start, $length_gallery);

    // Replace gallery HTML by pattern $god
    $god = "######GALLERY#GUTENBERG#BLOCK#############";
    $content = substr_replace($content, $god, $index_start, strlen($gallery_content));
}

// Add auto <p>
$content = wpautop( $content );

if ($index_start != FALSE) {
    // Search pattern $god
    $index_start = strpos($content, $god);
    $index_end = strpos($content, $god) + strlen($god);

    // Replace $god by gallery HTML
    $content = substr_replace($content, $gallery_content, $index_start, strlen($god));
}

// Save the new content inside temporary file
file_put_contents($filename, $content);

?>
{'fraction_non_alphanumeric': 0.18194740582800284, 'fraction_numerical': 0.0014214641080312722, 'mean_word_length': 4.35361216730038, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6253341', 'n_tokens_mistral': 449, 'n_tokens_neox': 433, 'n_words': 119}