Last active
May 22, 2025 08:14
-
-
Save ThePlenkov/f800bc78cb33fc489d457ab8a4751413 to your computer and use it in GitHub Desktop.
Convert markdown to Confluence XHTML
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
Thank you for such a great gist 💪
Here is one more, in case if anyone will be landed here
In my case, I was looking for a way to create markdown from Jira ticket description
At moment it is semi doable
Here is a snippet:
as you may see, at moment
MarkdownTransformer
encode method is not implemented, but still we can create HTML and later, convert it to markdown