From fa5c857321de23af55e083c12524cf789703263f Mon Sep 17 00:00:00 2001 From: Justin Poehnelt Date: Mon, 21 Oct 2024 20:24:10 +0000 Subject: [PATCH] feat(to-markdown): expose markdown ast --- packages/to-markdown/index.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/packages/to-markdown/index.js b/packages/to-markdown/index.js index 3971066c..c1a07800 100644 --- a/packages/to-markdown/index.js +++ b/packages/to-markdown/index.js @@ -241,10 +241,17 @@ function makeModuleDoc(mod, options) { * @return {string} */ export function customElementsManifestToMarkdown(manifest, options) { - const tree = - root(manifest.modules - .flatMap(x => makeModuleDoc(x, options)) - .filter(identity)) + return serialize(customElementsManifestToMarkdownAST(manifest, options)); +} - return serialize(tree); +/** + * Renders a custom elements manifest as Markdown AST + * @param {import('custom-elements-manifest/schema').Package} manifest + * @param {import('./types/main').Options} manifest + * @return {import('mdast-util-to-markdown/lib/types.js').Parent} + */ +export function customElementsManifestToMarkdownAST(manifest, options) { + return root(manifest.modules + .flatMap(x => makeModuleDoc(x, options)) + .filter(identity)); }