{"id":16611152,"url":"https://github.com/yhatt/markdown-it-incremental-dom","last_synced_at":"2025-03-16T21:31:03.333Z","repository":{"id":17708652,"uuid":"80899733","full_name":"yhatt/markdown-it-incremental-dom","owner":"yhatt","description":"markdown-it renderer plugin by using Incremental DOM.","archived":false,"fork":false,"pushed_at":"2022-12-08T19:06:28.000Z","size":2099,"stargazers_count":65,"open_issues_count":18,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-04-14T05:11:04.126Z","etag":null,"topics":["incremental-dom","markdown","markdown-it","markdown-it-plugin"],"latest_commit_sha":null,"homepage":"https://yhatt.github.io/markdown-it-incremental-dom/","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/yhatt.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}},"created_at":"2017-02-04T06:40:20.000Z","updated_at":"2024-02-10T07:49:07.000Z","dependencies_parsed_at":"2022-09-12T20:22:40.202Z","dependency_job_id":null,"html_url":"https://github.com/yhatt/markdown-it-incremental-dom","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yhatt%2Fmarkdown-it-incremental-dom","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yhatt%2Fmarkdown-it-incremental-dom/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yhatt%2Fmarkdown-it-incremental-dom/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yhatt%2Fmarkdown-it-incremental-dom/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yhatt","download_url":"https://codeload.github.com/yhatt/markdown-it-incremental-dom/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243830949,"owners_count":20354854,"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":["incremental-dom","markdown","markdown-it","markdown-it-plugin"],"created_at":"2024-10-12T01:35:21.813Z","updated_at":"2025-03-16T21:31:02.871Z","avatar_url":"https://github.com/yhatt.png","language":"JavaScript","readme":"# markdown-it-incremental-dom\n\n[![Travis CI](https://img.shields.io/travis/yhatt/markdown-it-incremental-dom.svg?style=flat-square)](https://travis-ci.org/yhatt/markdown-it-incremental-dom)\n[![Coveralls](https://img.shields.io/coveralls/yhatt/markdown-it-incremental-dom/master.svg?style=flat-square)](https://coveralls.io/github/yhatt/markdown-it-incremental-dom?branch=master)\n[![npm](https://img.shields.io/npm/v/markdown-it-incremental-dom.svg?style=flat-square)](https://www.npmjs.com/package/markdown-it-incremental-dom)\n[![LICENSE](https://img.shields.io/github/license/yhatt/markdown-it-incremental-dom.svg?style=flat-square)](./LICENSE)\n\nA [markdown-it](https://github.com/markdown-it/markdown-it) renderer plugin by using [Incremental DOM](https://github.com/google/incremental-dom).\n\nLet's see key features: **[https://yhatt.github.io/markdown-it-incremental-dom/](https://yhatt.github.io/markdown-it-incremental-dom/)** or [`docs.md`](docs/docs.md)\n\n[![](./docs/images/repainting-incremental-dom.gif)](https://yhatt.github.io/markdown-it-incremental-dom/)\n\n## Requirement\n\n- [markdown-it](https://github.com/markdown-it/markdown-it) \u003e= 4.0.0 (Recommend latest version \u003e= 8.4.0, that this plugin use it)\n- [Incremental DOM](https://github.com/google/incremental-dom) \u003e= 0.5.x\n\n## Examples\n\n### Node\n\n```javascript\nimport * as IncrementalDOM from 'incremental-dom'\nimport MarkdownIt from 'markdown-it'\nimport MarkdownItIncrementalDOM from 'markdown-it-incremental-dom'\n\nconst md = new MarkdownIt().use(MarkdownItIncrementalDOM, IncrementalDOM)\n\nIncrementalDOM.patch(\n  document.getElementById('target'),\n  md.renderToIncrementalDOM('# Hello, Incremental DOM!')\n)\n```\n\n### Browser\n\nDefine as `window.markdownitIncrementalDOM`.\n\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n  \u003chead\u003e\n    \u003cscript src=\"https://cdn.jsdelivr.net/npm/incremental-dom@0.6.0/dist/incremental-dom-min.js\"\u003e\u003c/script\u003e\n    \u003cscript src=\"https://cdn.jsdelivr.net/npm/markdown-it@8.4.2/dist/markdown-it.min.js\"\u003e\u003c/script\u003e\n    \u003cscript src=\"./node_modules/markdown-it-incremental-dom/dist/markdown-it-incremental-dom.min.js\"\u003e\u003c/script\u003e\n  \u003c/head\u003e\n  \u003cbody\u003e\n    \u003cdiv id=\"target\"\u003e\u003c/div\u003e\n\n    \u003cscript\u003e\n      const md = markdownit().use(markdownitIncrementalDOM)\n\n      IncrementalDOM.patch(\n        document.getElementById('target'),\n        md.renderToIncrementalDOM('# Hello, Incremental DOM!')\n      )\n    \u003c/script\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n```\n\n#### CDN\n\nYou can use [the recent version through CDN](https://cdn.jsdelivr.net/npm/markdown-it-incremental-dom@2/dist/markdown-it-incremental-dom.min.js) provides by [jsDelivr](https://www.jsdelivr.com/).\n\n```html\n\u003cscript src=\"https://cdn.jsdelivr.net/npm/markdown-it-incremental-dom@2/dist/markdown-it-incremental-dom.min.js\"\u003e\u003c/script\u003e\n```\n\n- **[Compressed (Recommend)](https://cdn.jsdelivr.net/npm/markdown-it-incremental-dom@2/dist/markdown-it-incremental-dom.min.js)**\n- [Uncompressed](https://cdn.jsdelivr.net/npm/markdown-it-incremental-dom@2/dist/markdown-it-incremental-dom.js)\n\n## Installation\n\nWe recommend using [yarn](https://yarnpkg.com/) to install.\n\n```bash\n$ yarn add incremental-dom markdown-it\n$ yarn add markdown-it-incremental-dom\n```\n\nIf you wanna use npm, try this:\n\n```bash\n$ npm install incremental-dom markdown-it --save\n$ npm install markdown-it-incremental-dom --save\n```\n\n## Usage\n\nWhen injecting this plugin by `.use()`, _you should pass Incremental DOM class as second argument._ (`window.IncrementalDOM` by default)\n\n```javascript\nimport * as IncrementalDOM from 'incremental-dom'\nimport MarkdownIt from 'markdown-it'\nimport MarkdownItIncrementalDOM from 'markdown-it-incremental-dom'\n\nconst md = new MarkdownIt().use(MarkdownItIncrementalDOM, IncrementalDOM)\n```\n\nIf it is succeed, [2 new rendering methods](#rendering-methods) would be injected to instance.\n\n\u003e **_TIPS:_** This plugin keeps default rendering methods [`render()`](https://markdown-it.github.io/markdown-it/#MarkdownIt.render) and [`renderInline()`](https://markdown-it.github.io/markdown-it/#MarkdownIt.renderInline).\n\n### Option\n\nYou can pass option object as third argument. See below:\n\n```javascript\nnew MarkdownIt().use(MarkdownItIncrementalDOM, IncrementalDOM, {\n  incrementalizeDefaultRules: false,\n})\n```\n\n- **`incrementalizeDefaultRules`**: For better performance, this plugin would override a few default renderer rules only when you calls injected methods. If the other plugins that override default rules have occurred any problem, You can disable overriding by setting `false`. _(`true` by default)_\n\n### Rendering methods\n\n#### `MarkdownIt.renderToIncrementalDOM(src[, env])` =\u003e `Function`\n\nSimilar to [`MarkdownIt.render(src[, env])`](https://markdown-it.github.io/markdown-it/#MarkdownIt.render) but _it returns a function for Incremental DOM_. It means doesn't render Markdown immediately.\n\nYou must render to DOM by using [`IncrementalDOM.patch(node, description)`](http://google.github.io/incremental-dom/#api/patch). Please pass the returned function to the description argument. For example:\n\n```javascript\nconst node = document.getElementById('#target')\nconst func = md.renderToIncrementalDOM('# Hello, Incremental DOM!')\n\n// It would render \"\u003ch1\u003eHello, Incremental DOM!\u003c/h1\u003e\" to \u003cdiv id=\"target\"\u003e\nIncrementalDOM.patch(node, func)\n```\n\n#### `MarkdownIt.renderInlineToIncrementalDOM(src[, env])` =\u003e `Function`\n\nSimilar to `MarkdownIt.renderToIncrementalDOM` but it wraps [`MarkdownIt.renderInline(src[, env])`](https://markdown-it.github.io/markdown-it/#MarkdownIt.renderInline).\n\n### Renderer property\n\n#### _get_ `MarkdownIt.IncrementalDOMRenderer` =\u003e [`Renderer`](https://markdown-it.github.io/markdown-it/#Renderer)\n\nReturns [`Renderer`](https://markdown-it.github.io/markdown-it/#Renderer) instance that includes Incremental DOM support.\n\nIt will inject Incremental DOM features into the current state of [`MarkdownIt.renderer`](https://markdown-it.github.io/markdown-it/#MarkdownIt.prototype.renderer) at getting this property.\n\n\u003e **_NOTE:_** This property is provided for the expert. Normally you should use `renderToIncrementalDOM()`.\n\u003e\n\u003e But it might be useful if you have to parse Markdown and operate tokens manually.\n\u003e\n\u003e ```javascript\n\u003e const md = new MarkdownIt()\n\u003e const tokens = md.parse('# Hello')\n\u003e\n\u003e // ...You can operate tokens here...\n\u003e\n\u003e const patch = md.IncrementalDOMRenderer.render(tokens, md.options)\n\u003e IncrementalDOM.patch(document.body, patch)\n\u003e ```\n\n## Development\n\n```bash\n$ git clone https://github.com/yhatt/markdown-it-incremental-dom\n\n$ yarn install\n$ yarn build\n```\n\n### Lint \u0026 Format\n\n```bash\n$ yarn lint            # Run ESLint\n$ yarn lint --fix      # Fix lint\n\n$ yarn format:check    # Run Prettier\n$ yarn format --write  # Fix formatting by Prettier\n```\n\n### Publish to npm\n\n```bash\n$ npm publish\n```\n\n:warning: Use npm \u003e= 5.0.0.\n\n## Author\n\nYuki Hattori ([@yhatt](https://github.com/yhatt/))\n\n## License\n\nThis plugin releases under the [MIT License](https://github.com/yhatt/markdown-it-incremental-dom/blob/master/LICENSE).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyhatt%2Fmarkdown-it-incremental-dom","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyhatt%2Fmarkdown-it-incremental-dom","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyhatt%2Fmarkdown-it-incremental-dom/lists"}