BobRay, thank you for the idea, actually the typography plugin is pretty bug piece of code but as far I applied it right to modx_content table content, which is against the whold CMS approach.
What I really interested is if I put that code in some OnWebPagePrerender-hooked plugin how often will it be executed: 1) on every page view or 2) only once the page content changed and then it output will be cached?
I suspect it will be executed on every page view, which will be waste of CPU for my site where pages are rarely to change, but I see no better place to have whole page typographed (that is template + all the contents, menu texts etc), not just main content field.
OnWebPagePrerender will execute every time the page is viewed. That's why I suggested OnBoforeDocFormSave, which only executes once when the form is saved in the Manager.
If you want to handle Templates and Chunks too, you can have the plugin listen for OnBeforeDocFormSave, OnBeforeChunkFormSave and OnBeforeTempFormSave.
You'll need a switch statement in the plugin for each event (note the change in the last line):
$e = & $modx->Event;
switch ($e->name) {
case 'OnBeforeDocFormSave':
case 'OnBeforeTempFormSave':
$field = 'content';
break;
case 'OnBeforeChunkFormSave':
$field = 'snippet'; // looks wrong, but it's not
break;
}
$pattern = array(' -- ', '<', '>', etc.);
$replacement = array('—', '<', '>', etc.);
$_POST[$field] = preg_replace($pattern, $replacement, $_POST[$field]);
That way you'll handle documents, chunks and templates as they are saved in the Manager without touching the core code. If you modify the core code, your changes will be overwritten when you update MODx to a new version.