pyk.kast.markdown module
- class CodeBlock(info, code)[source]
Bases:
NamedTuple- code: str
Alias for field number 1
- info: str
Alias for field number 0
- select_code_blocks(text: str, selector: str | None = None) str[source]
Extract selected fenced code blocks, preserving line and column positions.
Non-code characters (markdown prose, fence markers) are replaced with spaces so that the output string has the same newline structure as the input. This ensures that line/column numbers reported by the outer lexer match the original file, which is required for accurate error reporting in the inner parser (Java kompile).
Replicates the behaviour of Java’s ExtractFencedKCodeFromMarkdown.