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
Stylus: Add color
, entity
, unit
, change number
and operator
in inside
object, Fix relational tests.
#2368
Conversation
…g detection, and added corresponding unit test.
… in `inside` object, Fix relational tests.
components/prism-stylus.js
Outdated
}; | ||
// 123 -123 .123 -.123 12.3 -12.3 | ||
var number = { | ||
pattern: /(^|[^\w.-]|)-?\d*\.?\d+/, |
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.
Isn't the lookbehind supposed to be (^|[^\w.-])
?
the |
The previous issue with It should also work here. |
I have read that issue, but don't understand how |
And in your opinion, how should I modify the code |
PHP uses Markup templating. Markup templating (MT) will replace all occurrences of some regex in code with a placeholder. PHP gives MT this regex to replace all PHP blocks with a placeholder. So, why couldn't MT find the placeholder All I had to do to fix the issue was to prevent the
Sorry, but what do you want to change? |
I have already understand, it means the CSS tokenize wrongly handle the placeholder which PHP tokenize set. But if we define a special placeholder which all tokenizes can distinguish and ignore it,
Back to this PR, you raised two questions. The first is about If all of the placeholders are both grammar like |
There is an extra
It is. But it is a simple solution. For example, the CSS language before the |
That's true. Maybe I should add a test that just checks that a literal is always tokenized as one? |
I didn't notice this extra But in your opinion, So I removed the |
Thank you for contributing! |
This adds `color`, `unit`, and `entity` tokens. The `number` and `operator` patterns were also improved.
I noticed some definitions in CSS are not exist in Stylus, then add them which copied from
css-extras
.In addition, some modifications have been made.
about
number
definitionI noticed
number
definition in previous Stylus was/\b\d+(?:\.\d+)?%?/
, it includes%
, but in CSS-extra was/(^|[^\w.-]|)-?\d*\.?\d+/
. In fact, the CSS types include<percent>
,<integer>
,<number>
and more in CSS Level. Strictly speaking, they should be defined separately, but for code highlighting, we can think of%
asunit
, it is also the css-extra language's behavior.Of course, we can also do above 'strictly speaking' later.
about
operator
definitionI noticed the
.
inoperator
could refer to..
or...
in1...5
and1..5
, it always repeated 2 or 3 times. If we don't change it, it would separate1..5
into1
,.
and.5
, it may not be the result we expected.In fact, in my opinion, the
variable-declaration
,property-declaration
andatrule-declaration
should use the differentinside
property, because they have their own grammer. If we separate them, it might avoid more possible bugs.After I do these modification, I changed all of affected tests, such as
red
incolor red
,px
in5px
. so I believe that the previous tests can check the correctness of added code.