-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
enh(perl) add support for the new class system #3856
Conversation
Build Size ReportChanges to minified artifacts in 2 files changedTotal change +205 B View Changes
|
f537618
to
ad0ea73
Compare
test/markup/perl/class.expect.txt
Outdated
<span class="hljs-keyword">field</span> $_name<span class="hljs-attribute"> : param</span> = <span class="hljs-string">'Test'</span>; | ||
|
||
<span class="hljs-function"><span class="hljs-keyword">method</span> <span class="hljs-title">test</span>() </span>{ | ||
$_name == <span class="hljs-string">'Test'</span> ? <span class="hljs-string">'y'</span> : <span class="hljs-string">'n'</span>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would we want to tag the identifier portion of these as variables? Ie, $_name
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh! I completely missed it. Yes! It should be tagged. I'll get it done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, it turns out that all tests were ignoring the presence of variables due to the missing variable
scope and changing it also required to change Mojolicious (src/languages/mojolicious.js
) test case, which also had a conflict with the %=
tag. I pushed 2 new commits to get variables to work.
Build Size ReportChanges to minified artifacts in 5 files changedTotal change +229 B View Changes
|
I was not able to reproduce the "Node.js CI/build" failure locally, but looking at the logs I'm not sure it's something related to the changes. At the same time, the Lint error also occurs in the What am I missing? |
Yeah, something isn't happy... I'll try to find some time to look at it soon. |
Floating points numbers (eg. `2.34`, `0.54` and `.54`) were not being matched correctly. This patch splits the number class regex in different variants to make things clearer and also adds variants to better match floating points, including the `_` character, and also the special case of version numbers (eg. v5.38). Markup test for the new number class was also added.
Perl got a new builtin class support which brought new keywords like `class`, `method` and `field`, being that some support versioning and attributes. This commit adds the new keywords with the additional features they support (eg. attributes and version), alongside their markup test.
The VAR mode had no `scope` set, thus Perl variables were not being matched and highlighted at all. This commit adds the `variable` scope and update all tests to consider the new `<span class="variable"></span>`, including those that use Perl as sub-language (eg. Mojolicious).
Mojolicious uses `%=` as one of the ways to inform the templating engine Perl code will be embedded after it, however, it was being matched against Perl's variable scope, `<span class="variable">%=</span>`, even though it's not a valid Perl variable. This commit updates one of the Perl's variable variants in other to allow only `$=` as valid variable for it, which has special meaning, while `@=` and `%=` are not valid, thus solving the conflict with the tag used by Mojolicious.
Add the required line to the CHANGES.md file.
Build Size ReportChanges to minified artifacts in 3 files changedTotal change +225 B View Changes
|
Thanks for the help! |
This PR brings the highlight support for the new Perl class system (
Cor
) by adding the keywordsclass
,method
andfield
and their supported additional features, like attributes and version number.For getting it done, the regex for matching numbers were reworked because floating points were not fully supported alongside the use of
_
in between number digits.Resolves #3855