I found the solution to this problem after a lot of searching. By the way this works to customize the output of the links of any specific menu.
Let me just say first that customizing the primary or main menu links is something essential to any theming, and the only reason I can think of why Drupal programmers made it so hard to do is so that professional Drupal themers can keep their jobs!
I saw solutions using the theme_link function : bad idea because this will alter the output of ALL your links, which will break your site's layout.
So my approach is to you override the theme_menu_link function. I add a condition to use the override only on the specific menu I want. In this example I chose the primary links. To know the name of the menu you want to theme you have to put dsm($variables) and usse the Devel module.
function yourtheme_menu_link(array $variables) {
$element = $variables['element'];
$sub_menu = '';
// Replace 'menu_link__menu_block__1' with the name of the menu you want to theme.
if ($element['#theme']['0'] == 'menu_link__menu_block__1') {
if ($element['#below']) {
$sub_menu = drupal_render($element['#below']);
}
$title = $element['#title'];
// I put the span tags in the title.
$element['#title'] = '<span class="yourclass1"></span><span class="yourclass2">' . $title . '</span><span class="yourclass3"></span>';
// I tell the l() function to keep the HTML tags.
$element['#localized_options'] += array(
'attributes' => array(),
'html' => TRUE,
);
$output = l($element['#title'], $element['#href'], $element['#localized_options']);
return '<li' . drupal_attributes($element['#attributes']) . '>' . $output . $sub_menu . "</li>\n";
}
// The function renders the links from all the other menus without modification.
if ($element['#below']) {
$sub_menu = drupal_render($element['#below']);
}
$output = l($element['#title'], $element['#href'], $element['#localized_options']);
return '<li' . drupal_attributes($element['#attributes']) . '>' . $output . $sub_menu . "</li>\n";
}