class documentation

Base class for block-level tokens. Recursively parse inner tokens.

Naming conventions:

  • lines denotes a list of (possibly unparsed) input lines, and is commonly used as the argument name for constructors.

  • BlockToken.children is a list with all the inner tokens (thus if a token has children attribute, it is not a leaf node; if a token calls span_token.tokenize_inner, it is the boundary between span-level tokens and block-level tokens);

  • BlockToken.start takes a line from the document as argument, and returns a boolean representing whether that line marks the start of the current token. Every subclass of BlockToken must define a start function (see block_tokenizer.tokenize).

  • BlockToken.read takes the rest of the lines in the ducment as an iterator (including the start line), and consumes all the lines that should be read into this token.

    Default to stop at an empty line.

    Note that BlockToken.read does not have to return a list of lines. Because the return value of this function will be directly passed into the token constructor, we can return any relevant parsing information, sometimes even ready-made tokens, into the constructor. See block_tokenizer.tokenize.

    If BlockToken.read returns None, the read result is ignored, but the token class is responsible for resetting the iterator to a previous state. See block_tokenizer.FileWrapper.anchor, block_tokenizer.FileWrapper.reset.

Static Method read Undocumented
Method __contains__ Undocumented
Method __init__ Undocumented
Instance Variable children inner tokens.

Inherited from Token:

Method __repr__ Undocumented
Class Variable repr_attributes Undocumented