Many of my links are the titles of scientific papers and these often contain latin names - which are, by convention, shown in italics. e.g. "On a new Melangyna species (Diptera, Syrphidae) from Japan". If I use this with freelinking like this:

[[Neilsen_2005|On a new <em>Melangyna</em> species (Diptera, Syrphidae) from Japan]]

Then the link that actually appears on the page rendered by Drupal is "On a new <em>Melangyna</em> species (Diptera, Syrphidae) from Japan". ie. the HTML tags to italicise the name are being passed through html_entity_decode.

When I looked at the code for function _freelinking_do_filtering, I saw the line:

$replacement = l(html_entity_decode($phrase), 'freelinking/' . rawurlencode($freelink), array('attributes' => array('class' => 'freelinking')));

and assumed this was responsible. However, if I change this to:

$replacement = l($phrase, 'freelinking/' . rawurlencode($freelink), array('attributes' => array('class' => 'freelinking')));

it has no effect!. Further investigation showed that HTML decoding was also being done by the Drupal l() function. This makes me think thet the call to html_entity_decode() in _freelinking_do_filtering is probably redundant.

Anyway, I can fix my immediate problem with the follwomg patch:

        $replacement = l(html_entity_decode($phrase), 'freelinking/' . rawurlencode($freelink), array('attributes' => array('class' => 'freelinking')));
//      SGB - 24/08/09 - avoid encoding <em>..</em> in the link phrase
        $em = array("&lt;em&gt;","&lt;/em&gt;");
        $em_to = array("<em>","</em>");
 	$replacement = str_replace($em, $em_to, $replacement);

It seems perfectly resonable to me that character formatting like italic and bold should be allowed in the link phrase. I think a better fix would be to remove the apparently redundant html_entity_decode() call in _freelinking_do_filtering and pass the "HTML=True" option to the l() function. Can somebody who know more about drupal suggest how to modify the l() call to achieve this?

Comments

Grayside’s picture

Version: 6.x-1.8 » 6.x-3.x-dev

I will investigate this for FL3. If someone would like to submit a patch for 1.8, I invite the support.

The approach you have outlined seems correct to me. I will post again once I demonstrate it working in FL3. This functionality will most likely be handled the same (inside calls to l()).

Grayside’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.