{"id":47968602,"url":"https://github.com/php-collective/djot-grammars","last_synced_at":"2026-06-19T04:02:33.290Z","repository":{"id":344698798,"uuid":"1182757940","full_name":"php-collective/djot-grammars","owner":"php-collective","description":"Syntax highlighting grammars for Djot markup language","archived":false,"fork":false,"pushed_at":"2026-03-25T04:16:59.000Z","size":76,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-03-25T04:21:03.747Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/php-collective.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-03-15T23:28:20.000Z","updated_at":"2026-03-25T04:17:01.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/php-collective/djot-grammars","commit_stats":null,"previous_names":["php-collective/djot-grammars"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/php-collective/djot-grammars","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-collective%2Fdjot-grammars","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-collective%2Fdjot-grammars/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-collective%2Fdjot-grammars/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-collective%2Fdjot-grammars/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/php-collective","download_url":"https://codeload.github.com/php-collective/djot-grammars/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-collective%2Fdjot-grammars/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34516549,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-19T02:00:06.005Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2026-04-04T10:40:48.058Z","updated_at":"2026-06-19T04:02:33.282Z","avatar_url":"https://github.com/php-collective.png","language":"JavaScript","funding_links":[],"categories":["Syntax Highlighting"],"sub_categories":["Djot → HTML → Djot"],"readme":"# Djot Grammars\n\n[![Tests](https://github.com/php-collective/djot-grammars/actions/workflows/test.yml/badge.svg)](https://github.com/php-collective/djot-grammars/actions/workflows/test.yml)\n\nSyntax highlighting grammars for the [Djot](https://djot.net) markup language.\n\n## Included Grammars\n\n### TextMate Grammar\n\n\u003e **Note:** As of [Phiki v2.1.1](https://github.com/phikiphp/phiki/releases/tag/v2.1.1), the Djot grammar is bundled with Phiki.\n\u003e For PHP projects, use Phiki directly - no separate grammar installation needed.\n\u003e This file is kept for backwards compatibility with existing Shiki/Node.js projects.\n\n**Location:** `textmate/djot.tmLanguage.json`\n\nWorks with:\n- [Shiki](https://shiki.style/) (VitePress, Astro, etc.)\n- VS Code (via TextMate support)\n- TextMate and compatible editors\n- IntelliJ/PhpStorm (via [Djot plugin](https://plugins.jetbrains.com/plugin/18828-djot))\n\n#### Usage with Shiki (Node.js)\n\n```js\nimport { createHighlighter } from 'shiki'\nimport djotGrammar from 'djot-grammars/textmate/djot.tmLanguage.json'\n\nconst highlighter = await createHighlighter({\n  themes: ['github-light'],\n  langs: [djotGrammar],\n})\n\nconst html = highlighter.codeToHtml(code, { lang: 'djot', theme: 'github-light' })\n```\n\n#### Usage with VitePress\n\n```ts\n// .vitepress/config.ts\nimport { defineConfig } from 'vitepress'\nimport djotGrammar from 'djot-grammars/textmate/djot.tmLanguage.json'\n\nexport default defineConfig({\n  markdown: {\n    languages: [\n      { ...djotGrammar, name: 'djot', aliases: ['dj'] },\n    ],\n  },\n})\n```\n\n#### Usage with Phiki (PHP)\n\nAs of Phiki v2.1.1, Djot is bundled - just use it directly:\n\n```php\nuse Phiki\\Phiki;\n\n$phiki = new Phiki();\n$html = $phiki-\u003ecodeToHtml($djotCode, 'djot', 'github-light');\n```\n\n---\n\n### highlight.js Grammar\n\n**Location:** `highlightjs/djot.js`\n\nWorks with [highlight.js](https://highlightjs.org/) for client-side syntax highlighting.\n\n#### Usage\n\n```html\n\u003clink rel=\"stylesheet\" href=\"https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/github.min.css\"\u003e\n\u003cscript src=\"https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js\"\u003e\u003c/script\u003e\n\u003cscript src=\"path/to/djot-grammars/highlightjs/djot.js\"\u003e\u003c/script\u003e\n\u003cscript\u003ehljs.highlightAll();\u003c/script\u003e\n```\n\n```html\n\u003cpre\u003e\u003ccode class=\"language-djot\"\u003e\n# Hello World\n\nThis is *strong* and _emphasized_ text.\n\u003c/code\u003e\u003c/pre\u003e\n```\n\n---\n\n### Prism.js Grammar\n\n**Location:** `prismjs/djot.js`\n\nWorks with [Prism.js](https://prismjs.com/) for client-side syntax highlighting.\n\n#### Usage\n\n```html\n\u003clink rel=\"stylesheet\" href=\"https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/themes/prism.min.css\"\u003e\n\u003cscript src=\"https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/prism.min.js\"\u003e\u003c/script\u003e\n\u003cscript src=\"path/to/djot-grammars/prismjs/djot.js\"\u003e\u003c/script\u003e\n```\n\n```html\n\u003cpre\u003e\u003ccode class=\"language-djot\"\u003e\n# Hello World\n\nThis is *strong* and _emphasized_ text.\n\u003c/code\u003e\u003c/pre\u003e\n```\n\n---\n\n### Tiptap Integration\n\n**Location:** `tiptap/`\n\nWYSIWYG editor integration for [Tiptap](https://tiptap.dev) with Djot serialization.\n\n#### Quick Start\n\n```js\nimport { Editor } from '@tiptap/core'\nimport { DjotKit, serializeToDjot } from 'djot-grammars/tiptap'\n\nconst editor = new Editor({\n  element: document.getElementById('editor'),\n  extensions: [DjotKit],\n  onUpdate: ({ editor }) =\u003e {\n    const djot = serializeToDjot(editor.getJSON())\n    console.log(djot)\n  },\n})\n```\n\n#### Features\n\n- **DjotKit** - All-in-one extension bundle with full Djot support\n- **Custom marks** - Insert `{+text+}`, Delete `{-text-}`, Div containers `:::`\n- **Serializer** - Convert editor content to Djot markup\n- Tables, task lists, code blocks with language, images, links\n\nSee [tiptap/README.md](tiptap/README.md) for full documentation. [Demo](https://sandbox.dereuromark.de/sandbox/djot/wysiwyg).\n\n---\n\n## External Grammars\n\nThese Djot grammars are maintained in other repositories:\n\n| Grammar | Repository | Description |\n|---------|------------|-------------|\n| **tree-sitter** | [treeman/tree-sitter-djot](https://github.com/treeman/tree-sitter-djot) | For Neovim, Helix, and other tree-sitter editors |\n| **Vim** | [jgm/djot](https://github.com/jgm/djot/tree/main/editors/vim) | Official Vim syntax file |\n| **Emacs** | [jgm/djot](https://github.com/jgm/djot/tree/main/editors/emacs) | Official Emacs major mode |\n| **Sublime Text** | [sorairolake/djot.sublime-syntax](https://github.com/sorairolake/djot.sublime-syntax) | Sublime Text syntax (archived) |\n\n---\n\n## Supported Syntax\n\nAll grammars support the full [Djot specification](https://htmlpreview.github.io/?https://github.com/jgm/djot/blob/master/doc/syntax.html) plus [djot-php](https://github.com/php-collective/djot-php) enhancements:\n\n### Block Elements\n- Headings (`# Title` through `###### Title`)\n- Code fences (` ``` ` with optional language)\n- Div blocks (`:::` with optional class)\n- Blockquotes (`\u003e text`)\n- Lists (bullets `-`, `*`, `+` and numbered `1.`, `1)`)\n- Task lists (`- [ ]`, `- [x]`)\n- Definition lists (`: term`)\n- Tables (`| cell | cell |` with separator rows)\n- Line blocks (`| text` for poetry/addresses)\n- Horizontal rules (`---`, `***`, `___`)\n- Block attributes (`{.class #id key=value}`)\n\n### Inline Elements\n- Strong (`*bold*`)\n- Emphasis (`_italic_`)\n- Highlight (`{=text=}`)\n- Insert (`{+text+}`)\n- Delete (`{-text-}`)\n- Superscript (`^text^`, `{^text^}`)\n- Subscript (`~text~`, `{~text~}`)\n- Inline code (`` `code` ``)\n- Links (`[text](url)`, `[text][ref]`)\n- Images (`![alt](url)`)\n- Autolinks (`\u003chttps://...\u003e`, `\u003cuser@example.com\u003e`)\n- Footnotes (`[^note]` and `[^note]: definition`)\n- Math (`$` `` `code` `` `$` and `$$` `` `code` `` `$$`)\n- Symbols (`:name:`)\n- Spans with attributes (`[text]{.class}`)\n- Raw format markers (`` `code`{=html} ``)\n- Escape sequences (`\\*`, `\\[`, etc.)\n- Hard line breaks (`\\` at end of line)\n- Smart punctuation (`---`, `--`, `...`)\n\n### djot-php Extensions\n- Captions (`^ caption text` for images, tables, blockquotes)\n- Fenced comments (`%%%` blocks)\n- Inline comments (`{% comment %}`)\n- Table row/cell attributes (`| cell |{.class}`)\n\n---\n\n## Installation\n\n### NPM\n\n```bash\nnpm install djot-grammars\n```\n\n### Composer (PHP)\n\n```bash\ncomposer require php-collective/djot-grammars\n```\n\n### Manual\n\nDownload the grammar files directly from this repository.\n\n---\n\n## Comparison\n\n| Feature | TextMate | highlight.js | Prism.js | Tiptap | tree-sitter |\n|---------|----------|--------------|----------|--------|-------------|\n| Type | Syntax highlighting | Syntax highlighting | Syntax highlighting | WYSIWYG editor | Syntax highlighting |\n| Rendering | Server/Client | Client | Client | Client | Server/Editor |\n| JS required | Depends | Yes | Yes | Yes | No |\n| Used by | Shiki, VS Code | highlight.js | Prism.js | Tiptap/ProseMirror | Neovim, Helix |\n| Themes | VS Code themes | 90+ | 8+ | Custom CSS | Editor themes |\n| Extensible | Limited | Some | Extensive | Yes | Yes |\n\n\u003e **Note:** [Phiki](https://github.com/phikiphp/phiki) v2.1.1+ bundles the Djot grammar directly.\n\n---\n\n## Testing\n\nRun the test suite to validate all grammars:\n\n```bash\nnpm run test:install  # Install test dependencies\nnpm test              # Run grammar tests\n```\n\nThe test suite validates TextMate, highlight.js, and Prism.js grammars against a comprehensive Djot syntax fixture covering all language elements.\n\n---\n\n## Contributing\n\nContributions are welcome! Please ensure any changes maintain compatibility with the [Djot specification](https://djot.net).\n\n## License\n\nMIT License - see [LICENSE](LICENSE) for details.\n\n## Related Projects\n\n- [Djot](https://djot.net) - The Djot markup language\n- [djot-php](https://github.com/php-collective/djot-php) - PHP implementation\n- [djot.js](https://github.com/jgm/djot.js) - JavaScript implementation\n- [djot-intellij](https://github.com/php-collective/djot-intellij) - IntelliJ/PhpStorm plugin\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphp-collective%2Fdjot-grammars","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphp-collective%2Fdjot-grammars","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphp-collective%2Fdjot-grammars/lists"}