tumblr.content

Provides several content blocks to make up post bodies

Classes

Block()

Abstract base class of content blocks

ContentBlock()

Abstract base class of normal text content blocks

MultiBlock()

Abstract base class of container blocks

DataBlock(path, mime_type)

Abstract base class of content blocks that link to data

RawText(content, subtype, **kwargs)

Raw text block - creates text with the specified subtype

Text(content, **kwargs)

A Text content block with the given content.

Heading(content, **kwargs)

A Heading1 Text subtype content block with the given content.

Subheading(content, **kwargs)

A Heading2 Text subtype content block with the given content.

Cursive(content, **kwargs)

A quirky Text subtype content block with the given content.

Quote(content, **kwargs)

A quote Text subtype content block with the given content.

Chat(content, **kwargs)

A chat Text subtype content block with the given content.

OrderedListItem(content, **kwargs)

An ordered-list-item Text subtype content block with the given content.

UnorderedListItem(content, **kwargs)

An unordered-list-item Text subtype content block with the given content.

OrderedList(items, **kwargs)

A list of ordered-list-item Text subtype content blocks with the given items in the content list.

UnorderedList(items, **kwargs)

A list of unordered-list-item Text subtype content blocks with the given items in the content list.

Indented(content, **kwargs)

An indented Text subtype content block with the given content.

Poll(question, options, *[, expire_after])

A poll content block.

Image(path, img_type, alt_text[, caption])

An Image block.

ReadMore()

Inserts a "keep reading" bar that truncates the post.

Row(*images)

Creates a row of images.

class Block

Abstract base class of content blocks

class ContentBlock

Abstract base class of normal text content blocks

abstractmethod data() Mapping

The data associated with this block

class MultiBlock

Abstract base class of container blocks

abstractmethod data() Iterable[Mapping]

The data associated with this block’s children

class DataBlock(path: PurePath | str, mime_type: str)

Abstract base class of content blocks that link to data

class RawText(content: str, subtype: str, **kwargs)

Raw text block - creates text with the specified subtype

data() Mapping

The data associated with this block

class Text(content: str, **kwargs)

A Text content block with the given content.

See: https://www.tumblr.com/docs/npf#content-block-type-text

data()

The data associated with this block

class Heading(content: str, **kwargs)

A Heading1 Text subtype content block with the given content.

See: https://www.tumblr.com/docs/npf#content-block-type-text

class Subheading(content: str, **kwargs)

A Heading2 Text subtype content block with the given content.

See: https://www.tumblr.com/docs/npf#content-block-type-text

class Cursive(content: str, **kwargs)

A quirky Text subtype content block with the given content.

See: https://www.tumblr.com/docs/npf#content-block-type-text

class Quote(content: str, **kwargs)

A quote Text subtype content block with the given content.

See: https://www.tumblr.com/docs/npf#content-block-type-text

class Chat(content: str, **kwargs)

A chat Text subtype content block with the given content.

See: https://www.tumblr.com/docs/npf#content-block-type-text

class OrderedListItem(content: str, **kwargs)

An ordered-list-item Text subtype content block with the given content.

See: https://www.tumblr.com/docs/npf#content-block-type-text

class UnorderedListItem(content: str, **kwargs)

An unordered-list-item Text subtype content block with the given content.

See: https://www.tumblr.com/docs/npf#content-block-type-text

class OrderedList(items: list[str], **kwargs)

A list of ordered-list-item Text subtype content blocks with the given items in the content list. Passes all kwargs onto each individual list item.

data()

The data associated with this block’s children

class UnorderedList(items: list[str], **kwargs)

A list of unordered-list-item Text subtype content blocks with the given items in the content list. Passes all kwargs onto each individual list item.

data()

The data associated with this block’s children

class Indented(content: str, **kwargs)

An indented Text subtype content block with the given content.

See: https://www.tumblr.com/docs/npf#content-block-type-text

class Poll(question: str, options: Iterable[str], *, expire_after: timedelta = datetime.timedelta(days=7))

A poll content block. This is not officially documented yet, so who knows if it’s going to change!

Note

  • expire_after is clamped between 1 and 7 days serverside

  • Only one poll can be in each post and this is enforced serverside

  • At least 2 and at most 12 options can be provided each having a max of 80 characters.

Parameters:
  • question – The Poll prompt

  • options – The poll options

  • expire_after – a time delta of when the poll will close (default 7 days)

data() Mapping

The data associated with this block

class Image(path: PurePath | str, img_type: str, alt_text: str, caption: str = None)

An Image block.

See: https://www.tumblr.com/docs/npf#content-block-type-image

Parameters:
  • path – The path to the image

  • img_type – The image MIME type

  • alt_text – Image Alt Text

  • caption – Optional Caption (displayed under image when viewed)

class ReadMore

Inserts a “keep reading” bar that truncates the post. Only one can be added per post.

See: https://www.tumblr.com/docs/npf#read-more

class Row(*images: Image)

Creates a row of images.

Parameters:

images – varargs of Image blocks.