{"id":23633504,"url":"https://github.com/andorsk/d2-mode","last_synced_at":"2025-03-31T06:08:47.363Z","repository":{"id":63943667,"uuid":"569310980","full_name":"andorsk/d2-mode","owner":"andorsk","description":"emacs major mode for d2 graphs","archived":false,"fork":false,"pushed_at":"2024-12-09T21:56:55.000Z","size":3907,"stargazers_count":77,"open_issues_count":16,"forks_count":8,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-22T18:41:40.236Z","etag":null,"topics":["d2","elisp","emacs","graph","processes","tools"],"latest_commit_sha":null,"homepage":"","language":"Emacs Lisp","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andorsk.png","metadata":{"files":{"readme":"README.md","changelog":null,"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}},"created_at":"2022-11-22T14:42:04.000Z","updated_at":"2025-03-07T12:57:59.000Z","dependencies_parsed_at":"2024-12-09T22:30:58.694Z","dependency_job_id":"344acb07-ebb6-4a8b-9e38-85e296368422","html_url":"https://github.com/andorsk/d2-mode","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andorsk%2Fd2-mode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andorsk%2Fd2-mode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andorsk%2Fd2-mode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andorsk%2Fd2-mode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andorsk","download_url":"https://codeload.github.com/andorsk/d2-mode/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246423731,"owners_count":20774820,"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":["d2","elisp","emacs","graph","processes","tools"],"created_at":"2024-12-28T04:52:46.158Z","updated_at":"2025-03-31T06:08:47.336Z","avatar_url":"https://github.com/andorsk.png","language":"Emacs Lisp","readme":"[![MELPA](https://melpa.org/packages/d2-mode-badge.svg)](https://melpa.org/#/d2-mode)\n[![build](https://github.com/andorsk/d2-mode/actions/workflows/build.yml/badge.svg)](https://github.com/andorsk/d2-mode/actions/workflows/build.yml)\n[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)\n\n# d2-mode\n\nA [d2](https://github.com/terrastruct/d2) extension for Emacs. This was heavily\ninspired of [Mermaid Mode](https://github.com/abrochard/mermaid-mode).\n\n**Status:** Alpha. Available on Melpa. \n\nIt works you can use this to render d2 in both your browser and in an emacs buffer. See [Bugs \u0026 Issues](#bugs--issues) for known issues.\n\n\u003cdiv\u003e\n  \u003cimg height=\"500px\" alt=\"image\" src=\"https://user-images.githubusercontent.com/8604639/204498003-08bd0e05-0e0b-4d60-8d94-1ed95a4a7cd3.png\"\u003e\n\u003c/div\u003e\n\n\u003cdiv\u003e\n  \u003cimg height=\"500px\" alt=\"image\" src=\"tutorial.gif\"\u003e\n\u003c/div\u003e\n\n\u003c!-- markdown-toc start - Don't edit this section. Run M-x markdown-toc-refresh-toc --\u003e\n\n**Table of Contents**\n\n- [d2-mode](#d2-mode)\n- [Why D2](#why-d2)\n- [Installation](#installation)\n- [Usage](#usage)\n- [Customization](#customization)\n- [`d2` binary location](#d2-binary-location)\n- [Output format](#output-format)\n- [Temp directory](#temp-directory)\n- [Key bindings](#key-bindings)\n- [Bonus](#bonus)\n- [Roadmap](#roadmap)\n- [Bugs \u0026 Issues](#bugs--issues)\n- [Contributors](#contributors)\n\n\u003c!-- markdown-toc end --\u003e\n\n## Why D2\n\nText to graph diagrams are awesome. I used Mermaid.js all the time and it was\nfantastic, but there were a few things it couldn't do so I wanted to expand my\noptions.\n\nSome things that I've noticed d2 has some interesting support in:\n\n1. More themes\n2. Code Blocks\n3. More visual customization\n4. More graph support\n5. Autoformat\n\nLearn more about [d2 here](https://d2lang.com/tour/intro/)\n\n## Installation\n\n1. Load the d2-mode.el file or install from melpa: `M-x package-install d2-mode`\n2. Install d2 binary from the d2 project if you plan to compile graphs in Emacs\n\n## Usage\n\n```text\nC-c C-c - compile current file to an image\nC-c C-f - compile given file to an image\nC-c C-b - compile current buffer to an image\nC-c C-r - compile current region to an image\nC-c C-o - open in the live editor\nC-c C-d - open the official doc\n```\n\nNote: All compile commands will open the output in a buffer to view the resulting image.\n\n## Customization\n\n### `d2` binary location\n\nYou can specify the location of `d2` with the variable `d2-location`, the default assumes you have the binary in your `PATH` (and for that you probably want/need to install [`d2`](https://github.com/andorsk/d2-mode)).\n\n### Output format\n\nYou can specify png or svg output format by putting this in your `init.el` file:\n\n```(setq d2-output-format \"\u003cOUTPUT_FORMAT\")```\n\nOptions are: \n- `.png`\n- `.svg`\n\nDefault is SVG.\n\n### Temp directory\n\nBy default `d2-tmp-dir` points to `\\tmp\\`. Feel free to set it to a more appropriate location that works for you (e.g. on windows).\n\n### Key bindings\n\nTo customize the key bindings put this into your `init.el` ...\n\n```elisp\n(defvar d2-mode-map\n  (let ((map (make-sparse-keymap)))\n    (define-key map (kbd \"C-c C-c\") 'd2-compile)\n    (define-key map (kbd \"C-c C-f\") 'd2-compile-file)\n    (define-key map (kbd \"C-c C-b\") 'd2-compile-buffer)\n    (define-key map (kbd \"C-c C-r\") 'd2-compile-region)\n    (define-key map (kbd \"C-c C-h\") 'd2-compile-file-and-browse)\n    (define-key map (kbd \"C-c C-j\") 'd2-compile-buffer-and-browse)\n    (define-key map (kbd \"C-c C-k\") 'd2-compile-region-and-browse)\n    (define-key map (kbd \"C-c C-o\") 'd2-open-browser)\n    (define-key map (kbd \"C-x C-o\") 'd2-view-current-svg)\n    (define-key map (kbd \"C-c C-d\") 'd2-open-doc)\n    map))\n\n```\n\n### Bonus\n\nSee the `snippets` folder for yas snippets. Start making d2 graphs today!\n\n### Roadmap\n\n- Even better syntax highlighting and formatting\n- Watch mode support\n\n## Bugs \u0026 Issues\n\n- SVG's have issues rending in emacs sometimes. See\n  [#13](https://github.com/andorsk/d2-mode/issues/13) and\n  [#8](https://github.com/andorsk/d2-mode/issues/8) for more details. You can use the\n  `*browse` commands to render it directly in your browser instead!\n\nFeel free to open an issue and or contribute to this repo over a PR!\n\n## Contributors\n\nWe thank anyone that decides to contribute to this repository and encourage\ncontributions.\n\n\u003ca href=\"https://github.com/andorsk/d2-mode/graphs/contributors\"\u003e\n  \u003cimg src=\"https://contrib.rocks/image?repo=andorsk/d2-mode\" /\u003e\n\u003c/a\u003e\n\nAlso thank you to @suliveevil for bringing up issues.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandorsk%2Fd2-mode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandorsk%2Fd2-mode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandorsk%2Fd2-mode/lists"}