Hello,

I propose a patch to add the possibility to have a title for block code.

Becareful, I have changed the regular expression that match attribut values for allow spaces. I don't know real effects.

Comments

soxofaan’s picture

Title: Add support for title attribut » Add support for title attribute
Version: 6.x-1.3 » 6.x-1.x-dev
Component: Code » Filtering
Status: Active » Needs review

Interesting idea, good work.

Some remarks, after giving it a first quick look:

  • -  $cache_id = "geshifilter:$lang:$line_numbering:$line_numbering:$inline_mode" . md5($source_code);
    +  if (empty($title)) {
    +    $cache_id = "geshifilter:$lang:$line_numbering:$line_numbering:$inline_mode" . md5($source_code);
    +  }
    +  else {
    +    $cache_id = "geshifilter:$lang:$line_numbering:$line_numbering:$inline_mode:". md5($title) .":". md5($source_code);
    +  }
    

    I would avoid the if-construct by just putting the title in the md5 call: md5($title . $source_code)

  • +    if (!empty($title)) {
    +      $source_code = '<span class="geshifilter-title">'. $title .'</span>';
    +    }
    +    else {
    +      $source_code = '';
    +    }
         $source_code = '<span class="geshifilter"><code class="'. $code_class .'">'. $geshi->parse_code() .'< / code></span>';
    

    this looks wrong: $source_code_ gets overwritten?

sanpi’s picture

StatusFileSize
new6.31 KB

I would avoid the if-construct by just putting the title in the md5 call: md5($title . $source_code)
Great idea.

this looks wrong: $source_code_ gets overwritten?
Yes, but I misunderstood the inline mode. The new patch use the attribut as span title (let the mouse cursor on the code to show tooltip).

soxofaan’s picture

Status: Needs review » Needs work

I tried the patch and it worked fine.

One minor issue: in your screenshot, the title is on a gray background (like the collapse link), but the patch does not contain the necessary CSS to make this happen.

sanpi’s picture

Status: Needs work » Needs review
StatusFileSize
new6.92 KB

The CSS style has been added.

soxofaan’s picture

Status: Needs review » Fixed

added filter tips
added tests
tweaked some minor things
and committed: http://drupal.org/cvs?commit=356912
thanks!

Status: Fixed » Closed (fixed)

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