How to use @marp-team/marp-core - 6 common examples

To help you get started, we’ve selected a few @marp-team/marp-core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github marp-team / marp-vscode / src / extension.ts View on Github external
md.parse = (markdown: string, env: any) => {
    // Generate tokens by Marp if enabled
    if (detectMarpFromMarkdown(markdown)) {
      const mdFolder = Uri.parse(md.normalizeLink('.')).with({ scheme: 'file' })
      const workspaceFolder = workspace.getWorkspaceFolder(mdFolder)
      const baseFolder = workspaceFolder ? workspaceFolder.uri : mdFolder

      const marp = new Marp(marpCoreOptionForPreview(md.options))
        .use(customTheme)
        .use(outline)
        .use(lineNumber)

      // Load custom themes
      let shouldRefresh = false

      Promise.all(
        themes.loadStyles(baseFolder).map(promise =>
          promise
            .then(theme => {
              if (theme.registered) shouldRefresh = true
            })
            .catch(e => console.error(e))
        )
      ).then(() => {
github tyrchen / tongjian / tools / cli / engine.js View on Github external
module.exports = opts => {
  return new Marp(opts)
    .use(markdownItMark)
    // .use(markdownItFootnote)
    .use(markdownItAbbr)
    .use(markdownItSup)
    .use(markdownItSub)
    .use(markdownItEmoji)
    .use(html5Media)
    .use(markdownItContainer, 'note');

}
github marp-team / marp-web / src / animation-frame.ts View on Github external
private loop() {
    // At first, clear the event queue for adding funcs to execute in next frame
    const events = this.animationEvents
    this.animationEvents = []

    // Execute registered events
    for (const func of events) func()

    // Finally trigger marp-core's fitting
    MarpBrowser(false)

    if (this.dispatched) this.requestAnimationFrame()
  }
github marp-team / marp-vscode / src / preview.ts View on Github external
if (marpVscode) {
    document.body.classList.add('marp-vscode')

    // Remove default styles
    const styles = document.querySelectorAll(
      'style:not(#marp-vscode-style):not(#_defaultStyles)'
    )
    const links = document.querySelectorAll(
      'link[rel="stylesheet"]:not([href*="marp-vscode"])'
    )
    styles.forEach(elm => elm.remove())
    links.forEach(elm => elm.remove())

    // Run Marp observer
    browserCjs()
  }
}
github marp-team / marp-cli / test / templates / bespoke.ts View on Github external
describe("Bespoke template's browser context", () => {
  const marp = new Marp({
    container: new MarpitElement('div', { id: 'p' }),
  })

  const defaultMarkdown = '# 1\n\n---\n\n## 2\n\n---\n\n### 3'

  const render = (
    md = defaultMarkdown,
    targetDocument = document
  ): HTMLElement => {
    targetDocument.body.innerHTML = marp.render(md).html
    return targetDocument.getElementById('p')!
  }

  const replaceLocation = >(
    path: string,
    action: () => T
github marp-team / marp / packages / website / src / components / marp.js.jsx View on Github external
export const Marp = props => {
  const marp = new MarpCore({
    container: null,
    script: false,
    printable: false,
  })

  marp.markdown.normalizeLink = url => resolvePath(url)

  const rendered = marp.render(props.markdown, { htmlAsArray: true })

  return (
    <div>
      </div>

@marp-team/marp-core

The core of Marp tools

MIT
Latest version published 2 months ago

Package Health Score

79 / 100
Full package analysis