The "pre_liens" pipeline is used to process typographical shortcuts relating to links of the form[title->url]. It is called by the expanser_liens() (expand_link) function, which is itself called by the propre() function.
$texte = pipeline('pre_liens', $texte);
SPIP itself makes use of this entry point to execute processes that include 3 functions in the definition of the pipeline in the ecrire/inc_version.php file, defined within ecrire/inc/lien.php :
-
traiter_raccourci_liens automatically generates links for a piece of text that looks like a URL, -
traiter_raccourci_glossaire generates [?title] shortcuts pointing to a glossary. -
traiter_raccourci_ancre takes care of [<-anchor name] shortcuts that create a named anchor point
Example
The "documentation" plugin (which manages this same documentation), uses this pipeline to automatically add a title attribute on internal link shortcuts of the form [->art30], transforming them into [|art30->art30] (this workaround serves to display the page number relating to the link when exporting the contents of the documentation in PDF format)
function documentation_pre_liens($texte){
// only for the public site
if (test_espace_prive()) return $texte;
$regs = $match = array();
// for each link
if (preg_match_all(_RACCOURCI_LIEN, $texte, $regs, PREG_SET_ORDER)) {
foreach ($regs as $reg) {
// if the shortcut is of the form "art40"
if (preg_match(_RACCOURCI_URL, $reg[4], $match)) {
$title = '|' . $match[1] . $match[2];
// if this title doesn't already exist
if (false === strpos($reg[0], $title)) {
$lien = substr_replace($reg[0], $title, strpos($reg[0], '->'), 0);
$texte = str_replace($reg[0], $lien, $texte);
}
}
}
}
return $texte;
}