|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
mrmidi Smarty n00b
Joined: 02 Jan 2010 Posts: 1
|
Posted: Sat Jan 02, 2010 12:34 am Post subject: Fix typography errors with an output filter |
|
|
I was getting tired of replacing all those special characters with html entities, so I wrote a little outputfilter. It can be done using html_entities, but I don't want it to mess with my tags, so I just subtract html_specialchars from html_entities:
Code: | function fix_typography($tpl_output, &$smarty) {
$entities = array_diff_assoc(
get_html_translation_table(HTML_ENTITIES),
get_html_translation_table(HTML_SPECIALCHARS)
);
$entities = array_merge($entities, array('...' => '…'));
return str_replace(array_keys($entities), array_values($entities), $tpl_output);
}
$smarty->register_outputfilter('fix_typography'); |
|
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|