Many users do not realise that for PHP highlighting to work correctly--when using BBCode--that they need to include special PHP start and finish tags: and
This module should check for their existence within the text string, if not found they should be added.

Also the highlight_string function does not return valid xhtml, as Drupal has a good record of being standards compliant this should not be ruined by one wayward function. This module should take the result from the highlight_string function and change the invalid code.

The attached patch does both these things! Hope it can be added to this excellent module. :)

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Liam McDermott’s picture

Title: [php] highlight fails without PHP start and finish tags, output of highlight_string is not xhtml » New patch...
FileSize
1.7 KB

I noticed that PHP5 produces valid xhtml, so that part of this patch isn't really required. I've removed that part and added functionality that wraps a code block in a div with class="codeblock". This makes the bbcode module use the formatting of the codefilter module if it is installed, is this desirable behaviour? I can take it out if not (but found it useful myself).

Liam McDermott’s picture

Title: New patch... » Make BBCode work with Codefilter
FileSize
2.45 KB

Ok, firstly sorry for creating yet another patch! I keep thinking I've got this input filtering working the way I want it then another test breaks my setup. Now for the patch details:

It's desirable to have BBCode and the Codefilter module working alongside each other. BBCode to filter BBCode and codefilter to deal with HTML < code > and < ? php ? > Unfortunately, using both together ends up with a mess: usually the PHP content to be formatted is filtered twice.

The attached patch fixes this (as long as BBCode is 'lighter' than the codefilter in the Input formats 'Re-arrange' list) by removing the special php start and end tags from within [php][/php] BBCode, only tags within the [php] BBCode are removed. The tags are then re-inserted when the highlight_string function is called. This also ensures that the PHP start and end tags are always included in the code, the reason for the first patch.

Also, left in from the previous patch: divs are added to make the output of BBCode the same as Codefilter. This will re-use the Codefilter CSS if available. Of course, this can be removed if the maintainer thinks it superfluous! :)

Liam McDermott’s picture

Title: Make BBCode work with Codefilter » Make BBCode work with Codefilter (and Youtube embedding)
FileSize
0 bytes

Yet another patch! Is this module still maintained?

Found that the only real way to make BBCode work with other filters is to cut out any code included in the text string. So that's what this patch does. Also added support for Youtube embedding.

Liam McDermott’s picture

Hmmm, that doesn't seem to have uploaded correctly. Trying again.

naudefj’s picture

You've attached several patches, which ones should be tested? I assume hide_code_from_other_filters_0.patch and php_highlight3.patch.

PS: Next time, please submit one feature request per ticket/issue. These multi-feature patches are difficult to test. For example, I'm happy with the [YOUTUBE] tag, but the rest needs more thorough testing.

naudefj’s picture

[youtube] tag was implemented - see http://drupal.org/cvs?commit=95513

Liam McDermott’s picture

Assigned: Unassigned » Liam McDermott
Status: Needs review » Needs work

Thanks for implementing the YouTube support. Just the hide_code_from_other_filters_0.patch should be tested. I'll reroll it against head when I've got some free time.