Skip to content

Instantly share code, notes, and snippets.

@ThePlenkov
Last active June 13, 2023 00:11
Show Gist options
  • Save ThePlenkov/f800bc78cb33fc489d457ab8a4751413 to your computer and use it in GitHub Desktop.
Save ThePlenkov/f800bc78cb33fc489d457ab8a4751413 to your computer and use it in GitHub Desktop.
Convert markdown to Confluence XHTML
import {MarkdownTransformer} from "@atlaskit/editor-markdown-transformer";
import {defaultSchema} from "@atlaskit/adf-schema/schema-default";
import {ConfluenceTransformer} from "@atlaskit/editor-confluence-transformer";
import {JSDOM} from "jsdom";
test("Create a new page", async () => {
const md = new MarkdownTransformer(defaultSchema);
const ct = new ConfluenceTransformer(defaultSchema);
const mdADF = md.parse("# Hello!");
const dom = new JSDOM(
"<!DOCTYPE html><html><head></head><body></body></html>"
);
global.document = dom.window.document;
const mdXML = ct.encode(mdADF);
expect(mdXML).toBe("<h1>Hello!</h1>");
}, 100000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment