{"id":43612699,"url":"https://github.com/nuxt-content/monarch-mdc","last_synced_at":"2026-02-04T12:13:14.761Z","repository":{"id":268388697,"uuid":"402790148","full_name":"nuxt-content/monarch-mdc","owner":"nuxt-content","description":"Integrate MDC syntax with Monaco Editor","archived":false,"fork":false,"pushed_at":"2026-01-26T16:30:48.000Z","size":1119,"stargazers_count":15,"open_issues_count":9,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-28T01:51:37.663Z","etag":null,"topics":["mdc","vue"],"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/nuxt-content.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2021-09-03T14:04:53.000Z","updated_at":"2025-12-22T07:03:20.000Z","dependencies_parsed_at":"2024-12-16T13:30:10.835Z","dependency_job_id":"fe2593b8-e70c-44be-be81-9f89d0b24d23","html_url":"https://github.com/nuxt-content/monarch-mdc","commit_stats":null,"previous_names":["nuxtlabs/monarch-mdc","nuxt-content/monarch-mdc"],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/nuxt-content/monarch-mdc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nuxt-content%2Fmonarch-mdc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nuxt-content%2Fmonarch-mdc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nuxt-content%2Fmonarch-mdc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nuxt-content%2Fmonarch-mdc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nuxt-content","download_url":"https://codeload.github.com/nuxt-content/monarch-mdc/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nuxt-content%2Fmonarch-mdc/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29084103,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-04T03:31:03.593Z","status":"ssl_error","status_checked_at":"2026-02-04T03:29:50.742Z","response_time":62,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["mdc","vue"],"created_at":"2026-02-04T12:13:14.073Z","updated_at":"2026-02-04T12:13:14.753Z","avatar_url":"https://github.com/nuxt-content.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @nuxtlabs/monarch-mdc\n\n[![npm version][npm-version-src]][npm-version-href]\n[![npm downloads][npm-downloads-src]][npm-downloads-href]\n[![License][license-src]][license-href]\n\nIntegrate MDC syntax with Monaco Editor.\n\n## Installation\n\n```bash\n#using pnpm\npnpm add @nuxtlabs/monarch-mdc\n#using yarn\nyarn add @nuxtlabs/monarch-mdc\n# using npm\nnpm install @nuxtlabs/monarch-mdc\n```\n\n## Usage\n\nThe package provides both the MDC language syntax for the Monaco Editor, along with optional formatting and code folding providers.\n\nCheckout the [Editor.vue](./playground/components/Editor.vue) for a complete example.\n\n### Language\n\n```js\nimport * as monaco from 'monaco-editor'\nimport { language as markdownLanguage } from '@nuxtlabs/monarch-mdc'\n\n// Register language\nmonaco.languages.register({ id: 'mdc' })\nmonaco.languages.setMonarchTokensProvider('mdc', markdownLanguage)\n\nconst code = `\nYour **awesome** markdown\n`\n\n// Create monaco model\nconst model = monaco.editor.createModel(\n  code,\n  'mdc'\n)\n\n// Create your editor\nconst el = ... // DOM element\nconst editor = monaco.editor.create(el, {\n  model,\n  // Monaco Editor options\n  // see: https://microsoft.github.io/monaco-editor/api/interfaces/monaco.editor.istandaloneeditorconstructionoptions.html\n})\n```\n\n### Formatter\n\nIf you'd like to integrate MDC formatting into your Monaco Editor instance, you can also register the document format provider. The initial setup looks similar, but we'll also register a set of formatting providers and some additional editor instance config options.\n\n1. The `registerDocumentFormattingEditProvider` registers the document format provider which enables the \"Format Document\" action in the editor's Command Palette along with the built-in keyboard shortcut.\n2. You can also enable the `registerOnTypeFormattingEditProvider` along with enabling the `formatOnType` config setting to auto-format the document as the user types. The `autoFormatTriggerCharacters` property allows you to customize the characters that trigger auto-formatting in your editor instance. Below, it is configured to a newline character `/n`, but feel free to customize the options for your project.\n\n\u003e [!Note]\n\u003e Since the format provider utilizes spaces for indention, we will also configure the editor to insert spaces for tabs.\n\n```js\nimport * as monaco from 'monaco-editor'\nimport { language as markdownLanguage, formatter as markdownFormatter } from '@nuxtlabs/monarch-mdc'\n\n// Register language\nmonaco.languages.register({ id: 'mdc' })\nmonaco.languages.setMonarchTokensProvider('mdc', markdownLanguage)\n\n// Define your desired Tab size\nconst TAB_SIZE = 2\n\n// Register formatter\n// This enables the \"Format Document\" action in the editor's Command Palette\nmonaco.languages.registerDocumentFormattingEditProvider('mdc', {\n  provideDocumentFormattingEdits: model =\u003e [{\n    range: model.getFullModelRange(),\n    text: mdcFormatter(model.getValue(), {\n      tabSize: TAB_SIZE,\n    }),\n  }],\n})\n\n// Register format on type provider\nmonaco.languages.registerOnTypeFormattingEditProvider('mdc', {\n  // Auto-format when the user types a newline character.\n  autoFormatTriggerCharacters: ['\\n'],\n  provideOnTypeFormattingEdits: (model, position) =\u003e {\n    // Get the line content before the current position\n    const lineContent = model.getLineContent(position.lineNumber - 1)\n\n    // Prevent auto-formatting if the line ends with specific string(s) (e.g., '---' for the start/end of a YAML block)\n    const skipFormatPatterns = ['---']\n    if (skipFormatPatterns.some(pattern =\u003e lineContent.trim().endsWith(pattern))) {\n      // Return empty array to skip formatting\n      return []\n    }\n\n    return [{\n      range: model.getFullModelRange(),\n      // We pass `true` to `isFormatOnType` to indicate formatOnType is being called.\n      text: mdcFormatter(model.getValue(), {\n        tabSize: TAB_SIZE,\n        isFormatOnType: true,\n      }),\n    }]\n  },\n})\n\nconst code = `\nYour **awesome** markdown\n`\n\n// Create monaco model\nconst model = monaco.editor.createModel(\n  code,\n  'mdc'\n)\n\n// Create your editor\nconst el = ... // DOM element\nconst editor = monaco.editor.create(el, {\n  model,\n  tabSize: TAB_SIZE, // Utilize the same tabSize used in the format providers\n  detectIndentation: false, // Important as to not override tabSize\n  insertSpaces: true, // Since the formatter utilizes spaces, we set to true to insert spaces when pressing Tab\n  formatOnType: true, // Add to enable automatic formatting as the user types.\n  // Other Monaco Editor options\n  // see: https://microsoft.github.io/monaco-editor/api/interfaces/monaco.editor.istandaloneeditorconstructionoptions.html\n})\n```\n\n### Code Folding\n\nIf you'd like to enable code folding for MDC block components into your Monaco Editor instance, you can also register the folding range provider.\n\n```js\nimport * as monaco from 'monaco-editor'\nimport { language as markdownLanguage, foldingProvider as markdownFoldingProvider } from '@nuxtlabs/monarch-mdc'\n\n// Register language\nmonaco.languages.register({ id: 'mdc' })\nmonaco.languages.setMonarchTokensProvider('mdc', markdownLanguage)\n\n// Register code folding provider\nmonaco.languages.registerFoldingRangeProvider('mdc', {\n  provideFoldingRanges: model =\u003e markdownFoldingProvider(model),\n})\n\nconst code = `\nYour **awesome** markdown\n`\n\n// Create monaco model\nconst model = monaco.editor.createModel(\n  code,\n  'mdc'\n)\n\n// Create your editor\nconst el = ... // DOM element\nconst editor = monaco.editor.create(el, {\n  model,\n  folding: true, // Enable code folding for MDC block components\n  // Other Monaco Editor options\n  // see: https://microsoft.github.io/monaco-editor/api/interfaces/monaco.editor.istandaloneeditorconstructionoptions.html\n})\n```\n\n### Bracket Matching\n\nIf you'd like to highlight matching opening and closing MDC block component tags, you can register the bracket matcher. This will highlight the opening `::component-name` and closing `::` when the cursor is adjacent to either one.\n\n```js\nimport * as monaco from 'monaco-editor'\nimport { language as markdownLanguage, registerBracketMatcher } from '@nuxtlabs/monarch-mdc'\n\n// Register language\nmonaco.languages.register({ id: 'mdc' })\nmonaco.languages.setMonarchTokensProvider('mdc', markdownLanguage)\n\nconst code = `\n::component\nYour **awesome** markdown\n::\n`\n\n// Create monaco model\nconst model = monaco.editor.createModel(\n  code,\n  'mdc'\n)\n\n// Create your editor\nconst el = ... // DOM element\nconst editor = monaco.editor.create(el, {\n  model,\n  // Monaco Editor options\n  // see: https://microsoft.github.io/monaco-editor/api/interfaces/monaco.editor.istandaloneeditorconstructionoptions.html\n})\n\n// Register bracket matcher (with optional configuration)\nconst bracketMatcherDisposable = registerBracketMatcher(editor, {\n  injectStyles: true, // Auto-inject default styles (default: true)\n  maxLineCount: 5000, // Disable for large documents (default: 5000, set to 0 to disable limit)\n})\n\n// Clean up when disposing the editor\n// bracketMatcherDisposable.dispose()\n```\n\n## VS Code Extension\n\nThe exported `formatter`, `getDocumentFoldingRanges`, and `findMatchingBrackets` functions are also utilized in [@nuxtlabs/vscode-mdc](https://github.com/nuxtlabs/vscode-mdc) to provide the functionality to the [MDC VS Code extension](https://marketplace.visualstudio.com/items?itemName=Nuxt.mdc).\n\n## 💻 Development\n\n- Clone repository\n- Install dependencies using `pnpm install`\n- Try playground using `pnpm dev`\n\n## License\n\n[MIT](./LICENSE) - Made with 💚\n\n\u003c!-- Badges --\u003e\n[npm-version-src]: https://img.shields.io/npm/v/@nuxtlabs/monarch-mdc/latest.svg\n[npm-version-href]: https://npmjs.com/package/@nuxtlabs/monarch-mdc\n\n[npm-downloads-src]: https://img.shields.io/npm/dt/@nuxtlabs/monarch-mdc.svg\n[npm-downloads-href]: https://npmjs.com/package/@nuxtlabs/monarch-mdc\n\n[license-src]: https://img.shields.io/npm/l/@nuxtlabs/monarch-mdc.svg\n[license-href]: https://npmjs.com/package/@nuxtlabs/monarch-mdc\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnuxt-content%2Fmonarch-mdc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnuxt-content%2Fmonarch-mdc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnuxt-content%2Fmonarch-mdc/lists"}