WML Syntax Highlighting for Kate/KWrite
Moderator: Forum Moderators
Forum rules
- Please use [code] BBCode tags in your posts for embedding WML snippets.
- To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
-
- Posts: 217
- Joined: December 17th, 2015, 10:27 pm
Re: WML Syntax Highlighting for Kate/KWrite (edition 0.43)
R-r-r-resurrection!
I am making a few necessary changes to my own copy and thought that I'd let you all know so that you could throw in any of your own improvements or complaints.
Here are the two biggest things which I am changing:
I am making a few necessary changes to my own copy and thought that I'd let you all know so that you could throw in any of your own improvements or complaints.
Here are the two biggest things which I am changing:
preprocessor_block_end_statements
will now be recognized with a set ofadditionalDeliminator
that allows it to better represent how the preprocessor actually parses.- the brackets in animation notation of image paths are now not seen as wml elements; they have their own formatting to highlight them.
Re: WML Syntax Highlighting for Kate/KWrite (edition 0.43)
https://github.com/shikadiqueen/kate-wml-syntaxCan-ned_Food wrote: ↑March 15th, 2018, 11:38 pmAlthough the version in Kate.git is now the only copy which seems to be maintained — or even online, — I am posting this notice here rather than on the KDE boards for intuitive reasons.
If you could take the time to make a pull request against my repository I can work on getting the changes merged upstream later. I'm still using Kate and this syntax highlighter for WML every time I manage to find the motivation to do WML, so I'm quite interested in any updates for it. I also have a couple of 1.14-specific additions I want to work on over the next few days.
(By the way, the syntax schemas are now maintained as part of the ktexteditor library, not Kate.)
Author of the unofficial UtBS sequels Invasion from the Unknown and After the Storm.
-
- Posts: 217
- Joined: December 17th, 2015, 10:27 pm
Re: WML Syntax Highlighting for Kate/KWrite (edition 0.45)
I should've thought to look there. Okay, I'll do a pull sometime soon. I haven't finished it yet.
Those repos on https://cgit.kde.org/ must be old ones, then.
Re: WML Syntax Highlighting for Kate/KWrite
They're not old per se, it's just that Kate/KWrite underwent a major reorganization as part of the KF5 port.
Author of the unofficial UtBS sequels Invasion from the Unknown and After the Storm.
Re: WML Syntax Highlighting for Kate/KWrite
Two things:
I’d also like to take this opportunity to mention that if you can figure out a way to fix the issue with
- I previously mentioned that the syntax highlighting files had been moved to the KDE ktexteditor library. Well, I was wrong. They are now in the syntax-highlighting library instead. Not sure if there were ever in ktexteditor in the first place, but then again it does look like they’ve moved things around more than once.
- I added basic support for
#arg/#endarg
and#deprecated
I’d also like to take this opportunity to mention that if you can figure out a way to fix the issue with
# metadirectives:
(# po:
, # wmllint:
, etc.) requiring that pesky space sandwiched between the leading #
and the keyword itself to be actually recognized, that’d be grand.Author of the unofficial UtBS sequels Invasion from the Unknown and After the Storm.
Re: WML Syntax Highlighting for Kate/KWrite
Hi!
A bug has been reported in the WML highlighter of Kate (KSyntaxHighlighting framework): https://bugs.kde.org/show_bug.cgi?id=402720
I have proposed a patch that fixes it and, in addition, I modified the code so that only tags with valid names are highlighted (since the highlighter considers all content between "[" and "]" as a tag.).
Proposed patch: https://phabricator.kde.org/D17891
I'm not an expert in that language, I just relied on the documentation (wiki.wesnoth.org) and the highlighter for Visual Studio Code (Bitron.wml). I hope you can check the changes and verify that everything is OK (all the details are in the previous link).
A bug has been reported in the WML highlighter of Kate (KSyntaxHighlighting framework): https://bugs.kde.org/show_bug.cgi?id=402720
I have proposed a patch that fixes it and, in addition, I modified the code so that only tags with valid names are highlighted (since the highlighter considers all content between "[" and "]" as a tag.).
Proposed patch: https://phabricator.kde.org/D17891
I'm not an expert in that language, I just relied on the documentation (wiki.wesnoth.org) and the highlighter for Visual Studio Code (Bitron.wml). I hope you can check the changes and verify that everything is OK (all the details are in the previous link).
Re: WML Syntax Highlighting for Kate/KWrite
Inside an [abilities] tag any tag name is valid:
https://wiki.wesnoth.org/AbilitiesWML#T ... ies.5D_tag
https://github.com/wesnoth/wesnoth/blob ... fg#L15-L19
Also, have you seen https://wiki.wesnoth.org/SyntaxWML#Tag_Amendment_Syntax ?
https://wiki.wesnoth.org/AbilitiesWML#T ... ies.5D_tag
https://github.com/wesnoth/wesnoth/blob ... fg#L15-L19
Also, have you seen https://wiki.wesnoth.org/SyntaxWML#Tag_Amendment_Syntax ?
Re: WML Syntax Highlighting for Kate/KWrite
With a valid tag, I mean a regular expression (alphanumeric characters and underscores), not the exact names the tags can have.
I described the tags as:
\[\+?\w*\]
\[/\s*\w*\s*]
It could also be more general:: \[[^\[\]\s]*\]
The idea is to avoid writing "[", the highlighter considers all the following code as the tag name.
EDIT: for example: https://github.com/wesnoth/wesnoth/blob ... ng.cfg#L37
I described the tags as:
\[\+?\w*\]
\[/\s*\w*\s*]
It could also be more general:: \[[^\[\]\s]*\]
The idea is to avoid writing "[", the highlighter considers all the following code as the tag name.
EDIT: for example: https://github.com/wesnoth/wesnoth/blob ... ng.cfg#L37
- beetlenaut
- Developer
- Posts: 2814
- Joined: December 8th, 2007, 3:21 am
- Location: Washington State
- Contact:
Re: WML Syntax Highlighting for Kate/KWrite
Kate also highlights array indices like this: stored_unit[1].moves. Could it be prevented by requiring a non-alphanumeric character before the opening bracket? (This is new within a few months. It used to highlight indices normally.)
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
Re: WML Syntax Highlighting for Kate/KWrite
I included it! I didn't highlight tags if there is an alphanumeric character, underscore or "]" before. Because seen that a tag is highlighted in things like: https://github.com/wesnoth/wesnoth/blob ... ng.cfg#L59
The regex that I included is: (\w+|\])\[(?!/)
In this case, the matched code is highlighted as normal text.
The regex that I included is: (\w+|\])\[(?!/)
In this case, the matched code is highlighted as normal text.
Re: WML Syntax Highlighting for Kate/KWrite
The case of
][
is tricky, since that sequence can occur both in tags ([allow_undo][/allow_undo]
, [not][true][/true][/not]
, both used in mainline) and in inline WFL/lua (x[foo][bar]
is valid lua). Your example is WFL, but it's hard to get right since it's a macro that expands to a formula, not to WML as macros usually do.Re: WML Syntax Highlighting for Kate/KWrite
I thought about that case! The rules for highlighting tags have priority, therefore, the nested tags will be highlighted correctly. The case
This is a consequence of the regex:
Also, for simplicity, I can consider array indices only if there are integers between
][
only be considered if ]
doesn't belong to the closing of a tag. In addition, [/some]
(case [/
) will always be highlighted as a tag.- text[hello] -> [hello] isn't considered a tag, since there are alphanumeric characters before.
- text[/hello] -> [/hello] is highlighted as a tag, since there is
[/
. - text[foo][bar][hello] -> In this case, tags aren't highlighted, since there are alphanumeric characters before
[foo]
. Since [foo] isn't tag, enter the case][
and neither [bar] and [hello] are highlighted. - [foo][bar][hello]text[/hello][/bar][/foo] -> Here, all the tags are highlighted! [foo], [bar] & [hello] don't have alphanumeric characters before, so they are highlighted as tags. [/hello][/bar][/foo] are also highlighted as tags.
This is a consequence of the regex:
(\w+|\])\[(?!/)
Also, for simplicity, I can consider array indices only if there are integers between
[
& ]
(and alphanumeric characters before [
); for example: "array[2]", but not "foo[text]" (regex: \w+\[(?=\d+\])
) ...or simply, eliminate the case ][
- beetlenaut
- Developer
- Posts: 2814
- Joined: December 8th, 2007, 3:21 am
- Location: Washington State
- Contact:
Re: WML Syntax Highlighting for Kate/KWrite
No, that won't work. Another common case is "foo[$index]". However, I think all the other cases would start with "$" or white space ("foo[ 100 ]").
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
Re: WML Syntax Highlighting for Kate/KWrite
In theory someone could do
foo[{MACRO}]
.Re: WML Syntax Highlighting for Kate/KWrite
If you want to check the changes, here I leave a link with the modified highlighter: https://drive.google.com/file/d/1pmqc-_ ... sp=sharing
To install it, copy the wml.xml file to
On Friday I'll do the commit (so the patch will be included in KDE Frameworks 5.54).
To install it, copy the wml.xml file to
$HOME/.local/share/org.kde.syntax-highlighting/syntax/
(for local user) or /usr/share/org.kde.syntax-highlighting/syntax/
(for all users). On Friday I'll do the commit (so the patch will be included in KDE Frameworks 5.54).