contains 'self' is ambiguous with `variants`
See original GitHub issueI have a minor issue with http://highlightjs.readthedocs.org/en/latest/reference.html#variants in combination with self
. Here’s an example language
return {
contains: [
{
className: 'test',
variants: [
{
begin: '<',
end: '>'
},
{
begin: '\\{',
end: '\\}'
}
],
contains: [
'self'
]
}
]
};
This would match nested pairs of <<>>
as well as {{}}
- but not the inner part of a mixed form like <{}>
. It seems like self
refers to specific mode variant.
Sure, I can write two different modes to get this done where every mode contains the respectively other modes plus self
.
But I think it would be much more simply to have it “full recursive”. Or at least the docs should be more specific at this point.
To get it work, the example language has to be defined this way
var test1 = {
className: 'test',
begin: '<',
end: '>',
contains: []
};
var test2 = {
className: 'test',
begin: '\\{',
end: '\\}',
contains: []
};
test2.contains.push(test1, 'self');
test1.contains.push(test2, 'self');
return {
contains: [
test1,
test2
]
};
Wolfgang
Issue Analytics
- State:
- Created 8 years ago
- Reactions:1
- Comments:5 (5 by maintainers)
Top Results From Across the Web
lazy sequence: ambiguous use of 'filter' - Apple Developer
I'm currently experimenting with sequences and encountered the following strange behaviour. Suppose I have the following unlimited sequence of Fibonacci numbers ...
Read more >ambiguous column name 'VALUE' - Stack Overflow
I'm trying to flatten the nested JSON data using the below query by selecting the value from variant column, However getting ambiguous ......
Read more >Just-in-Time Mode - Tailwind CSS
You can use variants like focus-visible , active , disabled , even , and more in combination with any utility, without making any...
Read more >ambiguous use of operator '<' · Issue #1041 - GitHub
The project should be short, self-contained, and correct example. ... Fixes #1041 and #1038 on linux variants #1048.
Read more >Individual differences in social hypersensitivity predict the ...
Ambiguity may be an unavoidable part of everyday interactions. The reactions of socially hypersensitive people (i.e., self-esteem contingent on ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@yyyc514 here’s the problem. When you come onto a mode with
variants
, expanding it produces two independent modes like these:And by the time the recursive process in
compileMode
gets to thosecontains
, each'self'
can only refer to one concrete variant of the original mode. I don’t know how to fix it. If you teachexpand_mode
how to deal with'self'
incontains
, it would mean making it recursive? Inside of the already recursivecompileMode
?All in all, it’s not something I can actually help with, sorry!
@WolfgangKluge If you were doing this often or commonly though you’d wrap that up in a nice little helper, so it really wouldn’t be as bad as you’re making it out. I tagged this docs as it wouldn’t hurt to explain this behavior somewhere as you suggested.