Skip to content

Multi-Class / multi-matching breaks wrapping matcher #3101

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

Closed
NullVoxPopuli opened this issue Apr 3, 2021 · 2 comments
Closed

Multi-Class / multi-matching breaks wrapping matcher #3101

NullVoxPopuli opened this issue Apr 3, 2021 · 2 comments
Labels
bug help welcome Could use help from community language

Comments

@NullVoxPopuli
Copy link
Contributor

Describe the issue
I'm trying to highlight an HTML-like language, with this:

const TAG_NAME_RE = regex.concat(/[A-Z_]/, regex.optional(/[A-Z0-9:_.-]*:/), /[A-Z0-9_.-]*/);

  return {
    name: 'Ember.JS, Glimmer',
    aliases: [
      'hbs',
      'html.hbs',
      'html.handlebars',
      'htmlbars'
    ],
    case_insensitive: true,
    contains: [
      hljs.COMMENT(/\{\{!--/, /--\}\}/),
      hljs.COMMENT(/\{\{!/, /\}\}/),
      hljs.COMMENT(/<!--/, /-->/),
      // open tag
      {
        className: 'tag',
        begin: regex.concat(
          /<:?/,
          regex.lookahead(regex.concat(
            TAG_NAME_RE,
            regex.either(/\/>/, />/, /\s/)
          ))
        ),
        end: /\/?>/,
        contains: [
    className: {
      1: 'attribute',
      2: 'operator'
    },
    match: [
      /[A-Za-z0-9-_]+/,
      /=/
    ]
        ]
      },
    ]
  };

Which language seems to have the issue?
I'm writing it :)

Are you using highlight or highlightAuto?

Whatever the developer.html uses
...

Sample Code to Reproduce

<AngleBraketComponent
  @mustache={{@bla}}
  @number=123
  {{modifier @arg (sub-exp 1 "<- num" (concat "string" "another"))}}
  data-test-id="test"
  class="my-class" as |test|>

The developer.html shows:
image

Expected behavior
The tag wraps all the way around until the >

Additional context
if you clear the contains array, the tag is correctly outlining the entire tag.

@NullVoxPopuli NullVoxPopuli added bug help welcome Could use help from community language labels Apr 3, 2021
@joshgoebel
Copy link
Member

Note to self: This is a bug in #3081. startsMode accounts for the new multi-class stuff, but endsMode doesn't so it's closing an extra tag that it should not.

NullVoxPopuli added a commit to NullVoxPopuli/highlight.js that referenced this issue Apr 3, 2021
@joshgoebel
Copy link
Member

Fixed in the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug help welcome Could use help from community language
Projects
None yet
Development

No branches or pull requests

2 participants