Skip to content
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(parser) multi-class in a single mode #3081

Merged
merged 20 commits into from Apr 4, 2021

Conversation

joshgoebel
Copy link
Member

@joshgoebel joshgoebel commented Mar 27, 2021

Resolves #2838.

Changes

Adds multi-class highlighting:

{
        begin: [
          /function|function!/,
          /\s+/,
          hljs.IDENT_RE
        ],
        className: {
          1: "keyword",
          3: "title"
        },
}

Checklist

  • Added markup tests, or they don't apply here because...
  • needs unit tests
  • [x ] docs
  • Updated the changelog at CHANGES.md

@joshgoebel joshgoebel mentioned this pull request Mar 27, 2021
25 tasks
@joshgoebel joshgoebel marked this pull request as draft March 27, 2021 14:12
@joshgoebel joshgoebel mentioned this pull request Mar 27, 2021
3 tasks
@joshgoebel joshgoebel added this to the 11.0 alpha 1 milestone Mar 28, 2021
@joshgoebel joshgoebel marked this pull request as ready for review April 1, 2021 17:19
@joshgoebel joshgoebel marked this pull request as draft April 3, 2021 21:37
Copy link
Member

@allejo allejo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Loving the simplicity needed to add this feature

src/lib/ext/multi_class.js Show resolved Hide resolved
src/lib/ext/multi_class.js Outdated Show resolved Hide resolved
src/lib/ext/multi_class.js Outdated Show resolved Hide resolved
docs/mode-reference.rst Outdated Show resolved Hide resolved
src/lib/ext/multi_class.js Show resolved Hide resolved
@joshgoebel joshgoebel marked this pull request as ready for review April 4, 2021 04:39
Copy link
Member

@allejo allejo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems pretty sane to me

Edit: Waittttttt! See #3081 (review)

@@ -206,7 +206,8 @@ type CompiledMode = Omit<Mode, 'contains'> &
endRe: RegExp
illegalRe: RegExp
matcher: any
isCompiled: true
isCompiled: true,
isMultiClass?: boolean,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
isMultiClass?: boolean,
isMultiClass?: true,

If there's no time it'll ever false, should the type be true instead of boolean?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps technically, but that bugs me though i can't explain it. This isn't the same as isCompiled IMHO.

src/highlight.js Outdated Show resolved Hide resolved
docs/mode-reference.rst Outdated Show resolved Hide resolved
@joshgoebel joshgoebel merged commit 05a2770 into highlightjs:main Apr 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Proposal: Support multi-class highlighting inside a single mode/rule
2 participants