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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

(YAML) Expand allowed characters in keys #4044

Open
heiskr opened this issue Apr 25, 2024 · 3 comments
Open

(YAML) Expand allowed characters in keys #4044

heiskr opened this issue Apr 25, 2024 · 3 comments
Labels
bug good first issue Should be easier for first time contributors help welcome Could use help from community language

Comments

@heiskr
Copy link

heiskr commented Apr 25, 2024

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:

// Define keys as starting with a word character
// ...containing word chars, spaces, colons, forward-slashes, hyphens and periods
// ...and ending with a colon followed immediately by a space, tab or newline.
// The YAML spec allows for much more than this, but this covers most use-cases.
const KEY = {
className: 'attr',
variants: [
// added brackets support
{ begin: /\w[\w :()\./-]*:(?=[ \t]|$)/ },
{ // double quoted keys - with brackets
begin: /"\w[\w :()\./-]*":(?=[ \t]|$)/ },
{ // single quoted keys - with brackets
begin: /'\w[\w :()\./-]*':(?=[ \t]|$)/ },
]
};

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

@heiskr heiskr added bug help welcome Could use help from community language labels Apr 25, 2024
@joshgoebel
Copy link
Member

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

@joshgoebel joshgoebel added the good first issue Should be easier for first time contributors label Apr 26, 2024
@uniqueeest
Copy link

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

@joshgoebel
Copy link
Member

Sure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug good first issue Should be easier for first time contributors help welcome Could use help from community language
Projects
None yet
Development

No branches or pull requests

3 participants