Skip to content

Commit

Permalink
feat: Custom ADF via Codeblock and adf language
Browse files Browse the repository at this point in the history
  • Loading branch information
andymac4182 committed Apr 20, 2023
1 parent 82688d6 commit 8e91630
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions packages/lib/src/MdToADF.ts
Expand Up @@ -7,6 +7,7 @@ import { traverse } from "@atlaskit/adf-utils/traverse";
import { MarkdownFile } from "./adaptors";
import { LocalAdfFile } from "./Publisher";
import { processConniePerPageConfig } from "./ConniePageConfig";
import { p } from "@atlaskit/adf-utils/builders";

const frontmatterRegex = /^\s*?---\n([\s\S]*?)\n---/g;

Expand Down Expand Up @@ -72,6 +73,24 @@ export class MdToADF {
delete node.attrs;
}

if ((node.attrs || {})?.language === "adf") {
if (!node?.content?.at(0)?.text) {
return node;
}
try {
const parsedAdf = JSON.parse(
node?.content?.at(0)?.text ??
JSON.stringify(
p("ADF missing from ADF Code Block.")
)
);
node = parsedAdf;
return node;
} catch (e) {
return node;
}
}

return node;
},
});
Expand Down

0 comments on commit 8e91630

Please sign in to comment.