{"_id":"@constasj/vscode-markdown-languageservice","name":"@constasj/vscode-markdown-languageservice","dist-tags":{"latest":"0.5.0-alpha.8"},"versions":{"0.5.0-alpha.8":{"name":"@constasj/vscode-markdown-languageservice","description":"Markdown language service","version":"0.5.0-alpha.8","author":{"name":"Microsoft Corporation"},"license":"MIT","engines":{"node":"*"},"main":"./out/index.js","types":"./types/vscode-markdown-languageservice.d.ts","dependencies":{"@vscode/l10n":"^0.0.10","node-html-parser":"^6.1.5","picomatch":"^2.3.1","vscode-languageserver-protocol":"^3.17.1","vscode-languageserver-textdocument":"^1.0.11","vscode-uri":"^3.0.7"},"devDependencies":{"@microsoft/api-extractor":"^7.31.2","@types/markdown-it":"^12.2.3","@types/mocha":"^9.1.1","@types/node":"20.x","@types/picomatch":"^2.3.0","@typescript-eslint/eslint-plugin":"^7.2.0","@typescript-eslint/parser":"^7.2.0","eslint":"^8.57.0","github-slugger":"^2.0.0","markdown-it":"^13.0.1","mkdirp":"^1.0.4","mocha":"^10.0.0","source-map-support":"^0.5.21","typescript":"^5.6.0"},"scripts":{"api-extractor":"mkdirp etc && npx api-extractor run --local","compile":"tsc -b tsconfig.json","watch":"tsc -b tsconfig.json --watch","lint":"eslint \"src/**/*.ts\"","prepublishOnly":"npm run compile && npm run api-extractor","test":"mocha -r source-map-support/register 'out/test/**/*.test.js' --ui=tdd --timeout=2000 --exit"},"repository":{"type":"git","url":"git+https://github.com/microsoft/vscode-markdown-languageservice.git"},"bugs":{"url":"https://github.com/microsoft/vscode-markdown-languageservice/issues"},"_id":"@constasj/vscode-markdown-languageservice@0.5.0-alpha.8","gitHead":"ebf0be5723b909d01ae85291f30c5a70c9e36767","homepage":"https://github.com/microsoft/vscode-markdown-languageservice#readme","_nodeVersion":"22.14.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-9KuQffBfvDSNlXM6BGuAHbSFSPjmCNunIqFBskQg+Y76dsRoDC0vlban3aV+lb6Dxtkhp/3nZLwtdF8em5bFjA==","shasum":"d50da2b49ce7d852e4e97dc9b323d028e7fc246e","tarball":"https://registry.npmjs.org/@constasj/vscode-markdown-languageservice/-/vscode-markdown-languageservice-0.5.0-alpha.8.tgz","fileCount":51,"unpackedSize":279912,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIGquXzmNVTdFT97yl1B16r1+6RU4ODtG3OHr2cTNajkNAiAzKOK8Lfzj/eQLnF6hQDoVNsoIHWtsWMSWWxkqVquwWQ=="}]},"_npmUser":{"name":"constasj","email":"2020212726@qq.com"},"directories":{},"maintainers":[{"name":"constasj","email":"2020212726@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/vscode-markdown-languageservice_0.5.0-alpha.8_1740304410425_0.19314604500629873"},"_hasShrinkwrap":false}},"time":{"created":"2025-02-23T09:53:30.343Z","0.5.0-alpha.8":"2025-02-23T09:53:30.610Z","modified":"2025-02-23T09:53:30.852Z"},"maintainers":[{"name":"constasj","email":"2020212726@qq.com"}],"description":"Markdown language service","homepage":"https://github.com/microsoft/vscode-markdown-languageservice#readme","repository":{"type":"git","url":"git+https://github.com/microsoft/vscode-markdown-languageservice.git"},"author":{"name":"Microsoft Corporation"},"bugs":{"url":"https://github.com/microsoft/vscode-markdown-languageservice/issues"},"license":"MIT","readme":"# VS Code Markdown Language Service\r\n\r\nThe language service that powers VS Code's Markdown support, extracted so that it can be reused by other editors and tools.\r\n\r\n\r\n## Features\r\n\r\nThis library targets [CommonMark](https://commonmark.org). Support for other Markdown dialects and extensions is not within the scope of this project.\r\n\r\nCurrently supported language features:\r\n\r\n- Document links (clickable spans in the editor)\r\n\r\n\tSupported links include:\r\n\r\n\t- Links to headers within the current file: `[text](#header)`\r\n\t- Absolute and relative links to files: `[text](path/to/file.md)`\r\n\t- Reference links: `[text][link-name]`\r\n\r\n- Document symbols\r\n\r\n\tFinds all headers within a markdown file\r\n\r\n- Workspace symbols\r\n\r\n\tFind all headers across all markdown files in the workspace.\r\n\r\n- Folding ranges\r\n\r\n\tFolding ranges are computed for:\r\n\r\n\t- Header sections\r\n\t- Region sections\r\n\t- Lists\r\n\t- Block elements\r\n\r\n- Smart select (expand selection)\r\n\r\n- Completions\r\n\r\n\tSupports completions for:\r\n\r\n\t- Links to headers\r\n\t- Path links\r\n\t- Reference links\r\n\r\n- Hover previews for images and videos\r\n\r\n- Find all references\r\n\r\n\tSupports finding references to:\r\n\r\n\t- Headers\r\n\t- Path links\r\n\t- Fragments in links\r\n\t- Reference links\r\n\r\n- Definitions\r\n\r\n\tSupports finding definitions headers and reference links.\r\n\r\n- Renames\r\n\r\n\tSupports renaming of headers and links.\r\n\r\n- Organize link definitions.\r\n\r\n\tGroups and sorts link definitions in a file, optionally also removing unused definitions.\r\n\r\n-  Code actions\r\n\r\n\t- Extract all occurrences of a link in a file to a link definition at the bottom of the file.\r\n\t- Quick fixes for removing duplicated or unused link definitions.\r\n\r\n- Diagnostics (error reporting)\r\n\r\n\tSupports generating diagnostics for invalid links to:\r\n\r\n\t- References.\r\n\t- Header within the current file.\r\n\t- Files in the workspace.\r\n\t- Headers in other files.\r\n\t\r\n\tAlso can generate diagnostics for:\r\n\r\n\t- Unused link definitions.\r\n\t- Duplicate link definitions.\r\n\r\n- Update links on file rename\r\n\r\n\tGenerate an edit that updates all links when a file/directory in the workspace is renamed or moved.\r\n\r\n- (experimental) Update links when coping and pasting text between files.\r\n\r\n\r\n## Usage\r\n\r\nTo get started using this library, first install it into your workspace:\r\n\r\n```bash\r\nnpm install vscode-markdown-languageservice\r\n```\r\n\r\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.\r\n\r\n```ts\r\nimport * as md from 'vscode-markdown-languageservice';\r\n\r\n// Implement these\r\nconst parser: md.IMdParser = ...;\r\nconst workspace: md.IWorkspace = ...;\r\nconst logger: md.ILogger = ...;\r\n\r\nconst languageService = md.createLanguageService({ workspace, parser, logger });\r\n```\r\n\r\nAfter creating the service, you can ask it for the language features it supports:\r\n\r\n```ts\r\n// We're using the vscode-language types in this demo\r\n// If you want to use them, make sure to run:\r\n//\r\n//     npm install vscode-languageserver vscode-languageserver-textdocument\r\n//\r\n// However you can also bring your own types if you want to instead.\r\n\r\nimport { CancellationTokenSource } from 'vscode-languageserver';\r\nimport { TextDocument } from 'vscode-languageserver-textdocument';\r\n\r\nconst cts = new CancellationTokenSource();\r\n\r\n// Create a virtual document that holds our file content\r\nconst myDocument = TextDocument.create(\r\n\tURI.file('/path/to/file.md').toString(), // file path\r\n\t'markdown', // file language\r\n\t1, // version\r\n\t[ // File contents\r\n\t\t'# Hello',\r\n\t\t'from **Markdown**',\r\n\t\t'',\r\n\t\t'## World!',\r\n\t].join('\\n')\r\n);\r\n\r\nconst symbols = await languageService.getDocumentSymbols(myDocument, { includeLinkDefinitions: true }, cts.token);\r\n```\r\n\r\nSee [example.cjs](./example.cjs) for complete, minimal example of using the language service. You can run in using `node example.cjs`.\r\n\r\n\r\n## Additional Links\r\n\r\n- [VS Code's Markdown language server](https://github.com/microsoft/vscode/blob/main/extensions/markdown-language-features/server/)\r\n- [The TextMate grammar VS Code uses for Markdown syntax highlighting](https://github.com/microsoft/vscode-markdown-tm-grammar)\r\n\r\n\r\n## Contributing\r\n\r\nIf you're interested in contributing\r\n\r\n1. Clone this repo\r\n1. Install dependencies using `npm install`\r\n1. Start compilation using `npm run watch`\r\n\r\nYou can run the unit tests using `npm test` or by opening the project in VS Code and pressing `F5` to debug.\r\n","readmeFilename":"README.md"}