Style break - bug or normal?
-
In a file with the extension ‘.php’ or ‘.html’, whenever I use the character: `
Because I use it to insert texts in JavaScript.
Causes style breakage.
This is normal? -
Sorry it took a while to reply; my IT blocks that image-hosting site, so I meant to check last night at home, but forgot. Today, when I saw your question still hadn’t been answered, I disconnected my phone from work WiFi and used spotty cell connection instead, and looked at the image, then re-typed a snippet of code into Notepad++. If you had just provided us with a short sample of code that showed the problem, by including the following in your post, it would have saved a ton of effort, and you might have gotten a response from me yesterday.
``` <script> let transactions = event.data.transactions for(let i=0; i < transactions.length; i++) { $('#transactions-list').append(`<tr> <td></td> <td></td> <td></td> <td></td> </tr>`) } </script> <p>okay</p> ```
When I take that code in Notepad++ and use the HTML or PHP parser, they look the same as each other, but different than when you manually select JavaScript:
html php js I assume that the JS version is the one you want, because it’s treating the
`...`
as a multiline string.The just-JS parser has a style in Settings > Style Configurator > Language:
JavaScript
calledSTRINGRAW
which styles the back-tick “template literal” strings . The PHP and HTML parsers do their own parsing, but use the sub-parser Settings > Style Configurator > Language:JavaScript (embedded)
which doesn’t have that style available (because it’s a different lexer).Notepad++ uses the Scintilla IP for the lexers/syntax highlighting. (As of NPP v7.8, Scintilla 4.20; as of NPP 7.9.4, Scintilla 4.46). So not knowing which version you were on (and since I already had SciTE 4.20, Scintilla’s testbed editor, which we can use to confirm whether it’s a Notepad++ issue or Scintilla issue), and compare HTML/PHP/JS in SciTE as well:
4.20 html doesn’t show matching parenthesis; inconsistent coloring inside the string 4.20 php same 4.20 js shows matching paren in blue; the string has one consistent color Since SciTE showed similar difference between HTML/PHP behavior and JS behavior in 420, there’s a good chance the problem is on the Scintilla side. I just checked the SciTE 4.46 (which matches Notepad++ 8.1.4’s version of Scintilla) and SciTE 5.11 (which is the most recent version of Scintilla, as of today’s download), and they both have the difference, too.
So if you’re interested in getting that feature added, you would likely have to go to the Scintilla Feature Request or Bug Report area, and ask that they add support for the javascript (embeddded) template strings highlighting in the HTML/PHP lexer; then, after that got added and released in Scintilla, you would have to convince the Notepad++ Developers to upgrade the Scintilla component from 4.46 to whatever 5.xx it got incorporated into.
-
Thank you very much for the clarification. And forgive me for any inconvenience.
I will send the question to Scintilla Feature Request.Thank you very much!