Home

Awesome

mdast-util-from-adf

Checks npm version

mdast utility to convert ADF.

Install

This package is ESM only: Node 12+ is needed to use it and it must be imported instead of required.

npm:

npm install mdast-util-from-adf

Use

Say we have the following script, example.js:

import { fromADF } from "mdast-util-from-adf";
import { toMarkdown } from "mdast-util-to-markdown";

const doc = {
  version: 1,
  type: "doc",
  content: [
    {
      type: "paragraph",
      content: [
        {
          type: "text",
          text: "Hello ",
        },
        {
          type: "text",
          text: "ADF",
          marks: [
            {
              type: "link",
              attrs: {
                href: "https://developer.atlassian.com/cloud/jira/platform/apis/document/structure/",
              },
            },
            {
              type: "strong",
            },
          ],
        },
        {
          type: "text",
          text: "!",
        },
      ],
    },
  ],
};

console.log(toMarkdown(fromADF(doc)));

Now, running node example yields:

Hello **[ADF](https://developer.atlassian.com/cloud/jira/platform/apis/document/structure/)**!

References