Skip to main content

Code

Convenience functions to process code.

Extract

extract(markdown, language)

Extracts code blocks from markdown text.

When no language is specified, a dictionary is retrieved with all code blocks grouped by lanuage. If the blocks contain filename header, a dictionary of file names is retrieve instead. The default can contain a dictionary of files to use as defaults.

ParamTypeDescription
markdownStringThe markdown to extract blocks from.
languageStringThe language of the code blocks to extract.
defaultAnyThe default value when code not found, defaults to None.