pyk.kast.markdown module

final class And(ops: 'tuple[Selector, ...]')[source]

Bases: Selector

eval(atoms: Container[str]) bool[source]
ops: tuple[Selector, ...]
final class Atom(name: 'str')[source]

Bases: Selector

eval(atoms: Container[str]) bool[source]
name: str
class CodeBlock(info, code)[source]

Bases: NamedTuple

code: str

Alias for field number 1

info: str

Alias for field number 0

final class Not(op: 'Selector')[source]

Bases: Selector

eval(atoms: Container[str]) bool[source]
op: Selector
final class Or(ops: 'tuple[Selector, ...]')[source]

Bases: Selector

eval(atoms: Container[str]) bool[source]
ops: tuple[Selector, ...]
class Selector[source]

Bases: ABC

abstract eval(atoms: Container[str]) bool[source]
class SelectorParser(selector: str)[source]

Bases: object

parse() Selector[source]
code_blocks(text: str) Iterator[CodeBlock][source]
parse_tags(text: str) set[str][source]
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.

selector_lexer(it: Iterable[str]) Iterator[str][source]