class documentation

class BlockToken(object):

Known subclasses: mistletoe.block_token.BlockCode, mistletoe.block_token.CodeFence, mistletoe.block_token.Document, mistletoe.block_token.Footnote, mistletoe.block_token.Heading, mistletoe.block_token.HTMLBlock, mistletoe.block_token.List, mistletoe.block_token.ListItem, mistletoe.block_token.Paragraph, mistletoe.block_token.Quote, mistletoe.block_token.SetextHeading, mistletoe.block_token.Table, mistletoe.block_token.TableCell, mistletoe.block_token.TableRow, mistletoe.block_token.ThematicBreak

View In Hierarchy

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.
def __contains__(self, text):

Undocumented