{"id":13461826,"url":"https://github.com/microsoft/vscode-markdown-languageservice","last_synced_at":"2025-05-14T12:06:49.497Z","repository":{"id":45170396,"uuid":"512944461","full_name":"microsoft/vscode-markdown-languageservice","owner":"microsoft","description":"The language service that powers VS Code's Markdown support, extracted so that it can be reused by other editors and tools","archived":false,"fork":false,"pushed_at":"2025-04-09T21:31:23.000Z","size":819,"stargazers_count":419,"open_issues_count":17,"forks_count":13,"subscribers_count":14,"default_branch":"main","last_synced_at":"2025-05-07T23:48:07.256Z","etag":null,"topics":["lsp","markdown","vscode"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/microsoft.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-07-12T00:12:10.000Z","updated_at":"2025-05-07T10:13:29.000Z","dependencies_parsed_at":"2023-02-17T23:01:30.414Z","dependency_job_id":"a7d7d6f0-590f-4572-a4d5-69466771acce","html_url":"https://github.com/microsoft/vscode-markdown-languageservice","commit_stats":{"total_commits":232,"total_committers":10,"mean_commits":23.2,"dds":0.06034482758620685,"last_synced_commit":"21d45107813d1687705c11bb96ad285e104e8578"},"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2Fvscode-markdown-languageservice","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2Fvscode-markdown-languageservice/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2Fvscode-markdown-languageservice/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2Fvscode-markdown-languageservice/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/microsoft","download_url":"https://codeload.github.com/microsoft/vscode-markdown-languageservice/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254140740,"owners_count":22021218,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["lsp","markdown","vscode"],"created_at":"2024-07-31T11:00:58.848Z","updated_at":"2025-05-14T12:06:49.439Z","avatar_url":"https://github.com/microsoft.png","language":"TypeScript","readme":"# VS Code Markdown Language Service\n\nThe language service that powers VS Code's Markdown support, extracted so that it can be reused by other editors and tools.\n\n\n## Features\n\nThis library targets [CommonMark](https://commonmark.org). Support for other Markdown dialects and extensions is not within the scope of this project.\n\nCurrently supported language features:\n\n- Document links (clickable spans in the editor)\n\n\tSupported links include:\n\n\t- Links to headers within the current file: `[text](#header)`\n\t- Absolute and relative links to files: `[text](path/to/file.md)`\n\t- Reference links: `[text][link-name]`\n\n- Document symbols\n\n\tFinds all headers within a markdown file\n\n- Workspace symbols\n\n\tFind all headers across all markdown files in the workspace.\n\n- Folding ranges\n\n\tFolding ranges are computed for:\n\n\t- Header sections\n\t- Region sections\n\t- Lists\n\t- Block elements\n\n- Smart select (expand selection)\n\n- Completions\n\n\tSupports completions for:\n\n\t- Links to headers\n\t- Path links\n\t- Reference links\n\n- Hover previews for images and videos\n\n- Find all references\n\n\tSupports finding references to:\n\n\t- Headers\n\t- Path links\n\t- Fragments in links\n\t- Reference links\n\n- Definitions\n\n\tSupports finding definitions headers and reference links.\n\n- Renames\n\n\tSupports renaming of headers and links.\n\n- Organize link definitions.\n\n\tGroups and sorts link definitions in a file, optionally also removing unused definitions.\n\n-  Code actions\n\n\t- Extract all occurrences of a link in a file to a link definition at the bottom of the file.\n\t- Quick fixes for removing duplicated or unused link definitions.\n\n- Diagnostics (error reporting)\n\n\tSupports generating diagnostics for invalid links to:\n\n\t- References.\n\t- Header within the current file.\n\t- Files in the workspace.\n\t- Headers in other files.\n\t\n\tAlso can generate diagnostics for:\n\n\t- Unused link definitions.\n\t- Duplicate link definitions.\n\n- Update links on file rename\n\n\tGenerate an edit that updates all links when a file/directory in the workspace is renamed or moved.\n\n- (experimental) Update links when coping and pasting text between files.\n\n\n## Usage\n\nTo get started using this library, first install it into your workspace:\n\n```bash\nnpm install vscode-markdown-languageservice\n```\n\nTo 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.\n\n```ts\nimport * as md from 'vscode-markdown-languageservice';\n\n// Implement these\nconst parser: md.IMdParser = ...;\nconst workspace: md.IWorkspace = ...;\nconst logger: md.ILogger = ...;\n\nconst languageService = md.createLanguageService({ workspace, parser, logger });\n```\n\nAfter creating the service, you can ask it for the language features it supports:\n\n```ts\n// We're using the vscode-language types in this demo\n// If you want to use them, make sure to run:\n//\n//     npm install vscode-languageserver vscode-languageserver-textdocument\n//\n// However you can also bring your own types if you want to instead.\n\nimport { CancellationTokenSource } from 'vscode-languageserver';\nimport { TextDocument } from 'vscode-languageserver-textdocument';\n\nconst cts = new CancellationTokenSource();\n\n// Create a virtual document that holds our file content\nconst myDocument = TextDocument.create(\n\tURI.file('/path/to/file.md').toString(), // file path\n\t'markdown', // file language\n\t1, // version\n\t[ // File contents\n\t\t'# Hello',\n\t\t'from **Markdown**',\n\t\t'',\n\t\t'## World!',\n\t].join('\\n')\n);\n\nconst symbols = await languageService.getDocumentSymbols(myDocument, { includeLinkDefinitions: true }, cts.token);\n```\n\nSee [example.cjs](./example.cjs) for complete, minimal example of using the language service. You can run in using `node example.cjs`.\n\n\n## Additional Links\n\n- [VS Code's Markdown language server](https://github.com/microsoft/vscode/blob/main/extensions/markdown-language-features/server/)\n- [The TextMate grammar VS Code uses for Markdown syntax highlighting](https://github.com/microsoft/vscode-markdown-tm-grammar)\n\n\n## Contributing\n\nIf you're interested in contributing\n\n1. Clone this repo\n1. Install dependencies using `npm install`\n1. Start compilation using `npm run watch`\n\nYou can run the unit tests using `npm test` or by opening the project in VS Code and pressing `F5` to debug.\n","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicrosoft%2Fvscode-markdown-languageservice","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmicrosoft%2Fvscode-markdown-languageservice","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicrosoft%2Fvscode-markdown-languageservice/lists"}