selfdoc v0.15.1 /selfdoc.tokenizer
On this page

Standalone zero-dependency Markdown block tokenizer that splits source into 11 typed token dataclasses with line numbers for rendering and lint analysis.

#selfdoc.tokenizer

#selfdoc.tokenizer

Standalone Markdown block tokenizer.

Splits Markdown source into a flat list of typed block tokens. Each token carries 1-based start and end line numbers so the caller knows exactly which source lines produced it.

No imports from selfdoc -- this module is designed for reuse outside the project.

#CodeBlock

CodeBlock
FieldTypeDefault
langstr
lineslist[str]
annotationsdict[str, str]
startint
endint
runboolFalse
line_numbersboolFalse
line_startint1

#Heading

Heading
FieldTypeDefault
levelint
textstr
startint
endint

#Table

Table
FieldTypeDefault
rowslist[str]
startint
endint

#UnorderedList

UnorderedList
FieldTypeDefault
itemslist[str]
startint
endint

#OrderedList

OrderedList
FieldTypeDefault
itemslist[str]
startint
endint

#Blockquote

Blockquote
FieldTypeDefault
lineslist[str]
admonition_typestrNone
startint
endint

#DefinitionList

DefinitionList
FieldTypeDefault
entrieslist[tuple[str, list[str]]]
startint
endint

#ThematicBreak

ThematicBreak
FieldTypeDefault
startint
endint

#BlankLine

BlankLine
FieldTypeDefault
startint
endint

#Directive

Directive
FieldTypeDefault
namestr
argstr
bodylist[str]
startint
endint

#Paragraph

Paragraph
FieldTypeDefault
lineslist[str]
startint
endint

#tokenize

python
def tokenize(content: str) -> list[Block]

Tokenize Markdown content into a list of block tokens.

Line numbers on every token are 1-based (first line of the file is 1). The tokens cover every line exactly once -- no gaps and no overlaps.