Bug 428331 - Syntax highlighting PHP/PHP missing
Summary: Syntax highlighting PHP/PHP missing
Status: RESOLVED NOT A BUG
Alias: None
Product: frameworks-syntax-highlighting
Classification: Frameworks and Libraries
Component: syntax (other bugs)
Version First Reported In: 5.75.0
Platform: Neon Linux
: NOR normal
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-10-27 10:41 UTC by Björn Fischer
Modified: 2021-01-27 07:22 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments
Kate highlighting with 'PHP (HTML)' (49.07 KB, image/png)
2021-01-26 09:15 UTC, Björn Fischer
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Björn Fischer 2020-10-27 10:41:23 UTC
Hi, since the latest update I am missing the syntax highlighting for 'PHP/PHP'. I checked an there is only the highlighting for 'PHP (HTML)' remaining. (Which I am currently using as a workaround, though it is not as nice.)

I already figured  out that the PHP highlighting files are automatically generated froma base highliting definition, maybe there went something wrong with that?


STEPS TO REPRODUCE
1. Install Kate 20.08 and ktexteditor-katepart 5.75

OBSERVED RESULT
The syntax highlighting 'PHP/PHP' is not available. The only available PHP highlighting is 'PHP (HTML)'


EXPECTED RESULT
The syntax highlighting 'PHP/PHP' is available.


SOFTWARE/OS VERSIONS
Linux/KDE Plasma: KDE Neon 20.04
KDE Plasma Version: 5.20
KDE Frameworks Version: 5.75
Qt Version: 5.15

ADDITIONAL INFORMATION
Comment 1 Justin Zobel 2020-10-27 22:33:31 UTC
Can confirm missing from Kate built from git master.
Comment 2 Nibaldo G. 2021-01-16 05:47:10 UTC
The "PHP/PHP" highlighter is hidden, since it is used to generate "PHP (HTML)".
Using "PHP (HTML)" is equivalent to "PHP/PHP" only it includes the HTML tags.
Comment 3 Björn Fischer 2021-01-18 10:30:31 UTC
Thanks Nibaldo, I am actually currently using "PHP (HTML)". However "PHP (HTML)" and "PHP/PHP" are not equivalent to each other.

For example on "PHP (HTML)" I do not get any keyword highlighting.
Comment 4 Nibaldo G. 2021-01-25 20:05:28 UTC
In the "PHP/PHP" highlighter, the main context is:

<context name="start" lineEndContext="#stay" attribute="Normal Text">
    <RegExpr context="phpsource" attribute="Keyword" String="&lt;\?(?:=|php)?" insensitive="true" />
    <Detect2Chars attribute="Keyword" context="#pop" char="?" char1="&gt;" />
</context>


The script that generates "PHP (HTML)" inserts these rules in all contexts of the "HTML" highlighter.

Basically, in both "PHP/PHP" and "PHP (HTML)", to write PHP code you have to start with <? , <?= or <?php. The difference between "PHP (HTML)" and "PHP" is that outside the blocks <? ... ?>, the first one also highlights the HTML code.

I guess the following:
You may be using a custom "PHP/PHP" highlighter and after updating KDE Frameworks you are using the major version, which is the built-in one. Check the directories "$HOME/.local/share/org.kde.syntax-highlighting/syntax" and "/usr/share/org.kde.syntax-highlighting/syntax" if there are any XML file for PHP. Also check the old directories: "$HOME/.local/share/katepart5/syntax" and "/usr/share/katepart5/syntax".

I make this assumption since KDE Frameworks 5.75 was released on Oct 10, 2020 and prior to that date only minor updates have been made to the "PHP/PHP" highlighter:

  https://invent.kde.org/frameworks/syntax-highlighting/-/commits/master/data/syntax/php.xml

Also, I remember 2 years ago there was a bug that showed hidden highlighters in the syntax highlighting selection menu.

  https://invent.kde.org/frameworks/ktexteditor/-/commit/bb5f34d7224d0b4d891cdf5d804e2fe515d8dc79


You could also attach example files where you experience the problem along with snapshots, so it could be more clear about the problem.
Comment 5 Björn Fischer 2021-01-26 09:15:53 UTC
Created attachment 135200 [details]
Kate highlighting with 'PHP (HTML)'
Comment 6 Björn Fischer 2021-01-26 09:28:25 UTC
(In reply to Nibaldo G. from comment #4)
> In the "PHP/PHP" highlighter, the main context is:
> 
> <context name="start" lineEndContext="#stay" attribute="Normal Text">
>     <RegExpr context="phpsource" attribute="Keyword"
> String="&lt;\?(?:=|php)?" insensitive="true" />
>     <Detect2Chars attribute="Keyword" context="#pop" char="?" char1="&gt;" />
> </context>
> 
> 
> The script that generates "PHP (HTML)" inserts these rules in all contexts
> of the "HTML" highlighter.
> 
> Basically, in both "PHP/PHP" and "PHP (HTML)", to write PHP code you have to
> start with <? , <?= or <?php. The difference between "PHP (HTML)" and "PHP"
> is that outside the blocks <? ... ?>, the first one also highlights the HTML
> code.


Yes, my PHP files start with '<?php' and I do get some PHP style highlighting 
when I select 'PHP (HTML)' but for some reason I do not get Keyword highlighting.
Some other highlighting, like for variables, does work though.
I attached a screenshot of how syntax highligting currently looks for me with
 Kate and 'PHP (HTML)' for you to have a reference.

I also double checked that I use a default highlighting text style.

> 
> I guess the following:
> You may be using a custom "PHP/PHP" highlighter and after updating KDE
> Frameworks you are using the major version, which is the built-in one. Check
> the directories "$HOME/.local/share/org.kde.syntax-highlighting/syntax" and
> "/usr/share/org.kde.syntax-highlighting/syntax" if there are any XML file
> for PHP. Also check the old directories:
> "$HOME/.local/share/katepart5/syntax" and "/usr/share/katepart5/syntax".

I checked the locations that you pointed out and the folders do not exist or are empty.
Comment 7 Dominik Haumann 2021-01-26 17:45:18 UTC
You don't have a font that supports the bold face. What font are you using? There were KDE versions that propagated broken fonts by default quite some time ago. Maybe you are hit by this issue?
Comment 8 Björn Fischer 2021-01-27 07:22:23 UTC
Oh wow using a different font fixes it. I'm using "Noto Mono" as a font. It worked before so I would not have guessed that this is the problem.

Also all other fonts from the Noto family appear to work.

I guess this fixes my problem then.
Thank you.