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

Ideas for new features

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply

Do you Textpad to support multiple language syntaxes in one file?

I would love this!
2
100%
I don't see the need for this
0
No votes
I don't understand this
0
No votes
 
Total votes: 2

wstein
Posts: 3
Joined: Wed Feb 15, 2012 1:00 am

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

Post 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.
Post Reply