Generate h1 et h2 inside link with theme function
You need to set the html-Option of l() to true:

l( $date, '', array(
  'fragment' =&gt; $vars['timelinr_dates_id'] . '_' . $i, 
  'external' =&gt; TRUE, 
  'html' =&gt; TRUE
)); 


Otherwise all html-tags get escaped by l().