🚀 DAY 5 OF LAUNCH WEEK: Introducing Socket Firewall Enterprise.Learn more →
Socket
Book a DemoInstallSign in
Socket

@docus/mdc

Package Overview
Dependencies
Maintainers
5
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@docus/mdc

The Markdown Components parser for Docus.

latest
Source
npmnpm
Version
0.2.0
Version published
Weekly downloads
1
-98.08%
Maintainers
5
Weekly downloads
 
Created
Source

MDC

Install

# Using Yarn
yarn add --dev @docus/mdc
# Using NPM
npm install --save-dev @docus/mdc

Use

import mdc from '@docus/mdc'

const markdown = `---
frontmatter: data
---

## section title

::custom-component
Default Slot
::
`

await mdc.parse(markdown)

The result will be

{
  "body": {
    "raw": "---\nfrontmatter: data\n---\n\n## section title\n\n::custom-component\nDefault Slot\n::\n",
    "ast": {
      "type": "root",
      "children": [
        {
          "type": "element",
          "tag": "h2",
          "props": {
            "id": "section-title"
          },
          "children": [
            {
              "type": "element",
              "tag": "a",
              "props": {
                "href": "#section-title"
              },
              "children": [
                {
                  "type": "text",
                  "value": "section title"
                }
              ]
            }
          ]
        },
        {
          "type": "text",
          "value": "\n"
        },
        {
          "type": "element",
          "tag": "custom-component",
          "props": {},
          "children": [
            {
              "type": "element",
              "tag": "p",
              "props": {},
              "children": [
                {
                  "type": "text",
                  "value": "Default Slot"
                }
              ]
            }
          ]
        }
      ]
    },
    "toc": {
      "title": "",
      "searchDepth": 2,
      "depth": 2,
      "links": [
        {
          "id": "section-title",
          "depth": 2,
          "text": "section title"
        }
      ]
    }
  },
  "meta": {
    "frontmatter": "data",
    "empty": false,
    "title": "",
    "description": ""
  }
}

Keywords

markdown

FAQs

Package last updated on 24 Nov 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts