2.0.0 • Published 1 year ago

adf2md v2.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

ADF2MD

ADF2MD offers you conversion of Atlassian's ADF (Atlassian Document Format) syntax into GitHub-flavored markdown, and conversion of GitHub-flavored markdown into ADF objects. Coverage for Atlassian-specific nodes is provided through MDX-style extension of the Markdown standard.

Why?

Because no developer wants to use a WYSIWYG editor to write notes.

Install

ADF2MD can be included as part of your project, or installed via CDN in the browser.

NPM

You can install the package via NPM:

npm install adf2md

Then, import the required functions into your project as needed:

import { convert, preview } from 'adf2md';

If you're making use of the preview function, don't forget to include the stylesheet, adf2md.min.css, somewhere in your document or bundle.

Browser/CDN

Include the <script> and <link> tags in your documents' <head> from UNPKG, or another CDN:

<script src="//unpkg.com/adf2md@latest/dist/adf2md.min.js">
<link rel="stylesheet" href="//unpkg.com/adf2md@latest/dist/adf2md.min.css">

Usage

ADF2MD includes two basic functions for working with markdown and the Atlassian Document format:

ADF2MD.convert()

Use ADF2MD.convert() to convert an ADF object into a markdown string or a markdown string into an ADF object.

ArgDefaultDescription
adfOrMdThe ADF object to convert into markdown or the markdown to convert to ADF.
(async () => {
  const markdown = await fetch('https://xyz.atlassian.net/issues/ATL-22', {
    method: 'GET',
    headers: { Authorization: 'Bearer ...' },
  })
    .then((res) => res.json())
    .then(({ fields: { description } }) => ADF2MD.convert(description));

  console.log(markdown);
})();

ADF2MD.preview()

Use ADF2MD.preview() to render an ADF object or ADF-style extended markdown string as GitHub-flavored markdown.

ArgDefaultDescription
adfOrMdThe ADF object or markdown to preview.
el'body'The target element or element selector where the preview should render.
fetch('https://xyz.atlassian.net/issues/ATL-22', {
  method: 'GET',
  headers: { Authorization: 'Bearer ...' },
})
  .then((res) => res.json())
  .then(({ fields: { description } }) =>
    ADF2MD.preview(description, '#markdown-preview'),
  );

Coverage

ADF2MD offers coverage for the following ADF nodes:

NodeStatusNotes
blockquoteFull Support
bulletListFull Support
codeBlockFull Support
emojiFull Support
hardBreakFull Support
headingFull Support
inlineCardNo Support
listItemFull Support
mediaNo support
mediaGroupNo support
mediaSingleNo support
mentionNo support
orderedListFull Support
panelFull SupportUsing MDX-style admonition.
paragraphFull Support
ruleFull Support
tablePartial SupportColumn alignment is not supported in ADF.
tableCellPartial SupportColumn alignment is not supported in ADF.
tableHeaderPartial SupportColumn alignment is not supported in ADF.
tableRowPartial SupportColumn alignment is not supported in ADF.
textFull Support
codeFull Support
emFull Support
linkFull Support
strikeNo Support
strongFull Support
subsupNo Support
textColorNo Support
underlineNo Support

License

MIT License | Copyright (c) 2022 Stephan Casas