Yeah, it is not a simple thing to do :(  My own guess is that the HTML
highlighter scans the file as a whole and notices wherever PHP start and end
tags appear, and from that point it passes the substrings to the PHP
highlighter, completly unaware of whether or not those tags are actually PHP
tokens from the PHP engine's point of view.

A best-case solution would require some kind of "engine" approach, an iterative
or recursive loop that actually crawls through the file, stops at the whatever
special token is first found, and switches to the next highlighter to continue
from there.  This is not something you can easily (if at all) perform using one
big, all-encompassing regex.

Conceptually, it might look like this:

$offset = 0;
$hilighter = HTML_Multihighlighter;
while($offset < strlen($file))
{
  // Ask the highlighter where, according to its individual rules, the "next"
special token occurs
  $found = $hilighter->findNextSpecialChar($file, $offset);

  if (is_integer($found))
  {
    // Analyze the special token to figure out which highlighting mode to switch
to
    $offset = $found;
    $next = $hilighter->analyzeThisToken($file, $offset);

    if ($next instanceOf someHighlighter)
    {
      // Switch to that highlighter and start the next iteration using its
individual rules
      $hilighter = $next;
      continue;
    }
  }
  else
  {
    // No more special tokens in file
    break;
  }
}

...But actually coding it would be a nightmare for certain.

-- 
<http://forum.pspad.com/read.php?2,32787,54438>
PSPad freeware editor http://www.pspad.com

Odpovedet emailem