@telefonica/markdown-confluence-sync
Version:
Creates/updates/deletes Confluence pages based on markdown files in a directory. Supports Mermaid diagrams and per-page configuration using frontmatter metadata. Works great with Docusaurus
29 lines (28 loc) • 928 B
JavaScript
// SPDX-FileCopyrightText: 2024 Telefónica Innovación Digital
// SPDX-License-Identifier: Apache-2.0
import { mdxToMarkdown } from "mdast-util-mdx";
import { toMarkdown } from "mdast-util-to-markdown";
import { replace } from "../../../../support/unist/unist-util-replace.js";
const mdxElement = "mdxJsxFlowElement";
/**
* UnifiedPlugin to prevent \<Details\> elements from being removed from the tree.
*
* @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/details}
*/
const remarkTransformDetails = function remarkTransformDetails() {
return function (tree) {
replace(tree, mdxElement, transformDetailsTag);
};
};
function transformDetailsTag(node) {
if (node.name !== "details") {
return node;
}
return {
type: "html",
value: toMarkdown(node, {
extensions: [mdxToMarkdown()],
}),
};
}
export default remarkTransformDetails;