Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Fix typography errors with an output filter

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Tips and Tricks
View previous topic :: View next topic  
Author Message
mrmidi
Smarty n00b


Joined: 02 Jan 2010
Posts: 1

PostPosted: Sat Jan 02, 2010 12:34 am    Post subject: Fix typography errors with an output filter Reply with quote

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
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Tips and Tricks All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP