question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

contains 'self' is ambiguous with `variants`

See original GitHub issue

I 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:closed
  • Created 8 years ago
  • Reactions:1
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
isagalaevcommented, Oct 22, 2019

@yyyc514 here’s the problem. When you come onto a mode with variants, expanding it produces two independent modes like these:

[ { ..., contains: ['self']}, { ..., contains: ['self']} ]

And by the time the recursive process in compileMode gets to those contains, each 'self' can only refer to one concrete variant of the original mode. I don’t know how to fix it. If you teach expand_mode how to deal with 'self' in contains, it would mean making it recursive? Inside of the already recursive compileMode?

All in all, it’s not something I can actually help with, sorry!

0reactions
joshgoebelcommented, Oct 22, 2019

To get it work, the example language has to be defined this way

@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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found