Skip to content

How to render markdown presentation in browser using marp? #480

Answered by yhatt
GoBigorGoHome asked this question in Q&A
Discussion options

You must be logged in to vote

This is a deadly simple but actually working example for the live editor of Marp Core.

<!DOCTYPE html>
<html lang="en">
  <body>
    <div style="display: flex; width: 1000px; height: 600px">
      <textarea id="md" style="flex: 1; resize: none"></textarea>
      <div id="render" style="flex: 1; overflow-y: auto"></div>
    </div>
    
    <script type="module">
      import { Marp } from 'https://esm.sh/@marp-team/marp-core?bundle'
      import browser from 'https://esm.sh/@marp-team/marp-core/browser'

      const marp = new Marp({ script: false })

      md.addEventListener('input', () => {
        const { html, css } = marp.render(md.value)
        render.innerHTML = `${html}<style>${css}

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by GoBigorGoHome
Comment options

You must be logged in to vote
2 replies
@yhatt
Comment options

@scokobro
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants