#  markdown: Use first word of fenced code block info string as language \(\#64694\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/25303a4b25d141456b483081aa2843483aec9c46)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 25303a4b25d141456b483081aa2843483aec9c46

Requested commit: 25303a4b25d141456b483081aa2843483aec9c46

Commit: 25303a4b25d141456b483081aa2843483aec9c46

Tree: 825c7163d4230a9dc8c8cc89c02df10f18b07bdf

Author: Max Malkin

Committer: GitHub

## Message

`````
 markdown: Use first word of fenced code block info string as language (#64694)

# Objective

- Fixes #62765

Fenced code blocks with extra content after the language (e.g. ````
```ts import.meta.vitest ````) weren't syntax highlighted, since the
whole info string was used as the language name.

## Solution

- Resolve the language from the first whitespace-separated word of the
info string, per CommonMark. The full info string is still stored, so
mermaid scale options keep working.

## Testing

- Added `test_code_block_language_uses_first_word_of_info_string`.
- Existing `markdown` code block tests pass on Linux.

## Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content adheres to Zed's UI standards
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

---

Release Notes:

- Fixed syntax highlighting for fenced code blocks with extra text after
the language name.
`````

## Parents

- [8720fd1d093963be0aeb36954c15fd1aca1b94d2](https://git.cafe/gitcafe/zed/commit/8720fd1d093963be0aeb36954c15fd1aca1b94d2?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/25303a4b25d141456b483081aa2843483aec9c46?format=markdown)
