MarkdownExtractorExtractCodeBlocks Method

Extracts code blocks from a given markdown text, optionally filtering by programming language. Code blocks can include fenced code blocks with a specific language tag as well as indented code blocks.

Definition

Namespace: GenerativeAI.Utility
Assembly: GenerativeAI (in GenerativeAI.dll) Version: 2.0.2+aa51399cad6d90cc71158d589a6268608b3c1893
C#
public static List<CodeBlock> ExtractCodeBlocks(
	string markdown,
	string languageFilter = "*"
)

Parameters

markdown  String
The markdown content from which code blocks will be extracted.
languageFilter  String  (Optional)
An optional filter to extract only code blocks of a specific programming language. Use "*" to extract code blocks of any language.

Return Value

ListCodeBlock
A list of CodeBlock objects, each representing a code segment with details about its programming language and line number.

See Also