Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Have php with echoing html tags. notepad++ 6.4.5 is highlighting ok the tags inside php and outisde php.

notepad++ 6.5 is highlighting ok the tags only outisde php and NO HIGHLIGHT inside php code.

How to enable highlighting of tags inside php code?

notepad++ 6.4.5: enter image description here enter image description here

notepad++ 6.5:

enter image description here enter image description here

share|improve this question
    
I just saw this line in the change log, apparently previously this was considered a bug: 9. Fix a tag matching bug by disabling tag matching inside PHP code blocks. –  Ryan Oct 10 '13 at 20:28
    
yes, thanks, I raised a bug ticket - sourceforge.net/p/notepad-plus/bugs/4510 . Waiting for project owner to try to solve that. –  ihtus Oct 10 '13 at 21:43
    
@ihtus That would be a feature request, not a bug. –  Alex W Oct 25 '13 at 19:39
    
Alex: that "feature" was present in previous versions –  ihtus Oct 25 '13 at 20:04

2 Answers 2

You should be creating your PHP documents as templates of HTML documents, as seen below. Notepad++ is just supporting good coding practices by treating your echo strings as PHP strings and not highlighting them. If you want to break into HTML, then just put a ?> to end the PHP syntax highlighting and it will highlight it as HTML. Then use <?php to start PHP code again, as necessary. You don't need echo to output HTML, just end the <?php ... ?> block and type your HTML like you normally would.

<!doctype html>
<html>
...
   <div><?php echo "content"; ?></div>
...
</html>
share|improve this answer
    
php is set as language for both cases. it's about html tags highlighting inside php. –  ihtus Oct 9 '13 at 13:39
    
I think that "PHP documents as templates of HTML documents" is very uncomfortable, so I will not use this. –  ihtus Oct 24 '13 at 19:36
    
@ihtus That is the whole point of PHP is to generate templates of HTML and other static files by processing the dynamic information on the server side. –  Alex W Oct 24 '13 at 19:39
    
Alex: the template you suggest is good when you have a lot of static html + some dynamic information generated by php. In most cases I work at - static html is a small part of a lot php code written for dynamic interactions. So again, the HTML template you suggest does not work for me. –  ihtus Oct 25 '13 at 20:23
up vote 0 down vote accepted

I was expecting a solution from the developers of notepad++, by bringing back the feature of highlighting html code inside php code. But that is not happening... So got a temporary workaround:

1) Open php file in notepad++

2) Set HTML languahe: go to Language => H => HTML

3) Now html tags are highlighted in php code.

If you will close and open once again the php file, you will have to execute 1-3 again.

To make this automatically done:

1) Edit langs.xml from root of Notepad++

2) Replace

<Language name="html" ext="html htm shtml shtm xhtml hta"

with

<Language name="html" ext="html htm shtml shtm xhtml hta php"

That will make php files to be parsed as html language

3) Replace

<Language name="php" ext="php php3 phtml"

with

<Language name="php" ext="php1 php3 phtml"

That will disable php files to be parsed as php language. If not doing step 3 => step 2 has no effect.

EDIT:

Function list will be empty after those changes. Here is the fix: Need to edit functionList.xml

1) Replace:

<association langID="6" id="java"/>
<association langID="9" id="xml_node"/>

with

<association langID="6" id="java"/>
<association langID="8" id="html_function"/>
<association langID="9" id="xml_node"/>

2) just after last is closed, add this (it's a copy of php_function renamed to html_function):

        <parser id="html_function" displayName="PHP" commentExpr="((/\*.*?\*)/|(//.*?$))">
            <classRange
                mainExpr="^[\s]*(class|abstract[\s]+class|final[\s]+class)[\t ]+[\w]+([\s]*|[\s]*(extends|implements)[\s]+[\w\\]+[\s]*)?\{"
                openSymbole = "\{"
                closeSymbole = "\}"
                displayMode="node">
                <className>
                    <nameExpr expr="(class|abstract[\s]+class|final[\s]+class)[\s]+[\w]+"/>
                    <nameExpr expr="[\s]+[\w]+\Z"/>
                    <nameExpr expr="[\w]+\Z"/>
                </className>
                <function
                    mainExpr="^[\s]*((static|public|protected|private|final)*(\s+(static|public|protected|private|final))+[\s]+)?(function[\s]+)+([\w]+([\s]+[\w]+)?([\s]+|\*[\s]+|[\s]+\*|[\s]+\*[\s]+))?([\w_]+[\s]*::)?(?!(if|while|for|switch))[\w_~]+[\s]*\([^\{]*\{">
                    <functionName>
                        <funcNameExpr expr="(?!(if|while|for|switch))[\w_]+[\s]*\([^\{]*"/>
                        <!-- comment below node if want display method with parmas -->
                        <funcNameExpr expr="(?!(if|while|for|switch))[\w_]+"/>
                    </functionName>
                </function>
            </classRange>
            <function
                mainExpr="^[\s]*function[\s]+\w+\("

                displayMode="$className->$functionName">
                <functionName>
                    <nameExpr expr="(?!(if|while|for))[\w_]+[\s]*\("/>
                    <nameExpr expr="(?!(if|while|for))[\w_]+"/>
                </functionName>
                <className>
                    <nameExpr expr="[\w_]+(?=[\s]*::)"/>
                </className>
            </function>
        </parser>
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.