All Projects → yhatt → Markdown It Incremental Dom

yhatt / Markdown It Incremental Dom

Licence: mit
markdown-it renderer plugin by using Incremental DOM.

Programming Languages

javascript
184084 projects - #8 most used programming language

Labels

Projects that are alternatives of or similar to Markdown It Incremental Dom

Ods2md
Convert LibreOffice Calc Spreadsheets (*.ods) into Markdown tables.
Stars: ✭ 35 (-20.45%)
Mutual labels:  markdown
Markdown Latex
A markdown parser for converting markdown to LaTeX written in PHP.
Stars: ✭ 40 (-9.09%)
Mutual labels:  markdown
Html2md
html2markdown,converts html to markdown
Stars: ✭ 41 (-6.82%)
Mutual labels:  markdown
Blankup Electron
Markdown editor with clarity +1, as a desktop application.
Stars: ✭ 37 (-15.91%)
Mutual labels:  markdown
Markdownview
MarkdownView is an Android webview with the capablity of loading Markdown text or file and display it as HTML, it uses MarkdownJ and extends Android webview.
Stars: ✭ 993 (+2156.82%)
Mutual labels:  markdown
Remark Boilerplate
A boilerplate to create presentations using remark, Gulp, Stylus and more.
Stars: ✭ 41 (-6.82%)
Mutual labels:  markdown
Text Runner
Test runner for text
Stars: ✭ 35 (-20.45%)
Mutual labels:  markdown
Pagic
A static site generator powered by Deno + React
Stars: ✭ 1,016 (+2209.09%)
Mutual labels:  markdown
Cv Maker
simple elegant markdown based resumes
Stars: ✭ 1,003 (+2179.55%)
Mutual labels:  markdown
Metalsmith
An extremely simple, pluggable static site generator.
Stars: ✭ 7,692 (+17381.82%)
Mutual labels:  markdown
Grunt Md2html
Small Grunt MultiTask to convert Markdown files to HTML, supporting Grunt >= 1.0.0
Stars: ✭ 37 (-15.91%)
Mutual labels:  markdown
Recipes
A super minimal recipe website built on Markdown
Stars: ✭ 38 (-13.64%)
Mutual labels:  markdown
Markdown2pdf
A simple library to convert markdown to pdf using Java
Stars: ✭ 41 (-6.82%)
Mutual labels:  markdown
Qlcommonmark
QuickLook generator for beautifully rendering CommonMark documents on macOS
Stars: ✭ 36 (-18.18%)
Mutual labels:  markdown
Hastysite
A small but powerful static site generator
Stars: ✭ 42 (-4.55%)
Mutual labels:  markdown
Tmdlang
Timebase MarkDown Language
Stars: ✭ 35 (-20.45%)
Mutual labels:  markdown
Mkdocs With Pdf
Generate a single PDF file from MkDocs repository.
Stars: ✭ 39 (-11.36%)
Mutual labels:  markdown
Mdnote
📝 [website] A cloud notepad
Stars: ✭ 43 (-2.27%)
Mutual labels:  markdown
Marked
Confluence macro plugin which renders remote Markdown.
Stars: ✭ 42 (-4.55%)
Mutual labels:  markdown
Mdopen
View markdown files in the default browser
Stars: ✭ 42 (-4.55%)
Mutual labels:  markdown

markdown-it-incremental-dom

Travis CI Coveralls npm LICENSE

A markdown-it renderer plugin by using Incremental DOM.

Let's see key features: https://yhatt.github.io/markdown-it-incremental-dom/ or docs.md

Requirement

Examples

Node

import * as IncrementalDOM from 'incremental-dom'
import MarkdownIt from 'markdown-it'
import MarkdownItIncrementalDOM from 'markdown-it-incremental-dom'

const md = new MarkdownIt().use(MarkdownItIncrementalDOM, IncrementalDOM)

IncrementalDOM.patch(
  document.getElementById('target'),
  md.renderToIncrementalDOM('# Hello, Incremental DOM!')
)

Browser

Define as window.markdownitIncrementalDOM.

<!DOCTYPE html>
<html>
  <head>
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/incremental-dom-min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/markdown-it.min.js"></script>
    <script src="./node_modules/markdown-it-incremental-dom/dist/markdown-it-incremental-dom.min.js"></script>
  </head>
  <body>
    <div id="target"></div>

    <script>
      const md = markdownit().use(markdownitIncrementalDOM)

      IncrementalDOM.patch(
        document.getElementById('target'),
        md.renderToIncrementalDOM('# Hello, Incremental DOM!')
      )
    </script>
  </body>
</html>

CDN

You can use the recent version through CDN provides by jsDelivr.

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/markdown-it-incremental-dom.min.js"></script>

Installation

We recommend using yarn to install.

$ yarn add incremental-dom markdown-it
$ yarn add markdown-it-incremental-dom

If you wanna use npm, try this:

$ npm install incremental-dom markdown-it --save
$ npm install markdown-it-incremental-dom --save

Usage

When injecting this plugin by .use(), you should pass Incremental DOM class as second argument. (window.IncrementalDOM by default)

import * as IncrementalDOM from 'incremental-dom'
import MarkdownIt from 'markdown-it'
import MarkdownItIncrementalDOM from 'markdown-it-incremental-dom'

const md = new MarkdownIt().use(MarkdownItIncrementalDOM, IncrementalDOM)

If it is succeed, 2 new rendering methods would be injected to instance.

TIPS: This plugin keeps default rendering methods render() and renderInline().

Option

You can pass option object as third argument. See below:

new MarkdownIt().use(MarkdownItIncrementalDOM, IncrementalDOM, {
  incrementalizeDefaultRules: false,
})
  • 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)

Rendering methods

MarkdownIt.renderToIncrementalDOM(src[, env]) => Function

Similar to MarkdownIt.render(src[, env]) but it returns a function for Incremental DOM. It means doesn't render Markdown immediately.

You must render to DOM by using IncrementalDOM.patch(node, description). Please pass the returned function to the description argument. For example:

const node = document.getElementById('#target')
const func = md.renderToIncrementalDOM('# Hello, Incremental DOM!')

// It would render "<h1>Hello, Incremental DOM!</h1>" to <div id="target">
IncrementalDOM.patch(node, func)

MarkdownIt.renderInlineToIncrementalDOM(src[, env]) => Function

Similar to MarkdownIt.renderToIncrementalDOM but it wraps MarkdownIt.renderInline(src[, env]).

Renderer property

get MarkdownIt.IncrementalDOMRenderer => Renderer

Returns Renderer instance that includes Incremental DOM support.

It will inject Incremental DOM features into the current state of MarkdownIt.renderer at getting this property.

NOTE: This property is provided for the expert. Normally you should use renderToIncrementalDOM().

But it might be useful if you have to parse Markdown and operate tokens manually.

const md = new MarkdownIt()
const tokens = md.parse('# Hello')

// ...You can operate tokens here...

const patch = md.IncrementalDOMRenderer.render(tokens, md.options)
IncrementalDOM.patch(document.body, patch)

Development

$ git clone https://github.com/yhatt/markdown-it-incremental-dom

$ yarn install
$ yarn build

Lint & Format

$ yarn lint            # Run ESLint
$ yarn lint --fix      # Fix lint

$ yarn format:check    # Run Prettier
$ yarn format --write  # Fix formatting by Prettier

Publish to npm

$ npm publish

⚠️ Use npm >= 5.0.0.

Author

Yuki Hattori (@yhatt)

License

This plugin releases under the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].