The post_typo pipeline is used to modify text after SPIP has applied its normal typographical processes, and therefore also after the pre_typo pipeline. It is called by the corriger_typo() function in ecrire/inc/texte.php, a function which itself is called when using the propre() or typo() functions.

$letexte = pipeline('post_typo', $letexte);


The "Typo Guillemets" plugin replaces quotation marks " in a piece of entered text with the appropriate equivalent depending on the language code, such as using « and » for French texts. To do this, it analyses the text for typographical short-cuts that have been applied as shown below:

function typo_guillemets_post_typo($texte) {
    // ...
    switch ($GLOBALS['spip_lang']) {
        case 'fr':
            $guilles="«  »"; //LRTEUIN
        // ...

    // escape any " found in the tags;
    // note <!--extra--> is the character chr(1), and <!--extra--> represents the tag
    $texte = preg_replace(',<[^>]*"[^>]*(>|$),msSe', "str_replace('\"','<!--extra-->', \"<!--extra-->\")", $texte);

    // We correct any remaining quotes, which are by definition not within tags
    // A quote is not processed if it follows a non-space character, or
    // if it is followed by a word (letter, digit)
    $texte = preg_replace('/(^|\s)"\s?([^"]*?)\s?"(\W|$)/S', '<!--extra-->'.$guilles.'', $texte);

    // and put back the quotes in any tags
    return str_replace("<!--extra-->", '"', $texte);

Author Mark Baber Published : Updated : 12/05/17

Translations : English, français