Skip to content

Keep c#, c++ and f# as the language of Markdown code blocks - #18139

Merged
matthewp merged 2 commits into
withastro:mainfrom
breken-ai:fix/highlight-language-symbols
Sep 27, 2026
Merged

matthewp merged 2 commits into
withastro:mainfrom
breken-ai:fix/highlight-language-symbols

Conversation

@breken-ai

Copy link
Copy Markdown
Contributor

Changes

  • Markdown code blocks whose language ends in a symbol were highlighted as a different language. ```c# and ```c++ were highlighted with the C grammar and got data-language="c", and ```f# became f. Shiki registers c#, c++ and f# as aliases for csharp, cpp and fsharp, so these blocks now get the right grammar and data-language.
  • The cause is the language- class pattern in highlightCodeBlocks (packages/markdown/remark/src/highlight.ts). It ended with \b, and there is no word boundary after a trailing # or +, so the match backtracked to c or f. The pattern no longer ends with \b. \S+ already stops at whitespace, so class strings with several classes still work.
  • This only affects the remark processor. The Sätteri processor reads the language from data.lang or strips the language- prefix, so it already kept c#.
  • With syntaxHighlight: 'prism', ```c++ and ```c# now go to Prism unchanged. Prism has no grammar under those names, so those blocks are left unhighlighted and Prism logs its usual "Unable to load the language" warning, the same as <Prism lang="c++" />. Before, they were highlighted with the C grammar.

Testing

  • Added keeps symbols at the end of the code block language to packages/markdown/remark/test/highlight.test.ts. It renders ```c#, ```c++ and ```f# blocks and checks that each one keeps its language in data-language. It fails on main (data-language="c") and passes with this change. The whole @astrojs/markdown-remark suite passes (80/80), and tsc -b, Biome and Prettier are clean.

Docs

  • No docs update needed. This is a bug fix for languages that Shiki already documents as supported.

An AI agent (Breken, using Claude Code) found and fixed this bug, and the test above proves it.

🤖 Generated with Claude Code

The language class pattern ended with a word boundary, so `language-c#` and `language-c++` matched as `c` and `language-f#` as `f`.
@changeset-bot

changeset-bot Bot commented Sep 26, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: d891a2b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@astrojs/markdown-remark Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions Bot added the feat: markdown Related to Markdown (scope) label Sep 26, 2026
@matthewp
matthewp merged commit d047b5c into withastro:main Sep 27, 2026
24 checks passed
@astrobot-houston astrobot-houston mentioned this pull request Sep 27, 2026
dadezzz pushed a commit to dadezzz/university_notes that referenced this pull request Oct 10, 2026
This PR contains the following updates:

| Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) |
|---|---|---|---|
| [@astrojs/markdown-remark](https://astro.build) ([source](https://github.com/withastro/astro/tree/HEAD/packages/markdown/remark)) | [`7.3.1` → `7.3.2`](https://renovatebot.com/diffs/npm/@astrojs%2fmarkdown-remark/7.3.1/7.3.2) | ![age](https://developer.mend.io/api/mc/badges/age/npm/@astrojs%2fmarkdown-remark/7.3.2?slim=true) | ![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@astrojs%2fmarkdown-remark/7.3.1/7.3.2?slim=true) |
| [astro](https://astro.build) ([source](https://github.com/withastro/astro/tree/HEAD/packages/astro)) | [`7.3.5` → `7.3.6`](https://renovatebot.com/diffs/npm/astro/7.3.5/7.3.6) | ![age](https://developer.mend.io/api/mc/badges/age/npm/astro/7.3.6?slim=true) | ![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/astro/7.3.5/7.3.6?slim=true) |

---

### Release Notes

<details>
<summary>withastro/astro (@&#8203;astrojs/markdown-remark)</summary>

### [`v7.3.2`](https://github.com/withastro/astro/blob/HEAD/packages/markdown/remark/CHANGELOG.md#732)

[Compare Source](https://github.com/withastro/astro/compare/@astrojs/markdown-remark@7.3.1...@astrojs/markdown-remark@7.3.2)

##### Patch Changes

- [#&#8203;18099](withastro/astro#18099) [`6987261`](withastro/astro@6987261) Thanks [@&#8203;renovate](https://github.com/apps/renovate)! - Adds YAML parsing with timestamp and merge key support, and formats YAML errors consistently across Astro, Markdown, MDX, and Markdoc.

- [#&#8203;18139](withastro/astro#18139) [`d047b5c`](withastro/astro@d047b5c) Thanks [@&#8203;breken-ai](https://github.com/breken-ai)! - Fixes Markdown code blocks with languages ending in a symbol, such as `c#`, `c++`, and `f#`, being highlighted as `c` or `f`

- Updated dependencies \[[`6987261`](withastro/astro@6987261), [`62b13ba`](withastro/astro@62b13ba)]:
  - [@&#8203;astrojs/internal-helpers](https://github.com/astrojs/internal-helpers)@0.12.0

</details>

<details>
<summary>withastro/astro (astro)</summary>

### [`v7.3.6`](https://github.com/withastro/astro/blob/HEAD/packages/astro/CHANGELOG.md#736)

[Compare Source](https://github.com/withastro/astro/compare/astro@7.3.5...astro@7.3.6)

##### Patch Changes

- [#&#8203;18166](withastro/astro#18166) [`5134d0f`](withastro/astro@5134d0f) Thanks [@&#8203;astro-factory](https://github.com/apps/astro-factory)! - Fixes an intermittent dev server crash when using `astro:actions` inside a server island with adapters that use a pre-bundled SSR environment (e.g. `@astrojs/cloudflare`)

- [#&#8203;18076](withastro/astro#18076) [`8a2df66`](withastro/astro@8a2df66) Thanks [@&#8203;astro-factory](https://github.com/apps/astro-factory)! - Fixes stale scoped styles during HMR when both markup and `<style>` are changed in a single save

- [#&#8203;18252](withastro/astro#18252) [`2d29e7e`](withastro/astro@2d29e7e) Thanks [@&#8203;astro-factory](https://github.com/apps/astro-factory)! - Fixes CSS from other pages leaking into a page's `<head>` in dev when the page imports a module such as `astro:config/server`.

- [#&#8203;18000](withastro/astro#18000) [`6724575`](withastro/astro@6724575) Thanks [@&#8203;barclayd](https://github.com/barclayd)! - Fixes a bug where server islands containing framework components rendered empty in the dev server when using a custom `src/fetch.ts`

- [#&#8203;18241](withastro/astro#18241) [`7c5fd6f`](withastro/astro@7c5fd6f) Thanks [@&#8203;astro-factory](https://github.com/apps/astro-factory)! - Fixes the composable `i18n()` handler from `astro/fetch` and `astro/hono` returning an empty 404 for paths without a locale prefix. It now renders the custom 404 page, matching `astro()`.

- [#&#8203;18164](withastro/astro#18164) [`1a6997f`](withastro/astro@1a6997f) Thanks [@&#8203;astro-factory](https://github.com/apps/astro-factory)! - Fixes CSS Module HMR in dev when a component is rendered both with and without hydration on the same page. Astro now uses path-based class name hashing in dev mode so that editing CSS declarations no longer changes the generated selectors, allowing Vite's CSS HMR to update styles without a full page reload.

- [#&#8203;18243](withastro/astro#18243) [`dd29d62`](withastro/astro@dd29d62) Thanks [@&#8203;astro-factory](https://github.com/apps/astro-factory)! - Fixes `context.props` being `null` in middleware and endpoints when the composable `astro/hono` or `astro/fetch` `actions()` handler runs before `middleware()`, or when `pages()` runs without `middleware()`

- [#&#8203;18193](withastro/astro#18193) [`95d5d16`](withastro/astro@95d5d16) Thanks [@&#8203;astro-factory](https://github.com/apps/astro-factory)! - Fixes `astro build` failing on Windows with Node.js 25+ with `ERR_INVALID_ARG_VALUE` when clearing the output directory hits a transient `EPERM` error

- [#&#8203;18220](withastro/astro#18220) [`d6c13a4`](withastro/astro@d6c13a4) Thanks [@&#8203;astro-factory](https://github.com/apps/astro-factory)! - Fixes type errors reported in Astro's built-in `<Picture />` and `<Font />` components when type-checking a project with `tsc` and `@astrojs/ts-content-mapper`

- [#&#8203;18133](withastro/astro#18133) [`faac481`](withastro/astro@faac481) Thanks [@&#8203;astro-factory](https://github.com/apps/astro-factory)! - Fixes lost request state when Vite discovers server dependencies during a request in Cloudflare dev mode

- [#&#8203;18146](withastro/astro#18146) [`2af4516`](withastro/astro@2af4516) Thanks [@&#8203;astro-factory](https://github.com/apps/astro-factory)! - Fixes CSS imported from an `injectScript('page')` script being dropped during build

- [#&#8203;18159](withastro/astro#18159) [`e5f8fe0`](withastro/astro@e5f8fe0) Thanks [@&#8203;astro-factory](https://github.com/apps/astro-factory)! - Fixes a hang when a `server:defer` component is inside a slot of another component in an MDX content collection entry

- [#&#8203;18246](withastro/astro#18246) [`c3b42ad`](withastro/astro@c3b42ad) Thanks [@&#8203;astro-factory](https://github.com/apps/astro-factory)! - Fixes the `glob()` loader skipping content files whose paths contain `#` or `?`

- [#&#8203;18248](withastro/astro#18248) [`b97184e`](withastro/astro@b97184e) Thanks [@&#8203;astro-factory](https://github.com/apps/astro-factory)! - Fixes a bug where page routes added with `injectRoute()` returned a 404 when `i18n.routing.prefixDefaultLocale` was `true` and the route path had no locale prefix

- [#&#8203;18251](withastro/astro#18251) [`3415263`](withastro/astro@3415263) Thanks [@&#8203;astro-factory](https://github.com/apps/astro-factory)! - Fixes content collection changes being ignored in `astro dev` after the dev server restarts because of a config change

- [#&#8203;18226](withastro/astro#18226) [`ad54af0`](withastro/astro@ad54af0) Thanks [@&#8203;imharjot](https://github.com/imharjot)! - Fixes `Astro.cookies.get()` returning `undefined` for request cookies with empty values

- [#&#8203;18155](withastro/astro#18155) [`37ab0e4`](withastro/astro@37ab0e4) Thanks [@&#8203;astro-factory](https://github.com/apps/astro-factory)! - Fixes nondeterministic ordering of the server manifest's `assets` array, ensuring builds with identical inputs produce byte-identical output

- [#&#8203;18099](withastro/astro#18099) [`6987261`](withastro/astro@6987261) Thanks [@&#8203;renovate](https://github.com/apps/renovate)! - Adds YAML parsing with timestamp and merge key support, and formats YAML errors consistently across Astro, Markdown, MDX, and Markdoc.

- [#&#8203;15595](withastro/astro#15595) [`64e4039`](withastro/astro@64e4039) Thanks [@&#8203;qzio](https://github.com/qzio)! - Improves CSRF protection by taking modern browsers headers into account

- [#&#8203;18215](withastro/astro#18215) [`941bd5e`](withastro/astro@941bd5e) Thanks [@&#8203;ump45nose](https://github.com/ump45nose)! - Fixes a runtime `ReferenceError` for inlined scripts that import a URL with `/* @vite-ignore */`.

  Astro now inlines scripts after Vite replaces its preload markers, so ignored dynamic imports can remain inline without shipping an unresolved `__VITE_PRELOAD__` reference.

- [#&#8203;18179](withastro/astro#18179) [`6caa659`](withastro/astro@6caa659) Thanks [@&#8203;matthewp](https://github.com/matthewp)! - Fixes custom View Transition direction names that are not valid CSS identifiers, such as names starting with a digit or containing spaces. These directions now match their animations correctly.

- [#&#8203;18250](withastro/astro#18250) [`7eae39b`](withastro/astro@7eae39b) Thanks [@&#8203;astro-factory](https://github.com/apps/astro-factory)! - Fixes a 404 for a CSS file that a dynamic import preloads when the imported module uses a component that is also a hydrated island on the same page

- [#&#8203;18176](withastro/astro#18176) [`7c9d00d`](withastro/astro@7c9d00d) Thanks [@&#8203;astro-factory](https://github.com/apps/astro-factory)! - Fixes duplicate CSS in production builds when a component is both server-rendered and used with `client:only` on the same page

- [#&#8203;18245](withastro/astro#18245) [`492e95f`](withastro/astro@492e95f) Thanks [@&#8203;astro-factory](https://github.com/apps/astro-factory)! - Fixes the composable `astro/fetch` and `astro/hono` handlers (`trailingSlash()`, `redirects()`, `actions()`, `middleware()`, and `pages()`) so they reject over-encoded request paths with a `400 Bad Request`, matching `astro()`. For these requests, `redirects()` and `actions()` return the `400` response instead of `undefined`, so no redirect is issued and no action runs.

- [#&#8203;18078](withastro/astro#18078) [`0a2ab10`](withastro/astro@0a2ab10) Thanks [@&#8203;manuelgruber](https://github.com/manuelgruber)! - Fixes `Astro.rewrite()` and `context.rewrite()` selecting the wrong route in `astro dev` when two dynamic routes match the same path

- [#&#8203;18210](withastro/astro#18210) [`62b13ba`](withastro/astro@62b13ba) Thanks [@&#8203;edmundhung](https://github.com/edmundhung)! - Allows Astro CLI commands to install tagged package versions

- [#&#8203;18069](withastro/astro#18069) [`d39eb97`](withastro/astro@d39eb97) Thanks [@&#8203;astro-factory](https://github.com/apps/astro-factory)! - Fixes a dev server dependency scan failure when an `.astro` file contains a literal `<script` in frontmatter or a template expression

- [#&#8203;18114](withastro/astro#18114) [`c17d920`](withastro/astro@c17d920) Thanks [@&#8203;matthewp](https://github.com/matthewp)! - Fixes Astro on StackBlitz and other WebContainer environments

- [#&#8203;18088](withastro/astro#18088) [`cb767f9`](withastro/astro@cb767f9) Thanks [@&#8203;astro-factory](https://github.com/apps/astro-factory)! - Fixes a `MODULE_LEVEL_DIRECTIVE` warning during build caused by a stale `"use astro:head-inject"` directive in content collection propagated asset modules

- [#&#8203;18247](withastro/astro#18247) [`2b3f73d`](withastro/astro@2b3f73d) Thanks [@&#8203;astro-factory](https://github.com/apps/astro-factory)! - Fixes actions returning 500 for malformed JSON request bodies and undecodable action names. A `SyntaxError` from invalid JSON now returns 400 (`BAD_REQUEST`), and a `URIError` from a malformed percent-encoded action name now returns 404 (`NOT_FOUND`).

- [`1d9e910`](withastro/astro@1d9e910) Thanks [@&#8203;matthewp](https://github.com/matthewp)! - Validates the `Host` header against `security.allowedDomains` when using the Node adapter

- [#&#8203;18249](withastro/astro#18249) [`c7799a4`](withastro/astro@c7799a4) Thanks [@&#8203;astro-factory](https://github.com/apps/astro-factory)! - Fixes the `fontsource` font provider to resolve variable fonts when using the "Variable" suffix in the font name (e.g. `"Inter Variable"`)

- [#&#8203;18163](withastro/astro#18163) [`e48da9d`](withastro/astro@e48da9d) Thanks [@&#8203;astro-factory](https://github.com/apps/astro-factory)! - Fixes `<video muted>` losing its muted state after a ClientRouter navigation in Chrome

- [#&#8203;18244](withastro/astro#18244) [`f67e7f7`](withastro/astro@f67e7f7) Thanks [@&#8203;astro-factory](https://github.com/apps/astro-factory)! - Fixes localized error pages such as `src/pages/pt/404.astro` returning a `200` status when rendered through the `pages()` handler from `astro/fetch` or `astro/hono`

- [#&#8203;18242](withastro/astro#18242) [`c5275e3`](withastro/astro@c5275e3) Thanks [@&#8203;astro-factory](https://github.com/apps/astro-factory)! - Fixes `experimental_AstroContainer` output including dev toolbar `data-astro-source-file` and `data-astro-source-loc` attributes when rendering components under Vitest

- Updated dependencies \[[`6987261`](withastro/astro@6987261), [`62b13ba`](withastro/astro@62b13ba)]:
  - [@&#8203;astrojs/internal-helpers](https://github.com/astrojs/internal-helpers)@0.12.0
  - [@&#8203;astrojs/markdown-satteri](https://github.com/astrojs/markdown-satteri)@0.4.3

</details>

---

### Configuration

📅 **Schedule**: (UTC)

- Branch creation
  - At any time (no schedule defined)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

👻 **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://github.com/renovatebot/renovate/discussions) if that's undesired.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate CLI](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0NC4xNDguNCIsInVwZGF0ZWRJblZlciI6IjQ0LjE0OC40IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat: markdown Related to Markdown (scope)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants