Skip to content

lexers.DelegatingLexer always does not highlight tokens correctly #960

@Delta456

Description

@Delta456

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

I am currently working on a feature for charmbracelet/freeze which makes use of the chroma library and I am using the DelegatingLexer where I am passing two languages py and go as the language and root respectively. My PR implementation can be seen here: charmbracelet/freeze#79

Using

  • ./freeze --language py,go file.py gives
    image

  • ./freeze --language go,py file.py gives
    image

As it can be seen chroma doesn't highlight the root of the lexers.DelegatingLexer. Only the language part is highlighted. However, this is not always the case.

  • ./freeze --language jinja,html file.jinja gives

image

  • ./freeze --language jinja file.jinja gives

image

In this case, jinja,html languages correctly highlight the code snippet.

To Reproduce

Chroma Playground doesn't support syntax highlighting of two languages at one time.

To locally reproduce this:

Contents of file.py:

def hello():
    print('hello world')

func Hello() {
    fmt.Println("Hello world")
} 

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions