text¶
Classes and functions for text markup manipulation.
MarkupText ¶
Text with optional markup.
This class should not be instantiated directly, but only through its class method constructors. This is because the internal representation of the markup text may change at any time.
contains_markup
property
¶
contains_markup
True if this text contains markup; False if it is a plain string.
as_html ¶
as_html(allow_url=True)
as_latex ¶
as_latex()
Returns:
Type | Description |
---|---|
str
|
Text with markup transformed into LaTeX commands. |
as_text ¶
as_text()
Returns:
Type | Description |
---|---|
str
|
The plain text with any markup stripped. The only transformation that will be performed is replacing TeX-math expressions with their corresponding Unicode representation, if possible. |
from_string
classmethod
¶
from_string(text)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text |
str
|
A simple text string without any markup. |
required |
Returns:
Type | Description |
---|---|
MarkupText
|
Instantiated MarkupText object corresponding to the string. |
from_xml
classmethod
¶
from_xml(element)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
element |
_Element
|
An XML element containing valid MarkupText according to the schema. |
required |
Returns:
Type | Description |
---|---|
MarkupText
|
Instantiated MarkupText object corresponding to the element. |