Giter VIP home page Giter VIP logo

Comments (7)

zerodevx avatar zerodevx commented on June 13, 2024 3

Hey, thanks for your note. Given that Github now supports mermaid natively, I might add first-class support of this feature in a future release. In the meantime, something like this will work:

<head>
  ...
  <!-- Load mermaid -->
  <script defer src="https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js"></script>    
  <script type="module" src="https://cdn.jsdelivr.net/gh/zerodevx/zero-md@2/dist/zero-md.min.js"></script>
</head>

<body>
  <!-- Render zero-md in light dom -->
  <zero-md id="app" src="mermaid.md" no-shadow manual-render></zero-md>
  <script>
    app.addEventListener('zero-md-ready', async () => {
      // Create custom marked renderer
      const renderer = new marked.Renderer()
      renderer.code = function (code, lang) {
        return lang === 'mermaid'
          ? `<div class="mermaid">${code}</div>`
          : `<pre><code>${code}</code></pre>`
      }
      await app.render({ renderer })
      mermaid.init()
    })
  </script>
</body>

Here's a demo: https://plnkr.co/edit/Q64k8e498RfGDdlC

from zero-md.

zerodevx avatar zerodevx commented on June 13, 2024 3

@CetinSert

The demo linked below uses SyncHTML.io. (I am building it.)

Wow! That's a cool project - looks really good!

the approach suggested above breaks encapsulation.

Unfortunately, yes, mainly because of how mermaid works. For now, the markdown must be rendered into light dom - until first-class support is eventually added into zero-md (soon!). 😞

from zero-md.

simboonlong avatar simboonlong commented on June 13, 2024

amazing library, looking forward to this feature

from zero-md.

mmoehrlein avatar mmoehrlein commented on June 13, 2024

This was exactly what I was looking for! Awesome project, thanks a lot :)

from zero-md.

CetinSert avatar CetinSert commented on June 13, 2024

@zerodevxthe approach suggested above breaks encapsulation.

<zero-md> is the only third-party custom element I have seen that behaves like the standard elements of HTML in that it does not gain attributes on getting connected to a document or leaks state in other weird ways.

Demo of just how awesome <zero-md> is

The demo linked below uses RTCode.io. (I am building it.)


See what we mean with the following steps:

  1. Go to md.rt.ht/? 👈🏻
  2. Press / keys
  3. Notice the video does not restart on edit.
    This is all because you are doing custom elements right™ ❤️!

SyncHTML.io – the next-gen, no-reload, real-time web playground with instant two-way input ⇄ output sync.
(try, learn more)

from zero-md.

CetinSert avatar CetinSert commented on June 13, 2024

RTCode.io ❤️ <zero-md>

Dear @zerodevx,

We have dedicated the short domain md.rt.ht to the latest stable version of <zero-md>!
It is the shortest domain you can get that serves as an editable quick starting point! See below ↙️!

In the address bar of your browser:

type get
md.rt.ht/? editor
md.rt.ht output

All you need is a single /? to edit your edge-deployed syncs!
Just hit Ctrl+S1 to update it in 275+ cities around the world!

(1 RTEdge.net restricts saves/updates to Elefunc, Inc. until we reach public beta.)

Best Regards,
@CetinSert

from zero-md.

zerodevx avatar zerodevx commented on June 13, 2024

First class support for mermaid diagrams (into the shadow dom no less) is now available in V3, so do check it out!

from zero-md.

Related Issues (20)

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.