Giter Site home page Giter Site logo

remark-mermaid-plugin's Introduction

remark-mermaid-plugin

remark plugin to support mermaid for browser use, helpful for react-markdown

Install

npm install @moevis/remark-mermaid-plugin

Usage

Our module exampl.js looks as follows:

import ReactMarkdown from "react-markdown";
import rehypeRaw from "rehype-raw";
import rehypeStringify from "rehype-stringify";
import remarkMermaidPlugin from '@moevis/remark-mermaid-plugin';

const markdownContent = `
    ```mermaid
    graph LR
      excute1[i = 1]
      excute2[j = 0]
      excute3[i ++]
      excute4["a = arr[j], b = arr[j + 1]"]
      excute5[change a, b]
      excute6[j ++]
        judge1["i < n"]
        judge2["j < n - i"]
      judge3["a > b"]
      start --> excute1
      excute1 --> judge1
      judge1 --Y--> excute2
      excute2 --> judge2
      judge2 --Y--> excute4
      judge2 --N--> excute3
      excute3 --> judge1
      excute4 --> judge3
      judge3 --N--> judge2
      judge3 --Y--> excute5
      excute5 --> excute6
      excute6 --> judge2
      judge1 --N--> end
    ```
`

function Markdown() {

  return (
    <ReactMarkdown
      children={markdownContent}
      remarkPlugins={[
        [remarkMermaidPlugin, { theme: "dark" }],
      ]}
      rehypePlugins={[
        rehypeRaw,
        rehypeStringify,
      ]}
    />
  );
}

or

<ReactMarkdown
  children={markdownContent}
  remarkPlugins={[
    remarkMermaidPlugin
  ]}
  rehypePlugins={[
    rehypeRaw,
    rehypeStringify,
  ]}
/>

remark-mermaid-plugin's People

Contributors

moevis avatar

Stargazers

nabi avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.