<commit_before><?php
/*
Plugin Name: TypoFR
Plugin URI: https://github.com/borisschapira/typofr
Description: a plugin for french typography management, powered by JoliTypo
Version: 0.1
Author: <NAME>
Author URI: http://borisschapira.com
License: MIT
*/

include 'vendor/autoload.php';

// Correction typographique francaise par JoliTypo

use JoliTypo\Fixer;

function typofr($text)
{
    static $fixer;
    if (!isset($fixer)) {
        $fixer = new Fixer(array(
            'Ellipsis',
            'Dimension',
            'Dash',
            'FrenchQuotes',
            'FrenchNoBreakSpace',
            'CurlyQuote',
            'Hyphen',
            'Trademark'));
        $fixer->setLocale('fr_FR'); // Needed by the Hyphen Fixer
    }

    $decoded = utf8_decode($text);
    $reEncoded = utf8_encode($decoded);

    $fixed = $fixer->fix($decoded);
    $fixedWrong = $fixer->fix($reEncoded);

    $logs = "<script> console && console.log('-------\\nOriginal : ".$text." (".mb_detect_encoding($text).")\\nDecoded : ".$decoded." (".mb_detect_encoding($decoded).")\\nRe-encoded : ".$reEncoded." (".mb_detect_encoding($reincoded).")\\nFix(Decoded) : ".$fixed." (".mb_detect_encoding($fixed).")\\nFix(Re-encoded) : ".$fixedWrong." (".mb_detect_encoding($fixedWrong).")')</script>";

    return $fixed.$logs;
}

//add_filter('the_content', 'typofr');
add_filter('the_title', 'typofr');
<commit_msg>Remove logs and useless variables<commit_after><?php
/*
Plugin Name: TypoFR
Plugin URI: https://github.com/borisschapira/typofr
Description: a plugin for french typography management, powered by JoliTypo
Version: 0.1
Author: <NAME>
Author URI: http://borisschapira.com
License: MIT
*/

include 'vendor/autoload.php';

// Correction typographique francaise par JoliTypo

use JoliTypo\Fixer;

function typofr($text)
{
    static $fixer;
    if (!isset($fixer)) {
        $fixer = new Fixer(array(
            'Ellipsis',
            'Dimension',
            'Dash',
            'FrenchQuotes',
            'FrenchNoBreakSpace',
            'CurlyQuote',
            'Hyphen',
            'Trademark'));
        $fixer->setLocale('fr_FR'); // Needed by the Hyphen Fixer
    }

    $fixed = $fixer->fix($decoded);
    
    return $fixed;
}

add_filter('the_content', 'typofr');
add_filter('the_title', 'typofr');

{'fraction_non_alphanumeric': 0.16565481352992195, 'fraction_numerical': 0.0026019080659150044, 'mean_word_length': 3.0332167832167833, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 12, 'https://': 2, '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': '3649710', 'n_tokens_mistral': 794, 'n_tokens_neox': 774, 'n_words': 156}