mdast-util-from-adf
v2.1.1
Published
Convert from Atlassian Document Format to Markdown Abstract Syntax Tree
Downloads
153
Readme
mdast-util-from-adf
Install
This package is ESM only:
Node 12+ is needed to use it and it must be import
ed instead of require
d.
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
- Atlassian Document Format: https://developer.atlassian.com/cloud/jira/platform/apis/document/structure/
- ADF Builder: https://developer.atlassian.com/cloud/jira/platform/apis/document/playground/
- ADF Viewer: https://developer.atlassian.com/cloud/jira/platform/apis/document/viewer/