mirror of
https://github.com/zed-industries/zed.git
synced 2026-04-18 07:47:53 +00:00
b150663d45
## What does this PR did - Generate [GitHub-flavored heading slugs](https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#section-links) for markdown headings - Handle `[label](#heading)` same-document anchor links that scroll the preview and editor to the target heading - Handle `[label](./file.md#heading)` cross-file anchor links that open the file, scroll the preview, and move the editor cursor to the heading https://github.com/user-attachments/assets/ecc468bf-bed0-4543-a988-703025a61bf8 ## What to test - [ ] Create a markdown file with `[Go to section](#section-name)` links, verify clicking scrolls preview and editor - [ ] Create two markdown files with cross-file links like `[See other](./other.md#heading)`, verify file opens and preview scrolls to heading - [ ] Verify duplicate headings produce correct slugs (`heading`, `heading-1`) - [ ] Verify external URLs (`https://...`) are unaffected Self-Review Checklist: - [x] I've reviewed my own diff for quality, security, and reliability - [ ] Unsafe blocks (if any) have justifying comments - [x] The content is consistent with the [UI/UX checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) - [x] Tests cover the new/changed behavior - [ ] Performance impact has been considered and is acceptable Closes #18699 Release Notes: - Added support for anchor links for headings in Markdown Preview. --------- Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com>