algebraixlib.util.html module

Utilities that present MathObjects as HTML pages.

class algebraixlib.util.html.DataAlgebraHtmlDescriptor(input_title, data_algebra_construct, description_brief)

Bases: tuple

Named tuple for collecting information about a MathObject. It contains: - input_title: (Optional) A string that can serve as a name, origin expression or title. - data_algebra_construct: The MathObject or container of MathObjects. - description_brief: (Optional) A string to display more detail.

static __new__(_cls, input_title, data_algebra_construct, description_brief)

Create new instance of DataAlgebraHtmlDescriptor(input_title, data_algebra_construct, description_brief)

__repr__()

Return a nicely formatted representation string

data_algebra_construct

Alias for field number 1

description_brief

Alias for field number 2

input_title

Alias for field number 0

algebraixlib.util.html.math_object_as_html(title: str, data_algebra_html_descriptors: [], header_template: str = None, footer_template: str = None, mathobject_template: str = None) → str[source]

Return the contents of an HTML webpage representing a MathObject, using templates.

Parameters:
  • title – The title for this page of MathObjects.
  • data_algebra_html_descriptors – An array of DataAlgebraHtmlDescriptor instances (containing math objects and their related descriptive strings).
  • header_template – HTML markup that starts the webpage. May contain the template variable page_title; it is set to the value of title.
  • footer_template – HTML markup that ends the page.
  • mathobject_template – The HTML markup that is emited for each math object. May contain the template variables input_title, description_brief and data_algebra_construct, which are replaced with the respective values in the associated DataAlgebraHtmlDescriptor.
algebraixlib.util.html.as_html_handle_basic_parameter(html_input: str) → str[source]

Return the string of html_input, properly escaped for using it in HTML.

algebraixlib.util.html.as_html_handle_data_algebra(mathobj)[source]

Return mathobj converted into a string safe to be used in HTML.

  • If mathobj is a MathObject, it will be represented as LaTeX markup and wrapped in the mathjax escape token.
  • If it is a container of MathObjects, then each one will be represented as LaTeX markup and displayed on its own line.
  • If it is not a MathObject then the str function will be invoked.
algebraixlib.util.html.build_descriptors_from_math_obj(mathobjects)[source]

Return an array of simple DataAlgebraHtmlDescriptor of the objects in mathobjects.

Parameters:mathobjects – List of objects from which to create descriptors.
algebraixlib.util.html.create_simple_web_page(mathobj: algebraixlib.mathobjects.mathobject.MathObject) → str[source]

Return an HTML string for a simple HTML page from a single MathObject.