Am I the only one frustrated with the limitations of the existing codefilter module?
On the one hand it has the ability to create beautiful syntax colored php code samples as can be seen in this first example.
Example 1
if ($links) {
print '<div class="links container">'.$links.'</div>';
}
The problem is that the the nice php syntax coloring is limited to a single set of <?php ?> tags like the above example. Yet so many of the code samples involved with themes and templates jump in and out of php several times. For instance, look here is a typical example of some template code:
Example 2
<?php if ($links): ?>
<div class="links"><?php print $links ?></div>
<?php endif; ?>
For instance, a typical block of html from a node.php.tpl might contain well over 20 sets of inline <?php ?> which forces us to use the <code> </code> tags which don't get to the nice php syntax coloring, on the relevant sections within the <?php ?> tags. Instead, like in the second example above - the whole block is rendered as one monotonous block of code.
But if I leave out the <code> </code> tags in an effort to gain syntax coloring, the same block of code is displayed as several separate, boxed codeblocks. Here is the same exact code used in example 2 above, but without the surrounding <code> </code> tags:
Example 3
if ($links):
print $links
endif;
The resulting code sample is not only unrecognizable in format, but it is missing the inline html altogether, so it and therefore useless for the purpose of discussion.
What I really need is a way to provide a block of sample code so that it displays like Example 2, but with the pretty syntax coloring of Example 1 on the relevant strings between the <?php ?> tags.
I realize that the existing codefilter, is really only meant to be a simple filter without a lot of bells and whistles, and I can appreciate that.
It's just that so many of the topics discussed in these forums are already very difficult to talk about as it is -- anything we can do to increase the ease and consistency of producing sample code for discussion is a direct benefit to the whole community.
There are many great existing syntax coloring text functions already in wide use on the web, most of which are capable of jumping in and out of php sections with ease -- a good example is the PEAR :: Package :: Text_Highlighter -- but for some reason I am having trouble integrating any of them into the Drupal input formats.
I have also monkeyed with the existing codefilter module, trying to create a crossbreed of the two filtering types, but I'm getting nowhere.
Does anyone have any ideas or techniques that will help me better achieve better code highlighting?