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. :)
Comment | File | Size | Author |
---|---|---|---|
#4 | hide_code_from_other_filters_0.patch | 5.43 KB | Liam McDermott |
#3 | hide_code_from_other_filters.patch | 0 bytes | Liam McDermott |
#2 | php_highlight3.patch | 2.45 KB | Liam McDermott |
#1 | php_highlight2.patch | 1.7 KB | Liam McDermott |
php_highlight.patch | 1.03 KB | Liam McDermott |
Comments
Comment #1
Liam McDermott CreditAttribution: Liam McDermott commentedI 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).
Comment #2
Liam McDermott CreditAttribution: Liam McDermott commentedOk, 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! :)
Comment #3
Liam McDermott CreditAttribution: Liam McDermott commentedYet 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.
Comment #4
Liam McDermott CreditAttribution: Liam McDermott commentedHmmm, that doesn't seem to have uploaded correctly. Trying again.
Comment #5
naudefj CreditAttribution: naudefj commentedYou'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.
Comment #6
naudefj CreditAttribution: naudefj commented[youtube] tag was implemented - see http://drupal.org/cvs?commit=95513
Comment #7
Liam McDermott CreditAttribution: Liam McDermott commentedThanks 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.