This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 194149

Summary: hints for syntax higligting for other languages in (PHP) editor
Product: php Reporter: k2s
Component: EditorAssignee: Ondrej Brejla <obrejla>
Status: NEW ---    
Severity: normal CC: micahgreene2, semoriil
Priority: P1    
Version: Dev   
Hardware: All   
OS: All   
Issue Type: ENHANCEMENT Exception Reporter:

Description k2s 2011-01-09 00:32:21 UTC
I often have to write javascript, css or HTML code inside a PHP/PHTML file.

1. Here syntax highliting will work:
<?php
echo "test";
?>
<script type="text/JavaScript">
var v = "also test";
...
</script>

But often I use heredoc and in Zend Framework it is the best to use view helpers like $this->headScript() and then it will not work.

2. Heredoc example:
$js = <<<JAVASCRIPT
var v = "also test";
JAVASCRIPT;

3. Zend helpers add correct starting tags and move the string to head part of page so I can't add my own SCRIPT tag which would help to highlight correctly.
<?php $this->headScript()->captureStart(); ?>
var v = "also test";
<?php $this->headScript()->captureEnd(); ?>


Possible solution:
I think mixed syntax higlighting is supported in PHP editor, becasue it works in example 1.

I don't saw solution in other editors I worked with, but I would like at least to propose.

heredoc: define reserved heredoc names (<<<HTML, <<<JAVASCRIPT, <<<) and use them as hints

other situations: let user to define own (or define fixed) start/end strings assigned to highlight language.
For example I would define in Netbeans configuration javascript=>("//jssyntax", "//.jssyntax")

Then I would have to write:
<?php $this->headScript()->captureStart(); ?>
//jssyntax
var v = "also test";
//.jssyntax
<?php $this->headScript()->captureEnd(); ?>
Comment 1 tubaguy50035 2012-08-02 19:38:55 UTC
This would be lovely.  Updated version to 7.2 since it still does not exist.
Comment 2 micahgreene2 2016-12-29 22:55:52 UTC
I am looking for something similar, and if I know where to start looking the the source code I will see if I can start on a prototype. 

I would like to use the existing netbeans highlighting settings for the languages and just call them when I use heredoc <<<language_name
language_name;

If anyone could point me in the right direction that would be helpful

Even if I knew where the definition of how heredocs is defined as a string that would help.
Comment 3 semoriil 2017-05-31 14:46:27 UTC
JetBrains PhpStorm has similar functionality.