# vscode-markdown-languageservice

> Markdown language service

Latest version **0.5.0** (published 2026-06-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install vscode-markdown-languageservice
pnpm add vscode-markdown-languageservice
yarn add vscode-markdown-languageservice
bun add vscode-markdown-languageservice
```

## Health

**Score 60/100 (C)** — status: active.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.5.0 |
| Published | 2026-06-09 |
| First published | 2022-07-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=22 |
| Dependencies | 6 |
| Unpacked size | 275.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Microsoft Corporation |
| Maintainers | microsoft1es, microsoft-oss-releases, alexandrudima, kaimaetzel, sbatten, lszomoru, vscode-bot |

## Links

- npm: https://www.npmjs.com/package/vscode-markdown-languageservice
- Repository: https://github.com/microsoft/vscode-markdown-languageservice
- Homepage: https://github.com/microsoft/vscode-markdown-languageservice#readme
- Issues: https://github.com/microsoft/vscode-markdown-languageservice/issues
- npm.io page: https://npm.io/package/vscode-markdown-languageservice

## Dependencies (6)

- [picomatch](https://npm.io/package/picomatch.md) ^2.3.1
- [vscode-uri](https://npm.io/package/vscode-uri.md) ^3.0.7
- [@vscode/l10n](https://npm.io/package/@vscode/l10n.md) ^0.0.18
- [node-html-parser](https://npm.io/package/node-html-parser.md) ^6.1.5
- [vscode-languageserver-protocol](https://npm.io/package/vscode-languageserver-protocol.md) ^3.17.1
- [vscode-languageserver-textdocument](https://npm.io/package/vscode-languageserver-textdocument.md) ^1.0.11

## Recent versions

- 0.5.0 (latest) — 2026-06-09
- 0.5.0-alpha.13 — 2026-05-01
- 0.5.0-alpha.12 — 2026-04-23
- 0.5.0-alpha.11 — 2025-07-09
- 0.5.0-alpha.10 — 2025-05-20
- 0.5.0-alpha.9 — 2025-03-24
- 0.5.0-alpha.8 — 2024-10-29
- 0.5.0-alpha.7 — 2024-07-26
- 0.5.0-alpha.6 — 2024-04-25
- 0.5.0-alpha.5 — 2024-04-05
- 0.5.0-alpha.4 — 2024-04-04
- 0.5.0-alpha.3 — 2024-04-02
- 0.5.0-alpha.2 — 2024-03-28
- 0.5.0-alpha.1 — 2024-03-12
- 0.4.0 — 2024-01-25
- … 48 more at https://npm.io/package/vscode-markdown-languageservice/versions

## README

# VS Code Markdown Language Service

The language service that powers VS Code's Markdown support, extracted so that it can be reused by other editors and tools.


## Features

This library targets [CommonMark](https://commonmark.org). Support for other Markdown dialects and extensions is not within the scope of this project.

Currently supported language features:

- Document links (clickable spans in the editor)

	Supported links include:

	- Links to headers within the current file: `[text](#header)`
	- Absolute and relative links to files: `[text](path/to/file.md)`
	- Reference links: `[text][link-name]`

- Document symbols

	Finds all headers within a markdown file

- Workspace symbols

	Find all headers across all markdown files in the workspace.

- Folding ranges

	Folding ranges are computed for:

	- Header sections
	- Region sections
	- Lists
	- Block elements

- Smart select (expand selection)

- Completions

	Supports completions for:

	- Links to headers
	- Path links
	- Reference links

- Hover previews for images and videos

- Find all references

	Supports finding references to:

	- Headers
	- Path links
	- Fragments in links
	- Reference links

- Definitions

	Supports finding definitions headers and reference links.

- Renames

	Supports renaming of headers and links.

- Organize link definitions.

	Groups and sorts link definitions in a file, optionally also removing unused definitions.

-  Code actions

	- Extract all occurrences of a link in a file to a link definition at the bottom of the file.
	- Quick fixes for removing duplicated or unused link definitions.

- Diagnostics (error reporting)

	Supports generating diagnostics for invalid links to:

	- References.
	- Header within the current file.
	- Files in the workspace.
	- Headers in other files.

	Also can generate diagnostics for:

	- Unused link definitions.
	- Duplicate link definitions.

- Update links on file rename

	Generate an edit that updates all links when a file/directory in the workspace is renamed or moved.

- (experimental) Update links when coping and pasting text between files.


## Usage

To get started using this library, first install it into your workspace:

```bash
npm install vscode-markdown-languageservice
```

To use the language service, first you need to create an instance of it using `createLanguageService`. We use dependency injection to allow the language service to be used in as many contexts as possible.

```ts
import * as md from 'vscode-markdown-languageservice';

// Implement these
const parser: md.IMdParser = ...;
const workspace: md.IWorkspace = ...;
const logger: md.ILogger = ...;

const languageService = md.createLanguageService({ workspace, parser, logger });
```

After creating the service, you can ask it for the language features it supports:

```ts
// We're using the vscode-language types in this demo
// If you want to use them, make sure to run:
//
//     npm install vscode-languageserver vscode-languageserver-textdocument
//
// However you can also bring your own types if you want to instead.

import { CancellationTokenSource } from 'vscode-languageserver';
import { TextDocument } from 'vscode-languageserver-textdocument';

const cts = new CancellationTokenSource();

// Create a virtual document that holds our file content
const myDocument = TextDocument.create(
	URI.file('/path/to/file.md').toString(), // file path
	'markdown', // file language
	1, // version
	[ // File contents
		'# Hello',
		'from **Markdown**',
		'',
		'## World!',
	].join('\n')
);

const symbols = await languageService.getDocumentSymbols(myDocument, { includeLinkDefinitions: true }, cts.token);
```

See [example.mjs](./example.mjs) for complete, minimal example of using the language service. You can run in using `node example.mjs`.


## Additional Links

- [VS Code's Markdown language server](https://github.com/microsoft/vscode/blob/main/extensions/markdown-language-features/server/)
- [The TextMate grammar VS Code uses for Markdown syntax highlighting](https://github.com/microsoft/vscode-markdown-tm-grammar)


## Contributing

If you're interested in contributing

1. Clone this repo
1. Install dependencies using `npm install`
1. Start compilation using `npm run watch`

You can run the unit tests using `npm test` or by opening the project in VS Code and pressing `F5` to debug.

---
_Source: https://npm.io/package/vscode-markdown-languageservice · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
