markupit.writers package

Submodules

markupit.writers.json_writer module

class markupit.writers.json_writer.JsonWriter(input: Document)[source]

Bases: object

A class representing a JSON writer for a document.

Parameters:

input (Document) – The document to write.

write() → dict[source]

Return a JSON representation of AST.

Returns:

The document as a dictionary.

write_to_file(filename: str) → None[source]

Write the JSON representation of AST to a file.

Parameters:

filename (str) – The name of the file to write to.

markupit.writers.typst_writer module

class markupit.writers.typst_writer.TypstWriter(input: Document)[source]

Bases: Writer

A class representing a Typst writer for a document.

Parameters:

input (Document) – The document to write.

convert_block_quote(obj: BlockQuote) → str[source]
convert_bullet_list(obj: BulletList, nesting: int = 0) → str[source]
convert_code(obj: Code) → str[source]
convert_code_block(obj: CodeBlock) → str[source]
convert_emph(obj: Emph) → str[source]
convert_header(obj: Header) → str[source]
convert_horizontal_rule(obj: HorizontalRule) → str[source]
convert_image(obj: Image) → str[source]
convert_line_break(obj: LineBreak) → str[source]
convert_note(obj: Note) → str[source]
convert_ordered_list(obj: OrderedList, nesting: int = 0) → str[source]
convert_para(obj: Para) → str[source]
convert_plain(obj: Plain) → str[source]
convert_raw_block(obj: RawBlock) → str[source]
convert_raw_inline(obj: RawInline) → str[source]
convert_small_caps(obj: SmallCaps) → str[source]
convert_soft_break(obj: SoftBreak) → str[source]
convert_space(obj: Space) → str[source]
convert_str(obj: Str) → str[source]
convert_strikeout(obj: Strikeout) → str[source]
convert_strong(obj: Strong) → str[source]
convert_subscript(obj: Subscript) → str[source]
convert_superscript(obj: Superscript) → str[source]
convert_table(obj: Table) → str[source]
convert_underline(obj: Underline) → str[source]

markupit.writers.writer module

class markupit.writers.writer.Writer(input: Document)[source]

Bases: ABC

An abstract class representing a writer.

Parameters:

input (structure.Document) – The document to convert.

abstract convert_block_quote(obj: BlockQuote) → str[source]
abstract convert_bullet_list(obj: BulletList) → str[source]
abstract convert_code(obj: Code) → str[source]
abstract convert_code_block(obj: CodeBlock) → str[source]
convert_element(obj: Element) → str[source]

Find and perform conversion for the given element.

Parameters:

obj (Element) – The element to convert.

Returns:

The converted element.

abstract convert_emph(obj: Emph) → str[source]
abstract convert_header(obj: Header) → str[source]
abstract convert_horizontal_rule(obj: HorizontalRule) → str[source]
abstract convert_image(obj: Image) → str[source]
abstract convert_line_break(obj: LineBreak) → str[source]
abstract convert_note(obj: Note) → str[source]
abstract convert_ordered_list(obj: OrderedList) → str[source]
abstract convert_para(obj: Para) → str[source]
abstract convert_plain(obj: Plain) → str[source]
abstract convert_raw_block(obj: RawBlock) → str[source]
abstract convert_raw_inline(obj: RawInline) → str[source]
abstract convert_small_caps(obj: SmallCaps) → str[source]
abstract convert_soft_break(obj: SoftBreak) → str[source]
abstract convert_space(obj: Space) → str[source]
abstract convert_str(obj: Str) → str[source]
abstract convert_strikeout(obj: Strikeout) → str[source]
abstract convert_strong(obj: Strong) → str[source]
abstract convert_subscript(obj: Subscript) → str[source]
abstract convert_superscript(obj: Superscript) → str[source]
abstract convert_table(obj: Table) → str[source]
abstract convert_underline(obj: Underline) → str[source]
write() → str[source]

Convert the document to a text format according to writer.

Returns:

The converted document.

write_file(path: str) → None[source]

Convert and write the document to a file at the given path.

Parameters:

path (str) – The path to write the document to.

Module contents

class markupit.writers.JsonWriter(input: Document)[source]

Bases: object

A class representing a JSON writer for a document.

Parameters:

input (Document) – The document to write.

write() → dict[source]

Return a JSON representation of AST.

Returns:

The document as a dictionary.

write_to_file(filename: str) → None[source]

Write the JSON representation of AST to a file.

Parameters:

filename (str) – The name of the file to write to.

class markupit.writers.LatexWriter(input: Document)[source]

Bases: Writer

A class representing a Latex writer for a document.

Parameters:

input (Document) – The document to write.

convert_block_quote(obj: BlockQuote) → str[source]
convert_bullet_list(obj: BulletList, nesting: int = 0) → str[source]
convert_code(obj: Code) → str[source]
convert_code_block(obj: CodeBlock) → str[source]
convert_emph(obj: Emph) → str[source]
convert_header(obj: Header) → str[source]
convert_horizontal_rule(obj: HorizontalRule) → str[source]
convert_image(obj: Image) → str[source]
convert_line_break(obj: LineBreak) → str[source]
convert_note(obj: Note) → str[source]
convert_ordered_list(obj: OrderedList, nesting: int = 0) → str[source]
convert_para(obj: Para) → str[source]
convert_plain(obj: Plain) → str[source]
convert_raw_block(obj: RawBlock) → str[source]
convert_raw_inline(obj: RawInline) → str[source]
convert_small_caps(obj: SmallCaps) → str[source]
convert_soft_break(obj: SoftBreak) → str[source]
convert_space(obj: Space) → str[source]
convert_str(obj: Str) → str[source]
convert_strikeout(obj: Strikeout) → str[source]
convert_strong(obj: Strong) → str[source]
convert_subscript(obj: Subscript) → str[source]
convert_superscript(obj: Superscript) → str[source]
convert_table(obj: Table) → str[source]
convert_underline(obj: Underline) → str[source]
class markupit.writers.TypstWriter(input: Document)[source]

Bases: Writer

A class representing a Typst writer for a document.

Parameters:

input (Document) – The document to write.

convert_block_quote(obj: BlockQuote) → str[source]
convert_bullet_list(obj: BulletList, nesting: int = 0) → str[source]
convert_code(obj: Code) → str[source]
convert_code_block(obj: CodeBlock) → str[source]
convert_emph(obj: Emph) → str[source]
convert_header(obj: Header) → str[source]
convert_horizontal_rule(obj: HorizontalRule) → str[source]
convert_image(obj: Image) → str[source]
convert_line_break(obj: LineBreak) → str[source]
convert_note(obj: Note) → str[source]
convert_ordered_list(obj: OrderedList, nesting: int = 0) → str[source]
convert_para(obj: Para) → str[source]
convert_plain(obj: Plain) → str[source]
convert_raw_block(obj: RawBlock) → str[source]
convert_raw_inline(obj: RawInline) → str[source]
convert_small_caps(obj: SmallCaps) → str[source]
convert_soft_break(obj: SoftBreak) → str[source]
convert_space(obj: Space) → str[source]
convert_str(obj: Str) → str[source]
convert_strikeout(obj: Strikeout) → str[source]
convert_strong(obj: Strong) → str[source]
convert_subscript(obj: Subscript) → str[source]
convert_superscript(obj: Superscript) → str[source]
convert_table(obj: Table) → str[source]
convert_underline(obj: Underline) → str[source]