highlightjs / highlight.js

JavaScript syntax highlighter with language auto-detection and zero dependencies.
https://highlightjs.org/
BSD 3-Clause "New" or "Revised" License
23.3k stars 3.52k forks source link

(YAML) Expand allowed characters in keys #4044

Open heiskr opened 2 months ago

heiskr commented 2 months ago

Describe the issue

👋 Hello hello from GitHub Docs! We use highlight.js and are very grateful for your maintenance.

https://docs.github.com/en/copilot/managing-github-copilot-in-your-organization/configuring-content-exclusions-for-github-copilot#example-of-repositories-and-paths-in-organization-settings

We have a little syntax highlighting problem with a few YAML keys.

Image

You can see GitHub.com (Ruby) handling it a little better:

# Ignore all `.env` files in any location.
# This could also have been written on a single line as:
#
# "*": ["**/.env"]
"*":
  - "**/.env"

# In the `octo-repo` repository in this organization:
octo-repo:
  # Ignore the `/src/kernel.rs` file.
  - "/src/kernel.rs"

# In the `primer/react` repository on {% data variables.product.prodname_dotcom %}:
https://github.com/primer/react.git:
  # Ignore any files in or below the `/e2e` directory.
  - "/e2e/**"

# In the `copilot` repository of any {% data variables.product.prodname_dotcom %} organization:
git@github.com:*/copilot:
  # Ignore any files in or below the `/__tests__` directory.
  - "/__tests__/**"
  # Ignore any files in the `/script` directory.
  - "/script/*"

# In the `gitlab-org/gitlab-runner` repository on GitLab:
git@gitlab.com:gitlab-org/gitlab-runner.git:
  # Ignore the `/main_test.go` file.
  - "/main_test.go"
  # Ignore any files in any `packages` directories, anywhere in this repository.
  - "**/packages/*"
  # Ignore any files with names beginning `server` or `session`, anywhere in this repository.
  - "**/{server,session}*"
  # Ignore any files with names ending `.md` or `.mk`, anywhere in this repository.
  - "**/*.m[dk]"

I believe the relevant code would be here:

https://github.com/highlightjs/highlight.js/blob/583cb33627474ff577305dc787f9a2a09eaf3b88/src/languages/yaml.js#L16-L30

For our purposes we would need @ and * supported, but I believe there's a wider range of supported characters for YAML keys.

Which language seems to have the issue?

YAML

Are you using highlight or highlightAuto?

highlight

Sample Code to Reproduce

See description above

Expected behavior

See description Additional context

N/A

joshgoebel commented 2 months ago

I'd say a PR would be welcome for this.

uniqueeest commented 2 months ago

Hello! @joshgoebel. I'm interested in this issue. Can I ask for your help if I need it during the resolution?

joshgoebel commented 2 months ago

Sure.