Page 1 of 1

Make multiple .syn definitions apply to one file(PHP/HTML/JS

Posted: Mon Mar 12, 2012 4:32 pm
by wstein
Textpad already has a great syntax highlighting system...
However, web development frequently includes several different languages in one file, such as in Drupal Development:
  • The basic language is HTML.
    The <SCRIPT> tag switches context to Javascript.
    The <?PHP tag switches context to PHP
    The PHP can also include all the Drupal-specific functions.
There's no reason that all that should have to be packed into one "super" .syn file... Doing it like that, the result ends up being that HTML identifiers get highlighted in the PHP context (and vice-versa).
Additionally, since Javascript is between <SCRIPT> tags, it looks like plain text to Textpad, and doesn't get any highlighting at all.
What would be better is if Textpad could use several .syn definitions for a single file.
( This doesn't only apply to Drupal development, but also for Wordpress, ASP, and any other web framework where several languages get mixed in one file. )

Here's a possible implemention:
In [ Textpad.. Configure.. Preferences ]. you specify the primary .syn file for a file extension. For example, *.module would use "Drupal6Html5.syn".
Inside "Drupal6HTML5.syn", you define all the HTML5 tags. You also specify the start and end tags to mark other languages, such as "<?php" and "?>" as start and end tags for "Drupal6PHP5.syn". Also, you would specify "<SCRIPT.*>" and "</SCRIPT>" as the start and end tags for "JavascriptJQuery1.6.syn".
The corresponding .syn files would then be used for syntax highlighting between those tags.