Headings

Tags for headings.

class disseminate.tags.headings.Chapter(name, content, attributes, context, **kwargs)

Bases: disseminate.tags.headings.Heading

class disseminate.tags.headings.Heading(name, content, attributes, context, **kwargs)

Bases: disseminate.tags.tag.Tag, disseminate.tags.label.LabelMixin

A heading tag.

Note

If the content isn’t specified and an entry exists in the context with the tag’s name, then this tag’s content will be replaced with the contents from the context.

default_fmt(content=None, attributes=None)

Convert the tag to a text string.

Strips the tag information and simply return the content of the tag.

Parameters
contentOptional[Union[str, List[Union[str, list, Tag]]]

Specify an alternative content from the tag’s content. It can either be a string, a tag or a list of strings, tags and lists.

attributesOptional[Union[str, Attributes]]

Specify an alternative attributes dict from the tag’s attributes. It can either be a string or an attributes dict.

Returns
text_stringstr

A text string with the tags stripped.

generate_label_id()

Generate the label_id to use in creating the label.

Override this function to customize the generation of the label_id.

Returns
label_idstr

The generated label_id.

generate_label_kind()

Generate the kind tuple for the created label.

Override this function to customize the generation of the label kind.

Returns
kindTuple[str]

A tuple of strings for the kind of label. ex: (‘heading’, ‘chapter’)

html_fmt(content=None, **kwargs)

Convert the tag to an html string or html element.

Parameters
contentOptional[Union[str, List[Union[str, list, Tag]]]

Specify an alternative content from the tag’s content. It can either be a string, a tag or a list of strings, tags and lists.

attributesOptional[Union[str, Attributes]]

Specify an alternative attributes dict from the tag’s attributes. It can either be a string or an attributes dict.

format_funcOptional[str]

The format function to use with by formatted_content when formatting sub-tags.

methodOptional[str]

The rendering method for the string. ex: ‘html’ or ‘xml’

levelOptional[int]

The level of the tag.

Returns
htmlstr or html element

A string in HTML format or an HTML element (lxml.builder.E).

tex_fmt(content=None, attributes=None, mathmode=False, level=1, **kwargs)

Format the tag in LaTeX format.

Parameters
contentOptional[Union[str, List[Union[str, list, Tag]]]

Specify an alternative content from the tag’s content. It can either be a string, a tag or a list of strings, tags and lists.

attributesOptional[Union[str, Attributes]]

Specify an alternative attributes dict from the tag’s attributes. It can either be a string or an attributes dict.

mathmodeOptional[bool]

If True, the tag will be rendered in math mode. Otherwise (default) latex text mode is assumed.

levelOptional[int]

The level of the tag.

Returns
tex_stringstr

The formatted tex string.

class disseminate.tags.headings.Para(name, content, attributes, context)

Bases: disseminate.tags.tag.Tag

A paragraph heading tag.

class disseminate.tags.headings.Part(name, content, attributes, context, **kwargs)

Bases: disseminate.tags.headings.Heading

class disseminate.tags.headings.Section(name, content, attributes, context, **kwargs)

Bases: disseminate.tags.headings.Heading

A section heading tag.

class disseminate.tags.headings.SubSection(name, content, attributes, context, **kwargs)

Bases: disseminate.tags.headings.Heading

A subsection heading tag.

class disseminate.tags.headings.SubSubSection(name, content, attributes, context, **kwargs)

Bases: disseminate.tags.headings.Heading

A subsubsection heading tag.

class disseminate.tags.headings.Title(name, content, attributes, context, **kwargs)

Bases: disseminate.tags.headings.Heading