Code

Code formatting tags

class disseminate.tags.code.Code(*args, **kwargs)

Bases: disseminate.tags.tag.Tag

A tag for displaying code.

html_fmt(content=None, attributes=None, format_func='html_fmt', method='html', level=1)

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).

property lexer

Get the lexer for code highlighting.

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

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.code.Dm(*args, **kwargs)

Bases: disseminate.tags.code.Code

A tag for displaying dm code

class disseminate.tags.code.Html(*args, **kwargs)

Bases: disseminate.tags.code.Code

A tag for displaying html code

class disseminate.tags.code.Java(*args, **kwargs)

Bases: disseminate.tags.code.Code

A tag for displaying ruby code

class disseminate.tags.code.Javascript(*args, **kwargs)

Bases: disseminate.tags.code.Code

A tag for displaying javascript code

class disseminate.tags.code.Python(*args, **kwargs)

Bases: disseminate.tags.code.Code

A tag for displaying python code

class disseminate.tags.code.Ruby(*args, **kwargs)

Bases: disseminate.tags.code.Code

A tag for displaying ruby code