markupit.structure package

Submodules

markupit.structure.block module

class markupit.structure.block.BlockQuote(content: list)[source]

Bases: Block

A class representing a BlockQuote element of Block type.

Parameters:

content (List[Block]) – The content of the element.

class markupit.structure.block.BulletList(content: list)[source]

Bases: Block

A class representing a BulletList element of Block type.

Parameters:

content (List[List[Block]]) – The content of the element.

class markupit.structure.block.CodeBlock(content: list)[source]

Bases: Block

A class representing a CodeBlock element of Block type.

Parameters:

content ([Attr, str]) – The content of the element.

class markupit.structure.block.DefinitionList(content: list)[source]

Bases: Block

A class representing a DefinitionList element of Block type.

Parameters:

content (List[List[List[Inline]], List[List[List[Block]]]]) – The content of the element.

class markupit.structure.block.Div(content: list)[source]

Bases: Block

A class representing a Div element of Block type.

Parameters:

content ([Attr, List[Block]]) – The content of the element.

class markupit.structure.block.Figure(content: list)[source]

Bases: Block

A class representing a Figure element of Block type.

Parameters:

content ([Attr, Caption, List[Block]]) – The content of the element.

class markupit.structure.block.Header(content: list)[source]

Bases: Block

A class representing a Header element of Block type.

Parameters:

content ([int, Attr, List[Inline]]) – The content of the element.

class markupit.structure.block.HorizontalRule[source]

Bases: Block

A class representing a HorizontalRule element of Block type.

class markupit.structure.block.LineBlock(content: list)[source]

Bases: Block

A class representing a LineBlock element of Block type.

Parameters:

content (List[List[Inline]]) – The content of the element.

class markupit.structure.block.Null[source]

Bases: Block

A class representing a Null element of Block type.

class markupit.structure.block.OrderedList(content: list)[source]

Bases: Block

A class representing an OrderedList element of Block type.

Parameters:

content ([ListAttributes, List[List[Block]]]) – The content of the element.

class markupit.structure.block.Para(content: list)[source]

Bases: Block

A class representing a Para element of Block type.

Parameters:

content (List[Inline]) – The content of the element.

class markupit.structure.block.Plain(content: list)[source]

Bases: Block

A class representing a Plain element of Block type.

Parameters:

content (List[Inline]) – The content of the element.

class markupit.structure.block.RawBlock(content: list)[source]

Bases: Block

A class representing a RawBlock element of Block type.

Parameters:

content ([Format, str]) – The content of the element.

class markupit.structure.block.Table(content: list)[source]

Bases: Block

A class representing a Table element of Block type.

Parameters:

content ([Attr, Caption, List[ColSpec], TableHead, List[TableBody], TableFoot]) – The content of the element.

markupit.structure.content module

class markupit.structure.content.Attr(content: list)[source]

Bases: ContentElement

Class representing an Attr element.

Parameters:

content (list) – The content of the element.

class markupit.structure.content.Caption(content: list)[source]

Bases: ContentElement

Class representing a Caption element.

Parameters:

content ([List[Inline] | null, List[Block]]) – The content of the element.

class markupit.structure.content.Cell(content: list)[source]

Bases: ContentElement

Class representing a Cell element.

Parameters:

content ([Attr, Alignment, int, int, List[Block]]) – The content of the element.

class markupit.structure.content.Citation(content: list)[source]

Bases: ContentElement

Class representing a Citation element.

Parameters:

content ([str, List[Inline], List[Inline], CitationMode, int, int]) – The content of the element.

class markupit.structure.content.ColSpec(content: list)[source]

Bases: ContentElement

Class representing a ColSpec element.

Parameters:

content ([Alignment, ColWidth]) – The content of the element.

class markupit.structure.content.Format(content: str)[source]

Bases: ContentElement

Class representing a Format element.

Parameters:

content (str) – The content of the element.

class markupit.structure.content.ListAttributes(content: list)[source]

Bases: ContentElement

Class representing a ListAttributes element.

Parameters:

content ([int, ListNumberStyle, ListNumberDelim]) – The content of the element.

class markupit.structure.content.Row(content: list)[source]

Bases: ContentElement

Class representing a Row element.

Parameters:

content ([Attr, List[Cell]]) – The content of the element.

class markupit.structure.content.TableBody(content: list)[source]

Bases: ContentElement

Class representing a TableBody element.

Parameters:

content ([Attr, int, List[Row], List[Row]]) – The content of the element.

class markupit.structure.content.TableFoot(content: list)[source]

Bases: ContentElement

Class representing a TableFoot element.

Parameters:

content ([Attr, List[Row]]) – The content of the element.

class markupit.structure.content.TableHead(content: list)[source]

Bases: ContentElement

Class representing a TableHead element.

Parameters:

content ([Attr, List[Row]]) – The content of the element.

class markupit.structure.content.Target(content: list)[source]

Bases: ContentElement

Class representing a Target element.

Parameters:

content ([str, str]) – The content of the element.

markupit.structure.document module

class markupit.structure.document.Document(blocks: List[Element] | None = None)[source]

Bases: object

A class representing a document. It contains a list of blocks.

Parameters:

blocks (List[Element], optional) – A list of blocks in the document.

add_block(block: Element) None[source]

Add a block to the end of the document.

Parameters:

block (Element) – The block to add.

add_blocks(blocks: List[Element]) None[source]

Add a list of blocks to the end of the document.

Parameters:

blocks (List[Element]) – The blocks to add.

to_json() dict[source]

Convert the document to a dictionary representing AST.

Returns:

The document as a dictionary.

Return type:

dict

markupit.structure.enum module

class markupit.structure.enum.Alignment(content: str)[source]

Bases: EnumElement

Class representing an Alignment enum element.

Parameters:

content (str) – Chosen value from the enumeration.

class markupit.structure.enum.CitationMode(content: str)[source]

Bases: EnumElement

Class representing a CitationMode enum element.

Parameters:

content (str) – Chosen value from the enumeration.

class markupit.structure.enum.ColWidth(content: str, width: float | None = None)[source]

Bases: EnumElement

Class representing a ColWidth enum element.

Parameters:
  • content (str) – Chosen value from the enumeration.

  • width (float, optional) – The width of the column, used when content is ‘ColWidth’.

class markupit.structure.enum.ListNumberDelim(content: str)[source]

Bases: EnumElement

Class representing a ListNumberDelim enum element.

Parameters:

content (str) – Chosen value from the enumeration.

class markupit.structure.enum.ListNumberStyle(content: str)[source]

Bases: EnumElement

Class representing a ListNumberStyle enum element.

Parameters:

content (str) – Chosen value from the enumeration.

class markupit.structure.enum.MathType(content: str)[source]

Bases: EnumElement

Class representing a MathType enum element.

Parameters:

content (str) – Chosen value from the enumeration.

class markupit.structure.enum.QuoteType(content: str)[source]

Bases: EnumElement

Class representing a QuoteType enum element.

Parameters:

content (str) – Chosen value from the enumeration.

markupit.structure.general_types module

class markupit.structure.general_types.Block(content: Any | None = None)[source]

Bases: Element

A class representing an element of Block type.

Parameters:

content (Any, optional) – The content of the element.

to_json() dict[source]

Convert the element to a JSON representation of AST.

Returns:

The element as a JSON object.

Return type:

dict

class markupit.structure.general_types.ContentElement(content: Any)[source]

Bases: Element

Abstract class representing an element that is not represented by its tag in JSON.

Parameters:

content (Any) – The content of the element.

to_json() Any[source]

Convert the element to a JSON representation of AST.

Returns:

The element as a JSON object.

Return type:

Any

class markupit.structure.general_types.Element(tag: str | None = None, content: Any | None = None)[source]

Bases: ABC

An abstract class representing an element in a document.

Parameters:
  • tag (str, optional) – The name describing type of element.

  • content (Any, optional) – The content of the element.

abstract to_json() Any[source]

Convert the element to a JSON representation of AST.

Returns:

The element as a JSON object.

Return type:

Any

class markupit.structure.general_types.EnumElement(content: str)[source]

Bases: Element

Class representing an element of Enum type.

Parameters:

content (str) – Chosen value from the enumeration.

to_json() str[source]

Convert the element to a JSON representation of AST.

Returns:

The element as a JSON object.

Return type:

Any

class markupit.structure.general_types.Inline(content: Any | None = None)[source]

Bases: Element

A class representing an element of Inline type.

Parameters:

content (Any, optional) – The content of the element.

to_json() dict[source]

Convert the element to a JSON representation of AST.

Returns:

The element as a JSON object.

Return type:

dict

class markupit.structure.general_types.MetaValue(tag: str | None = None, content: Any | None = None)[source]

Bases: Element

markupit.structure.inline module

class markupit.structure.inline.Cite(content: list)[source]

Bases: Inline

A class representing a Cite element of Inline type.

Parameters:

content ([List[Citation], List[Inline]]) – The content of the element.

class markupit.structure.inline.Code(content: list)[source]

Bases: Inline

A class representing a Code element of Inline type.

Parameters:

content ([Attr, str]) – The content of the element.

class markupit.structure.inline.Emph(content: list)[source]

Bases: Inline

A class representing an Emph element of Inline type.

Parameters:

content (List[Inline]) – The content of the element.

class markupit.structure.inline.Image(content: list)[source]

Bases: Inline

A class representing an Image element of Inline type.

Parameters:

content ([Attr, List[Inline], Target]) – The content of the element.

class markupit.structure.inline.LineBreak[source]

Bases: Inline

A class representing a LineBreak element of Inline type.

Bases: Inline

A class representing a Link element of Inline type.

Parameters:

content ([Attr, List[Inline], Target]) – The content of the element.

class markupit.structure.inline.Math(content: list)[source]

Bases: Inline

A class representing a Math element of Inline type.

Parameters:

content ([EnumElement, str]) – The content of the element.

class markupit.structure.inline.Note(content: list)[source]

Bases: Inline

A class representing a Note element of Inline type.

Parameters:

content (List[Block]) – The content of the element.

class markupit.structure.inline.Quoted(content: list)[source]

Bases: Inline

A class representing a Quoted element of Inline type.

Parameters:

content ([QuoteType, List[Inline]]) – The content of the element.

class markupit.structure.inline.RawInline(content: list)[source]

Bases: Inline

A class representing a RawInline element of Inline type.

Parameters:

content ([Format, str]) – The content of the element.

class markupit.structure.inline.SmallCaps(content: list)[source]

Bases: Inline

A class representing a SmallCaps element of Inline type.

Parameters:

content (List[Inline]) – The content of the element.

class markupit.structure.inline.SoftBreak[source]

Bases: Inline

A class representing a SoftBreak element of Inline type.

class markupit.structure.inline.Space[source]

Bases: Inline

A class representing a Space element of Inline type.

class markupit.structure.inline.Span(content: list)[source]

Bases: Inline

A class representing a Span element of Inline type.

Parameters:

content ([Attr, List[Inline]]) – The content of the element.

class markupit.structure.inline.Str(content: str)[source]

Bases: Inline

A class representing a Str element of Inline type.

Parameters:

content (str) – The content of the element.

class markupit.structure.inline.Strikeout(content: list)[source]

Bases: Inline

A class representing a Strikeout element of Inline type.

Parameters:

content (List[Inline]) – The content of the element.

class markupit.structure.inline.Strong(content: list)[source]

Bases: Inline

A class representing a Strong element of Inline type.

Parameters:

content (List[Inline]) – The content of the element.

class markupit.structure.inline.Subscript(content: list)[source]

Bases: Inline

A class representing a Subscript element of Inline type.

Parameters:

content (List[Inline]) – The content of the element.

class markupit.structure.inline.Superscript(content: list)[source]

Bases: Inline

A class representing a Superscript element of Inline type.

Parameters:

content (List[Inline]) – The content of the element.

class markupit.structure.inline.Underline(content: list)[source]

Bases: Inline

A class representing an Underline element of Inline type.

Parameters:

content (List[Inline]) – The content of the element.

Module contents

class markupit.structure.Document(blocks: List[Element] | None = None)[source]

Bases: object

A class representing a document. It contains a list of blocks.

Parameters:

blocks (List[Element], optional) – A list of blocks in the document.

add_block(block: Element) None[source]

Add a block to the end of the document.

Parameters:

block (Element) – The block to add.

add_blocks(blocks: List[Element]) None[source]

Add a list of blocks to the end of the document.

Parameters:

blocks (List[Element]) – The blocks to add.

to_json() dict[source]

Convert the document to a dictionary representing AST.

Returns:

The document as a dictionary.

Return type:

dict