@kubb/parser-md
v5.3.19
Published
Markdown source file parser for Kubb. Converts the universal AST to `.md` source and renders YAML frontmatter via the `print` helper.
Maintainers
Readme
@kubb/parser-md
Markdown source file parser for Kubb
Joins source blocks as plain markdown and renders YAML frontmatter via parserMd.print.
Installation
bun add @kubb/parser-md
# or
pnpm add @kubb/parser-md
# or
npm install @kubb/parser-mdUsage
import { defineConfig } from 'kubb'
import { parserMd } from '@kubb/parser-md'
import { parserTs } from '@kubb/parser-ts'
export default defineConfig({
input: './petstore.yaml',
output: { path: './src/gen' },
parsers: [parserTs(), parserMd()],
})To convert a metadata object into a YAML frontmatter envelope from inside a plugin, call print on a parser instance:
import { parserMd } from '@kubb/parser-md'
const source = parserMd().print({ title: 'Pets', layout: 'doc' })
// → ---
// title: Pets
// layout: doc
// ---API
parserMd()
Factory returning a parser instance for .md and .markdown files. Pass to defineConfig({ parsers: [...] }) to emit Markdown source files.
The returned instance exposes parse(file) to serialize a FileNode to Markdown source (prepending the YAML envelope when file.meta.frontmatter is set) and print(...parts) to join markdown fragments separated by blank lines, serializing plain objects as YAML frontmatter and passing strings through unchanged.
Supporting Kubb
Kubb is an open source project, and its development is funded entirely by sponsors. If you would like to become a sponsor, please consider:
